Now that updateNode preserves circularity, provide close/unclose functions

This lets us break closed ways at their connecting node in the few situations where
we actually want that behavior (disconnect action for circular non-area ways)
This commit is contained in:
Bryan Housel
2017-01-09 19:41:38 -05:00
parent 8676dd6e4c
commit 73e27c9657
2 changed files with 38 additions and 5 deletions
+5 -2
View File
@@ -31,6 +31,9 @@ export function actionDisconnect(nodeId, newNodeId) {
if (connection.index === 0 && way.isArea()) {
// replace shared node with shared node..
graph = graph.replace(way.replaceNode(way.nodes[0], newNode.id));
} else if (way.isClosed() && connection.index === way.nodes.length - 1) {
// replace closing node with new new node..
graph = graph.replace(way.unclose().addNode(newNode.id));
} else {
// replace shared node with multiple new nodes..
graph = graph.replace(way.updateNode(newNode.id, connection.index));
@@ -52,11 +55,11 @@ export function actionDisconnect(nodeId, newNodeId) {
return;
}
if (way.isArea() && (way.nodes[0] === nodeId)) {
candidates.push({wayID: way.id, index: 0});
candidates.push({ wayID: way.id, index: 0 });
} else {
way.nodes.forEach(function(waynode, index) {
if (waynode === nodeId) {
candidates.push({wayID: way.id, index: index});
candidates.push({ wayID: way.id, index: index });
}
});
}