From 091bdb8a2b6d2e3027b7f8ce8ae75f5da0a30c84 Mon Sep 17 00:00:00 2001 From: Oliver Wipfli Date: Thu, 7 Nov 2024 22:30:53 +0100 Subject: [PATCH] Remove self-closing short loops in removeLoops --- .../com/onthegomap/planetiler/util/LoopLineMerger.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 72e9283cfa..e60c977390 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 @@ -98,7 +98,13 @@ private void removeLoops() { List removedEdges = new ArrayList<>(); for (var node : output) { for (var edge : List.copyOf(node.getEdges())) { - if (removedEdges.contains(edge) || edge.from == edge.to) { + if (removedEdges.contains(edge)) { + continue; + } + if (edge.from == edge.to && edge.length <= loopMinLength) { + // self-closing short loop + removedEdges.add(edge); + edge.remove(); continue; } try {