Skip to content

Commit

Permalink
Fix issue where merging adjacent points in a loop could disconnect th…
Browse files Browse the repository at this point in the history
…e loop from itself (close #7553)
  • Loading branch information
quincylvania committed May 19, 2020
1 parent 267707d commit 4515363
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions modules/actions/connect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { actionDeleteNode } from './delete_node';
import { actionDeleteWay } from './delete_way';
import { utilArrayUniq } from '../util';


Expand Down Expand Up @@ -36,9 +37,7 @@ export function actionConnect(nodeIDs) {

parents = graph.parentWays(node);
for (j = 0; j < parents.length; j++) {
if (!parents[j].areAdjacent(node.id, survivor.id)) {
graph = graph.replace(parents[j].replaceNode(node.id, survivor.id));
}
graph = graph.replace(parents[j].replaceNode(node.id, survivor.id));
}

parents = graph.parentRelations(node);
Expand All @@ -52,6 +51,14 @@ export function actionConnect(nodeIDs) {

graph = graph.replace(survivor);

// find and delete any degenerate ways created by connecting adjacent vertices
parents = graph.parentWays(survivor);
for (i = 0; i < parents.length; i++) {
if (parents[i].isDegenerate()) {
graph = actionDeleteWay(parents[i].id)(graph);
}
}

return graph;
};

Expand Down

0 comments on commit 4515363

Please sign in to comment.