Opened 25 hours ago
#5832 new defect
Intersection test error with curved polygons
Reported by: | aaime | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.5.2 |
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