mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-19 23:14:47 +02:00
Fix adding to ways in the reverse direction
This commit is contained in:
@@ -4,7 +4,7 @@ iD.actions.AddWayNode = function(wayId, nodeId, index) {
|
||||
var way = graph.entity(wayId),
|
||||
node = graph.entity(nodeId),
|
||||
nodes = way.nodes.slice();
|
||||
nodes.splice(index || nodes.length, 0, nodeId);
|
||||
nodes.splice((index === undefined) ? nodes.length : index, 0, nodeId);
|
||||
return graph.replace(way.update({nodes: nodes}));
|
||||
};
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ iD.modes.AddRoad = function() {
|
||||
|
||||
mode.enter = function() {
|
||||
var map = mode.map,
|
||||
node,
|
||||
history = mode.history,
|
||||
controller = mode.controller;
|
||||
|
||||
@@ -37,7 +38,7 @@ iD.modes.AddRoad = function() {
|
||||
|
||||
} else if (datum.type === 'way') {
|
||||
// begin a new way starting from an existing way
|
||||
var node = iD.Node({loc: map.mouseCoordinates()}),
|
||||
node = iD.Node({loc: map.mouseCoordinates()}),
|
||||
index = iD.util.geo.chooseIndex(datum, d3.mouse(map.surface.node()), map);
|
||||
|
||||
history.perform(
|
||||
@@ -48,7 +49,7 @@ iD.modes.AddRoad = function() {
|
||||
|
||||
} else {
|
||||
// begin a new way
|
||||
var node = iD.Node({loc: map.mouseCoordinates()});
|
||||
node = iD.Node({loc: map.mouseCoordinates()});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddWay(way),
|
||||
|
||||
@@ -9,7 +9,7 @@ iD.modes.DrawRoad = function(wayId, direction) {
|
||||
controller = mode.controller,
|
||||
way = history.graph().entity(wayId),
|
||||
node = iD.Node({loc: map.mouseCoordinates()}),
|
||||
index = (direction === 'forward') ? undefined : -1,
|
||||
index = (direction === 'forward') ? undefined : 0,
|
||||
headId = (direction === 'forward') ? _.last(way.nodes) : _.first(way.nodes),
|
||||
tailId = (direction === 'forward') ? _.first(way.nodes) : _.last(way.nodes);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user