From b6dbb9a3db0a2c5dd4b23f0c52328cb41a2029a5 Mon Sep 17 00:00:00 2001 From: Ignacio Vera Date: Tue, 29 Oct 2024 12:19:53 +0100 Subject: [PATCH] Try to simplify geometries that fail with TopologyException (#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. --- docs/changelog/115834.yaml | 5 +++++ .../xpack/vectortile/feature/FeatureFactory.java | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 docs/changelog/115834.yaml diff --git a/docs/changelog/115834.yaml b/docs/changelog/115834.yaml new file mode 100644 index 0000000000000..91f9e9a4e2e41 --- /dev/null +++ b/docs/changelog/115834.yaml @@ -0,0 +1,5 @@ +pr: 115834 +summary: Try to simplify geometries that fail with `TopologyException` +area: Geo +type: bug +issues: [] diff --git a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java index 0c4ff1780ae1e..b5f9088edc4be 100644 --- a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java +++ b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java @@ -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; } } }