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:
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.
Recently two issues were reported in PostGIS (this and this) about inconsistent results between the
intersects
andPreparedGeometry.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: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 thatPreparedGeometry.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.Also logged as GEOS-565.
Patch also removes some obsolete code to simplify logic.
Signed-off-by: Martin Davis mtnclimb@gmail.com