mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 01:33:03 +00:00
18 lines
664 B
JavaScript
18 lines
664 B
JavaScript
iD.actions.RemoveWayNode = function(wayId, nodeId) {
|
|
return function(graph) {
|
|
var way = graph.entity(wayId), nodes;
|
|
// If this is the connecting node in a closed area
|
|
if (way.nodes.length > 1 &&
|
|
_.indexOf(way.nodes, nodeId) === 0 &&
|
|
_.lastIndexOf(way.nodes, nodeId) === way.nodes.length - 1) {
|
|
// Remove the node
|
|
nodes = _.without(way.nodes, nodeId);
|
|
// And reclose the way on the new first node.
|
|
nodes.push(nodes[0]);
|
|
} else {
|
|
nodes = _.without(way.nodes, nodeId);
|
|
}
|
|
return graph.replace(way.update({nodes: nodes}));
|
|
};
|
|
};
|