From 156039b11929f5856bbefc3dc1b62a6397057cd0 Mon Sep 17 00:00:00 2001 From: Symmetricity <184246+Symmetricity@users.noreply.github.com> Date: Fri, 15 May 2026 19:34:15 +0200 Subject: [PATCH] Revalidate fast-clip spike repairs When fast_clip produces a polygon reported with failure_spikes, the existing code removes spikes and then continues with that geometry without checking whether it became valid. That can skip the existing Boost intersection fallback if the repaired geometry still has self-intersections or intersecting interiors. Run Boost's validity check again after remove_spikes so remaining self-intersection failures use the existing slower intersection path instead of being cached and returned as invalid clipped geometry. --- src/tile_data.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tile_data.cpp b/src/tile_data.cpp index 1233a029..10c2f11b 100644 --- a/src/tile_data.cpp +++ b/src/tile_data.cpp @@ -330,17 +330,22 @@ Geometry TileDataSource::buildWayGeometry(OutputGeometryType const geomType, fast_clip(mp, box); geom::correct(mp); geom::validity_failure_type failure = geom::validity_failure_type::no_failure; - if (!geom::is_valid(mp,failure)) { + bool valid = geom::is_valid(mp,failure); + if (!valid) { if (failure==geom::failure_spikes) { geom::remove_spikes(mp); - } else if (failure==geom::failure_self_intersections || failure==geom::failure_intersecting_interiors) { - // retry with Boost intersection if fast_clip has caused self-intersections + failure = geom::validity_failure_type::no_failure; + valid = geom::is_valid(mp,failure); + } + if (!valid && (failure==geom::failure_self_intersections || failure==geom::failure_intersecting_interiors)) { MultiPolygon output; geom::intersection(input, box, output); geom::correct(output); + + // retry with Boost intersection if fast_clip has caused self-intersections multiPolygonClipCache.add(bbox, objectID, output); return output; - } else { + } else if (!valid) { // occasionally also wrong_topological_dimension, disconnected_interior } }