Handle incomplete relations in SplitWay (fixes #466)

This commit is contained in:
John Firebaugh
2013-01-23 15:52:35 -05:00
parent 72618574f3
commit 3138ba2805
2 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -47,7 +47,8 @@ iD.actions.SplitWay = function(nodeId, newWayId) {
j;
for (j = 0; j < relation.members.length; j++) {
if (relation.members[j].type === 'way' && graph.entity(relation.members[j].id).contains(last)) {
var entity = graph.entity(relation.members[j].id);
if (entity && entity.type === 'way' && entity.contains(last)) {
break;
}
}
+14
View File
@@ -175,6 +175,20 @@ describe("iD.actions.SplitWay", function () {
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['~', '=', '-']);
});
it("handles incomplete relations", function () {
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
'b': iD.Node({id: 'b'}),
'c': iD.Node({id: 'c'}),
'-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}),
'r': iD.Relation({id: 'r', members: [{id: '~', type: 'way'}, {id: '-', type: 'way'}]})
});
graph = iD.actions.SplitWay('b', '=')(graph);
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['~', '-', '=']);
});
['restriction', 'restriction:bus'].forEach(function (type) {
it("updates a restriction's 'from' role", function () {
// Situation: