[postgis-users] [Question] Point returned in ST_LineLocatePoint and ST_ClosestPoint is not able to detect in ST_Contains
Dharshan Bharathur
dharshan4help at gmail.com
Tue Sep 29 21:59:00 PDT 2015
Hi all, Need experts advice.
This is the same question I have asked here.
<http://gis.stackexchange.com/questions/164683/point-returned-from-st-linelocatepoint-returns-false-in-st-contains>
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
<http://postgis.net/docs/ST_LineLocatePoint.html>)
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 <http://jsfiddle.net/2p3zekae/2/>.
query with St_Closest function also returns the same points.
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.
I am using Postgresql : 9.4, postgis : 2.1
*Thanks & RegardsDharshan*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150930/36c3b0ed/attachment.html>
More information about the postgis-users
mailing list