mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 13:59:27 +02:00
Handle incomplete relations in SplitWay (fixes #466)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user