There are two issues here.  

I believe ST_AsText() does not return the full underlying precision of the 
point/line coordinates, so won't help resolve this.

Also, if you bear in mind your machine precision (or the Postgis coordinate 
precision - which may not be the same thing), the number of points on a 
linestring is finite, and makes the linestring actually a series of small 
steps. Think of it a bit like a series of pixels in a very fine raster. If 
horizontal or vertical, it works nicely, but any sort of diagonal & your line 
is only approximated. Two crossing diagonals do not necessarily have a pixel 
(point) in common.

A point using the value of pi as a coordinate - you can get very close, but 
"equals" is a meaningless operation.

Point on line intersections are therefore real number equality tests, and not 
reliable. Theoretically you can get different answers on 32/64 bit systems, or 
code compiled with different compilers (with different numerical precision), & 
if you export to any format that has reduced precision coordinates & re-import 
you can change the result as well. 

This also applies to points very nearly "on" the boundary of a polygon being 
inside or outside.

This is an issue for me using postgis topologies. Creating nodes (as points) at 
the intersections of linestrings can result in very slightly shifted 
linestrings - not quite the same as the originals.

For point-on-line queries, using ST_Within() & a near zero number will find 
points very nearly on a line, there is no operation that can measure this 
exactly.

Cheers,

   Brent Wood

--- On Sat, 5/18/13, Richard Cernava <[email protected]> wrote:

From: Richard Cernava <[email protected]>
Subject: [postgis-users] Strange behavior
To: [email protected]
Date: Saturday, May 18, 2013, 11:40 AM

I'm trying to query if a point is present inside a MultiLineString. When I run 
the following query I get very strange results in my opinion. If someone could 
elaborate as to what's going on it would be very much appreciated! 

>From this query I get a false and a true on the identical data. First I check 
>to see if the_geom intersects with my point and receive false. Second I take 
>the_geom and convert it to text and then compare it with my point using 
>ST_GeomFromText and get true. How is this possible? I've outputted the result 
>from the statement below.


SELECT fullname, ST_X(ST_StartPoint(ST_LineMerge(the_geom))), 
ST_Y(ST_StartPoint(ST_LineMerge(the_geom))),ST_AsText(the_geom) AS 
text,ST_Intersects(the_geom, ST_GeomFromText('POINT(-122.837109 45.537746)', 
4269)) AS fromdb,
ST_Intersects(ST_GeomFromText(ST_AsText(the_geom), 4269), 
ST_GeomFromText('POINT(-122.837109 45.537746)', 4269)) AS fromtxtfrom 
tiger_data.or_edges where   fullname like 'NW Norwich St' limit 1


"NW Norwich St";-122.837109;45.537746;"MULTILINESTRING((-122.837109 
45.537746,-122.837253 45.537684,-122.837718 45.537368,-122.837829 
45.537288,-122.838081 45.537108,-122.838169 45.537049))";f;t



-- 
-Richard


-----Inline Attachment Follows-----

_______________________________________________
postgis-users mailing list
[email protected]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

Reply via email to