I am using postgis's ST_LineLocatePoint to find out the closest point on a LineString to the given Point, and using ST_LineInterpolatePoint to extract a Point from the returned float number.(as referred here)
This is my ST_LineLocatePoint Query:
SELECT ST_AsText(ST_LineInterpolatePoint(foo.the_line, ST_LineLocatePoint(foo.the_line,ST_GeomFromText('POINT(12.962315 77.584841)')))) AS g FROM (SELECT ST_GeomFromText('LINESTRING(12.96145 77.58408,12.96219 77.58447,12.96302 77.58489,12.96316 77.58496,12.96348 77.58511)') AS the_line) AS foo; Output:
g ------------------------------------------ POINT(12.9624389808159 77.5845959902924) Which exactly lies on the linestring I have passed. Demonstration is displayed here.
But when I check whether this point lies in the same linestring using ST_Contains it always return false, even though the point lies within.
My ST_Contains Query:
SELECT ST_Contains(ST_GeomFromText('LINESTRING(12.96145 77.58408,12.96219 77.58447,12.96302 77.58489, 12.96316 77.58496, 12.96348 77.58511)'),ST_GeomFromText('POINT(12.9624389808159 77.5845959902924)')); Output:
st_contains ------------- f I am not getting where I am doing wrong, why I am getting false. Can anyone help me in this.
Postgresql : 9.4 postgis : 2.1
أكثر...
This is my ST_LineLocatePoint Query:
SELECT ST_AsText(ST_LineInterpolatePoint(foo.the_line, ST_LineLocatePoint(foo.the_line,ST_GeomFromText('POINT(12.962315 77.584841)')))) AS g FROM (SELECT ST_GeomFromText('LINESTRING(12.96145 77.58408,12.96219 77.58447,12.96302 77.58489,12.96316 77.58496,12.96348 77.58511)') AS the_line) AS foo; Output:
g ------------------------------------------ POINT(12.9624389808159 77.5845959902924) Which exactly lies on the linestring I have passed. Demonstration is displayed here.
But when I check whether this point lies in the same linestring using ST_Contains it always return false, even though the point lies within.
My ST_Contains Query:
SELECT ST_Contains(ST_GeomFromText('LINESTRING(12.96145 77.58408,12.96219 77.58447,12.96302 77.58489, 12.96316 77.58496, 12.96348 77.58511)'),ST_GeomFromText('POINT(12.9624389808159 77.5845959902924)')); Output:
st_contains ------------- f I am not getting where I am doing wrong, why I am getting false. Can anyone help me in this.
Postgresql : 9.4 postgis : 2.1
أكثر...