mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-19 09:33:32 +00:00
Due to differenced redraw, midpoint.ways was getting stale, so sometimes dragging a midpoint didn't add the new node to all ways. Better to calculate participating ways when needed. This also simplifies the code for adding a midpoint via double click. It does make filtering midpoints on redraw a bit more expensive, but a cursory profile didn't show it being a problem. Fixes #763.
23 lines
819 B
JavaScript
23 lines
819 B
JavaScript
iD.actions.AddMidpoint = function(midpoint, node) {
|
|
return function(graph) {
|
|
graph = graph.replace(node.move(midpoint.loc));
|
|
|
|
var parents = _.intersection(
|
|
graph.parentWays(graph.entity(midpoint.edge[0])),
|
|
graph.parentWays(graph.entity(midpoint.edge[1])));
|
|
|
|
parents.forEach(function(way) {
|
|
for (var i = 0; i < way.nodes.length - 1; i++) {
|
|
if ((way.nodes[i] === midpoint.edge[0] &&
|
|
way.nodes[i + 1] === midpoint.edge[1]) ||
|
|
(way.nodes[i] === midpoint.edge[1] &&
|
|
way.nodes[i + 1] === midpoint.edge[0])) {
|
|
graph = graph.replace(graph.entity(way.id).addNode(node.id, i + 1));
|
|
}
|
|
}
|
|
});
|
|
|
|
return graph;
|
|
};
|
|
};
|