You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GeometryPrecisionReducer inverts self-intersecting inner ring #974
While investigating onthegomap/planetiler#546 I found that GeometryPrecisionReducer can sometimes invert a hole of a polygon that has a small self-intersection and treat it as a separate polygon. It looks like the root cause is that EdgeNodingBuilder uses Orientation.isCCW on the inner ring, which gives the opposite result for that inner ring. Here is a simple test-case to reproduce:
Would it make sense to switch EdgeNodingBuilder to use isCCWArea instead of isCCW which handles this case as we would expect? Or at least expose which orientation method it uses as an option to OverlayNG and PrecisionReducer ? From a user perspective, it would also be fine for precision reducer to throw an exception in this case so we could re-try after fixing the polygon.
I'd be happy to make the change if any of those sound like a feasible path forward?
Like many JTS operations, GeometryPrecisionReducer required valid input. You can check validity using Geometry.isValid, and if invalid make it valid using GeometryFixer.
Invalid geometry can present in a multitude of different ways, and GeometryFixer contains extensive logic to determine how to fix it. Centralizing that logic in one place avoids a lot of code duplication and complexity.
Activity
dr-jts commentedon Apr 16, 2023
Like many JTS operations,
GeometryPrecisionReducerrequired valid input. You can check validity usingGeometry.isValid, and if invalid make it valid usingGeometryFixer.Invalid geometry can present in a multitude of different ways, and
GeometryFixercontains extensive logic to determine how to fix it. Centralizing that logic in one place avoids a lot of code duplication and complexity.