mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-12 14:16:14 +00:00
They're something distinct from actions. Actions are independent of UI, operations are actions + UI (title, keybinding, modality, etc.)
31 lines
995 B
JavaScript
31 lines
995 B
JavaScript
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteWayAction.as
|
|
iD.actions.DeleteWay = function(wayId) {
|
|
return function(graph) {
|
|
var way = graph.entity(wayId);
|
|
|
|
graph.parentRelations(way)
|
|
.forEach(function(parent) {
|
|
graph = graph.replace(parent.removeMember(wayId));
|
|
});
|
|
|
|
way.nodes.forEach(function (nodeId) {
|
|
var node = graph.entity(nodeId);
|
|
|
|
// Circular ways include nodes more than once, so they
|
|
// can be deleted on earlier iterations of this loop.
|
|
if (!node) return;
|
|
|
|
graph = graph.replace(way.removeNode(nodeId));
|
|
|
|
if (!graph.parentWays(node).length &&
|
|
!graph.parentRelations(node).length) {
|
|
if (!node.hasInterestingTags()) {
|
|
graph = graph.remove(node);
|
|
}
|
|
}
|
|
});
|
|
|
|
return graph.remove(way);
|
|
};
|
|
};
|