diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/geo/DouglasPeuckerSimplifier.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/geo/DouglasPeuckerSimplifier.java index ac76603a5e..6ccb2bca5e 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/geo/DouglasPeuckerSimplifier.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/geo/DouglasPeuckerSimplifier.java @@ -38,7 +38,7 @@ public class DouglasPeuckerSimplifier { * @return the simplified geometry */ public static Geometry simplify(Geometry geom, double distanceTolerance) { - if (geom.isEmpty()) { + if (geom.isEmpty() || (distanceTolerance < 0.0)) { return geom.copy(); } diff --git a/planetiler-core/src/test/java/com/onthegomap/planetiler/FeatureMergeTest.java b/planetiler-core/src/test/java/com/onthegomap/planetiler/FeatureMergeTest.java index 4a3a38ca16..5a1b713ac0 100644 --- a/planetiler-core/src/test/java/com/onthegomap/planetiler/FeatureMergeTest.java +++ b/planetiler-core/src/test/java/com/onthegomap/planetiler/FeatureMergeTest.java @@ -165,6 +165,21 @@ void simplifyLineStringIfToleranceIsSet() { true ) ); + // but doesn't resimplify if the tolerance is negative even when resimplify=true + assertEquals( + List.of( + feature(1, newLineString(10, 10, 20, 20, 30, 30), Map.of("a", 1)) + ), + FeatureMerge.mergeLineStrings( + List.of( + feature(1, newLineString(10, 10, 20, 20, 30, 30), Map.of("a", 1)) + ), + 0, + -1, + 0, + true + ) + ); } @Test