If you are trying to solve a point in polygon problem, there are plenty of examples just within a google's reach.
If it is simply to find out whether the point coincides with one of the linestring vertices, a simple in
operator (for Python) can do the job pretty well - or you can iterate the vertices and compare using abs()
to introduce some coordinate precision tolerance.
If you want to know if the point lies on a polyline, iterate through the segment in the following way (Pythonic pseudocode):
function lies_on_polyline(point, vertices):
for i from 0 to vertices.length - 2: // finish on last-but-one
if lies_on_segment(point, vertices[i], vertices[i+1]):
return True
return False
function lies_on_segment(point, start, end):
deltax = end.x - start.x
if deltax == 0:
liesInXDir = (point.x == start.x)
else:
t = (point.x - start.x) / deltax
liesInXDir = (t >= 0 and t <= 1)
if liesInXDir:
deltay = end.y - start.y
if deltay == 0:
return (point.y == start.y)
else:
t = (point.y - start.y) / deltay
return (t >= 0 and t <= 1)
else:
return False