Open james-willis opened 1 month ago
OverlayNG supersedes the old overlay algorithm. It is significantly more robust, particularly when using OverlayNGRobust
. (Unfortunately there are still a few failure cases - see #1000. Hopefully these can be sorted out soonish).
I suggest switching to using the OverlayNGRobust
API. This can used for the Geometry
overlay methods via the -Djts.overlay=ng
flag. In the release it will become the default algorithm, and OverlayOp
will be deprecated.
A user of Apache Sedona reported an issue where computing the intersection of a valid multipolygon and a valid polygon throws a "found non-noded intersection" Topology Exception. I have reproduced the issue in JTS.
There seems to be a problem in the SnapIfNeededOverlayOp implementation but not OverlayNGRobust. The issue is not symmetric; one ordering of the geometries returns correctly but the other throws the exception.
2 questions: 1) Is there some fix that should be made to SnapIfNeededOverlayOp to avoid failure in this case? Is there a way to detect cases where this failure mode might be encountered? 2) Is there any downside to using OverlayNGRobust? That is the work around that the Sedona users are using for now.
The polygons:
Note that last of the polygons in the MultiPolygon is incredibly small.
This runs fine:
(new SnapIfNeededOverlayOp(multiPolygon, polygon)).getResultGeometry(OverlayNG.INTERSECTION)
This throws the exception:
(new SnapIfNeededOverlayOp(polygon, multiPolygon)).getResultGeometry(OverlayNG.INTERSECTION)
OverlayNGRobust works fine with both orderings:
I tested some other Overlay implementations as well.
Both orders of OverlayOp fail with the error above:
both orderings of the non-robust NG throw the error above:
The 'good order' works with SnapOverlay:
(new SnapOverlayOp(multiPolygon, polygon)).getResultGeometry(OverlayNG.INTERSECTION)
The 'bad order' throws a new exception:
(new SnapOverlayOp(polygon, multiPolygon)).getResultGeometry(OverlayNG.INTERSECTION)
: