Fix Disconnect of way with multiple intersections (fixes #1955)

This commit is contained in:
John Firebaugh
2013-11-14 15:48:07 -08:00
parent b383bfec1f
commit 3f99e2fd4b
2 changed files with 26 additions and 2 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ iD.actions.Disconnect = function(nodeId, newNodeId) {
replacements.forEach(function(replacement) {
var newNode = iD.Node({id: newNodeId, loc: node.loc, tags: node.tags});
graph = graph.replace(newNode);
graph = graph.replace(replacement.way.updateNode(newNode.id, replacement.index));
graph = graph.replace(graph.entity(replacement.wayID).updateNode(newNode.id, replacement.index));
});
return graph;
@@ -41,7 +41,7 @@ iD.actions.Disconnect = function(nodeId, newNodeId) {
parent.nodes.forEach(function(waynode, index) {
if (waynode === nodeId) {
candidates.push({way: parent, index: index});
candidates.push({wayID: parent.id, index: index});
}
});
});
+24
View File
@@ -128,6 +128,30 @@ describe("iD.actions.Disconnect", function () {
expect(graph.entity('w').nodes).to.eql(['a', 'b', 'c', 'd']);
});
it("disconnects a way with multiple intersection points", function() {
// Situtation:
// a = b - c
// | |
// e - d
// Where b starts/ends -.
// Disconnect at b
var graph = iD.Graph([
iD.Node({id: 'a'}),
iD.Node({id: 'b'}),
iD.Node({id: 'c'}),
iD.Node({id: 'd'}),
iD.Node({id: 'e'}),
iD.Way({id: 'w1', nodes: ['a', 'b']}),
iD.Way({id: 'w2', nodes: ['b', 'c', 'd', 'e', 'b']})
]);
graph = iD.actions.Disconnect('b', '*')(graph);
expect(graph.entity('w1').nodes).to.eql(['a', 'b']);
expect(graph.entity('w2').nodes).to.eql(['*', 'c', 'd', 'e', '*']);
});
it("copies location and tags to the new nodes", function () {
var tags = {highway: 'traffic_signals'},
loc = [1, 2],