mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 17:52:55 +00:00
Prevent a closed way from disconnecting itself..
This commit is contained in:
@@ -20,9 +20,10 @@ iD.actions.Disconnect = function(nodeId, newNodeId) {
|
||||
replacements = action.replacements(graph);
|
||||
|
||||
replacements.forEach(function(replacement) {
|
||||
var newNode = iD.Node({id: newNodeId, loc: node.loc, tags: node.tags});
|
||||
var way = graph.entity(replacement.wayID),
|
||||
newNode = iD.Node({id: newNodeId, loc: node.loc, tags: node.tags});
|
||||
graph = graph.replace(newNode);
|
||||
graph = graph.replace(graph.entity(replacement.wayID).updateNode(newNode.id, replacement.index));
|
||||
graph = graph.replace(way.replaceNode(way.nodes[replacement.index], newNode.id));
|
||||
});
|
||||
|
||||
return graph;
|
||||
@@ -31,21 +32,22 @@ iD.actions.Disconnect = function(nodeId, newNodeId) {
|
||||
action.replacements = function(graph) {
|
||||
var candidates = [],
|
||||
keeping = false,
|
||||
parents = graph.parentWays(graph.entity(nodeId));
|
||||
parentWays = graph.parentWays(graph.entity(nodeId));
|
||||
|
||||
parents.forEach(function(parent) {
|
||||
if (wayIds && wayIds.indexOf(parent.id) === -1) {
|
||||
parentWays.forEach(function(way) {
|
||||
if (wayIds && wayIds.indexOf(way.id) === -1) {
|
||||
keeping = true;
|
||||
return;
|
||||
}
|
||||
|
||||
parent.nodes.forEach(function(waynode, index) {
|
||||
way.nodes.forEach(function(waynode, index) {
|
||||
if (waynode === nodeId) {
|
||||
candidates.push({wayID: parent.id, index: index});
|
||||
candidates.push({wayID: way.id, index: index});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
candidates = _.uniq(candidates, function(item) { return item.wayID; } );
|
||||
return keeping ? candidates : candidates.slice(1);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user