diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LoopLineMerger.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LoopLineMerger.java index d7bc0336c3..325d006301 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LoopLineMerger.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LoopLineMerger.java @@ -308,7 +308,8 @@ private void simplify() { for (var node : output) { for (var edge : node.getEdges()) { if (edge.main) { - if (!edge.simplify()) { + edge.simplify(); + if (edge.isCollapsed()) { toRemove.add(edge); } } @@ -551,13 +552,16 @@ void remove() { return length; } - /** Returns {@code false} if simplifying this edge collapsed it to {@code length=0}. */ - boolean simplify() { + void simplify() { coordinates = DouglasPeuckerSimplifier.simplify(coordinates, tolerance, false); if (reversed != null) { reversed.coordinates = coordinates.reversed(); } - return coordinates.size() != 2 || !coordinates.getFirst().equals(coordinates.getLast()); + } + + boolean isCollapsed() { + return coordinates.size() < 2 || + (coordinates.size() == 2 && coordinates.getFirst().equals(coordinates.getLast())); } @Override