mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-06 03:11:22 +00:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteWayAction.as
|
|
iD.actions.DeleteWay = function(wayId) {
|
|
function deleteNode(node, graph) {
|
|
return !graph.parentWays(node).length &&
|
|
!graph.parentRelations(node).length &&
|
|
!node.hasInterestingTags();
|
|
}
|
|
|
|
var action = function(graph) {
|
|
var way = graph.entity(wayId);
|
|
|
|
graph.parentRelations(way)
|
|
.forEach(function(parent) {
|
|
parent = parent.removeMembersWithID(wayId);
|
|
graph = graph.replace(parent);
|
|
|
|
if (parent.isDegenerate()) {
|
|
graph = iD.actions.DeleteRelation(parent.id)(graph);
|
|
}
|
|
});
|
|
|
|
_.uniq(way.nodes).forEach(function(nodeId) {
|
|
graph = graph.replace(way.removeNode(nodeId));
|
|
|
|
var node = graph.entity(nodeId);
|
|
if (deleteNode(node, graph)) {
|
|
graph = graph.remove(node);
|
|
}
|
|
});
|
|
|
|
return graph.remove(way);
|
|
};
|
|
|
|
action.disabled = function() {
|
|
return false;
|
|
};
|
|
|
|
return action;
|
|
};
|