Opened 2 months ago

Last modified 6 weeks ago

#5832 new defect

Intersection test error with curved polygons

Reported by: aaime Owned by: pramsey
Priority: medium Milestone: PostGIS GEOS
Component: postgis Version: 3.4.x
Keywords: Cc:

Description

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

Change History (3)

comment:1 by robe, 8 weeks ago

Milestone: PostGIS 3.5.2PostGIS 3.5.3

Ticket retargeted after milestone closed

comment:2 by pramsey, 6 weeks ago

I am going to move this to PostGIS GEOS and leave dormant, as Dan Baston has been working on some improvements in GEOS to handle curves natively that would kill several birds with one stone. It's a long term solution. In the meanwhile, the workarounds are

  • know this is an issue and use distance == 0 as your intersects test as necessary

or

  • know this is an issue and preempt the built-in linearizer by pre-linearizing your inputs at the level you would prefer

comment:3 by pramsey, 6 weeks ago

Milestone: PostGIS 3.5.3PostGIS GEOS
Note: See TracTickets for help on using tickets.