Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RelateOp for a snapped line boundary point #839

Merged
merged 2 commits into from
Feb 16, 2022

Conversation

dr-jts
Copy link
Contributor

@dr-jts dr-jts commented Feb 16, 2022

Recently two issues were reported in PostGIS (this and this) about inconsistent results between the intersects and PreparedGeometry.intersects predicates.

The cases involve two line segments which cross very close to a segment endpoint which is also a boundary point of a line. The lines intersect according to the robust orientation tests (visible in the TestBuilder Magnify Topology mode). The intersects result is incorrect, because the IM matrix is being computed incorrectly, as shown here:

A: LINESTRING (-57.2681216 49.4063466, -57.267725199999994 49.406617499999996, -57.26747895046037 49.406750916517765)
B: LINESTRING (-57.267475399999995 49.4067465, -57.2675701 49.406864299999995, -57.267989 49.407135399999994)

image

The problem is that roundoff causes the computed intersection point to be equal to the boundary point. The intersection detection logic in SegmentIntersector.addIntersections was not handling this case correctly. (The reason that PreparedGeometry.intersects works is that it uses different and simpler logic.)

Note that there is an unavoidable inconsistency between the robust orientation predicates and the computed intersection point (which is subject to roundoff). The fix takes the computed point as being correct (thus effectively introducing an implicit, very small tolerance). This causes the computed IM to report touches as true as well.

image

Also logged as GEOS-565.

Patch also removes some obsolete code to simplify logic.

Signed-off-by: Martin Davis [email protected]

Also remove obsolete code

Signed-off-by: Martin Davis <[email protected]>
Signed-off-by: Martin Davis <[email protected]>
@dr-jts dr-jts merged commit 3952526 into locationtech:master Feb 16, 2022
@dr-jts dr-jts deleted the fix-relate-snapped-int branch February 16, 2022 18:27
@jodygarnett jodygarnett added this to the 1.19.0 milestone Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants