Skip to content

Commit

Permalink
Do not remove first edge of shortest path
Browse files Browse the repository at this point in the history
  • Loading branch information
wipfli committed Nov 9, 2024
1 parent 2076034 commit 49df8b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void removeLoops() {
List<Edge> removedEdges = new ArrayList<>();
for (var node : output) {
for (var edge : List.copyOf(node.getEdges())) {
if (removedEdges.contains(edge)) {
if (removedEdges.contains(edge) || removedEdges.contains(edge.reversed)) {
continue;
}
if (edge.from == edge.to && edge.length <= loopMinLength) {
Expand All @@ -113,8 +113,9 @@ private void removeLoops() {
try {
var allPaths = findAllPaths(edge.from, edge.to, loopMinLength);
if (allPaths.size() > 1) {
var firstEdgeShortestPath = allPaths.get(0).getFirst();
for (var path : allPaths.subList(1, allPaths.size())) {
if (path.size() > 0) {
if (path.size() > 0 && !firstEdgeShortestPath.equals(path.get(0))) {
removedEdges.add(path.get(0));
path.get(0).remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void testMergeCarriagewaysWithTwoSplits() {
@Test
void testRealWorldHarkingen() {
var merger = new LoopLineMerger()
.setMinLength(0)
.setMinLength(4 * 0.0625)
.setLoopMinLength(8 * 0.0625);

merger.add(newLineString(99.185791015625,109.83056640625, 99.202392578125,109.8193359375, 99.21337890625,109.810302734375, 99.222412109375,109.8017578125, 99.229736328125,109.793701171875, 99.241943359375,109.779541015625));
Expand Down

0 comments on commit 49df8b4

Please sign in to comment.