[postgis-devel] precision issue with several functions

Rémi Cura remi.cura at gmail.com
Wed Oct 9 07:15:33 PDT 2013


Hey fellow postgis users,
I ran into some precision issue.
(I use latest postgis/postgres/geos release on a ubuntu 12.0.4 :
postgis_full_version
POSTGIS="2.1.0 r11822" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6
March 2012" GDAL="GDAL 1.10.0, released 2013/04/24" LIBXML="2.8.0" TOPOLOGY
(topology procs from "2.0.3 r11128" need upgrade) RASTER ).

*I would appreciate expert answers on this as precision issued introduce**
 (silently) **very incoherent results. *


During a geometry processing, I project a point on a line using the
ST_CLosestPoint() function.

The issue are
_the projected point is at a residual distance of 2 x 10^-9 meters of the
line
_the projected point is not related to the line (ST_Relate FF*FF****)
_snapping the point to the line does nothing
_snapping the line to the point moves the line (and they relate :
0F*FF****).

So it appears to me that :

   - if spatial testing is more precise than 10^-9, ST_ClosestPoint()
   should return something more precise than this
   - (in the above example, a point projected on a  line is disjoint from
      this line)
   - ST_Snap() does nothing when snapping point on line with a vastly
   sufficient tolerance, but snapping the line to the point moves the line.
   This is at best incoherent.


It seems to be not related to size of coordinates (650880,X being the limit
for a float)


WITH the_geom AS (
SELECT ST_GeomFromText('MULTILINESTRING((651006 6860741.8,650880.2
6860649.4,650872.7 6860644.9))', 931008) AS the_line
, ST_GeomFromText('POINT(650996.890345122 6860735.10896573)', 931008) AS
the_point
),
the_geom_plus AS (
SELECT the_line, the_point,
ST_Snap(the_point,the_line,0.1) AS the_snapped_point,
ST_Snap(the_line,the_point,0.1) AS the_snapped_line
FROM the_geom
)
SELECT ST_Distance(the_point,the_line) AS distance_between_point_and_line,
ST_Distance(the_snapped_point,the_line) AS
distance_between_point_snapped_and_line,
ST_Distance(the_line, ST_ClosestPoint(the_line,the_point) )
distance_with_closest_point,
ST_Distance(the_point, the_snapped_line) AS
distance_betweenpoint_and_snapped_line,
ST_Disjoint(the_point,the_line) are_they_disjoint,
ST_Relate(the_point,the_line) relation_between_point_and_line,
ST_Relate(the_snapped_point,the_line)
relation_between_snapped_point_and_line,
ST_Relate(the_snapped_point,the_snapped_line)
relation_between_snapped_point_and_snapped_line,
ST_Intersects(the_point,the_line) do_they_intersect,
ST_Touches(the_point,the_line) do_they_touch,
ST_Within(the_point,the_line) is_the_point_within_the_line
FROM the_geom_plus


[image: Images intégrées 1]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20131009/d1583df2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 13257 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20131009/d1583df2/attachment.png>


More information about the postgis-devel mailing list