[PostGIS] #5832: Intersection test error with curved polygons

PostGIS trac at osgeo.org
Tue Jan 7 02:35:27 PST 2025


#5832: Intersection test error with curved polygons
---------------------+---------------------------
 Reporter:  aaime    |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 3.5.2
Component:  postgis  |    Version:  3.4.x
 Keywords:           |
---------------------+---------------------------
 As reported on the user list, I'm encountering a precision problem with an
 intersection test involving curve polygons.

 Test data can be found in this Github Gist:
 https://gist.github.com/aaime/dcf55b635c5bd09c2b9ebb31a2ab083a

 Test for intersection with a point returns two polygons, while only one
 polygon actually contains the point:

 {{{
 SELECT ogc_fid FROM testdata WHERE ST_Intersects(geom,
 ST_GeomFromText('POINT (25492818 6677399.98)', 3879));
  ogc_fid
 ---------
     1258
    12875
 (2 rows)
 }}}

 The issue has been verified with:
 * postgis 3.2 and postgresql 14.15
 * postgis 3.5 and postgresql 17.2 (latest postgis docker image)

 After discussion we found the issue is that the are linearized before the
 intersection test with GEOS, and that using a native curve operator like
 distance offers instead the correct result:

 {{{
 SELECT ogc_fid, ST_Distance(ST_GeomFromText('POINT (25492818 6677399.98)',
 3879), geom) FROM testdata;

  ogc_fid |     st_distance
 ---------+---------------------
     1258 | 0.01234572446598792
    12875 |                   0
 (2 rows)
 }}}

 It looks like the issue could be addressed in a few ways:
 * Native curve support for intersection (hard)
 * For more practical applications, maybe allow control of the tolerance
 used in linearization? Someone knowing the accuracy of their data could
 set a variable declaring the desired precision
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5832>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list