Skip to content

Commit

Permalink
Try to simplify geometries that fail with TopologyException (elastic#…
Browse files Browse the repository at this point in the history
…115834)

This geometries are valid and they can actually be simplified so lets make the clipping algorithm a best effort and 
return the original geometry in those cases so the simplification can handle it.
  • Loading branch information
iverase committed Oct 29, 2024
1 parent be45461 commit a3d1ba5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/115834.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 115834
summary: Try to simplify geometries that fail with `TopologyException`
area: Geo
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,11 @@ private static org.locationtech.jts.geom.Geometry clipGeometry(
return null;
}
} catch (TopologyException ex) {
// we should never get here but just to be super safe because a TopologyException will kill the node
throw new IllegalArgumentException(ex);
// Note we should never throw a TopologyException as it kill the node
// unfortunately the intersection method is not perfect and it will throw this error for complex
// geometries even when valid. We can still simplify such geometry so we just return the original and
// let the simplification process handle it.
return geometry;
}
}
}
Expand Down

0 comments on commit a3d1ba5

Please sign in to comment.