Fix adding to ways in the reverse direction

This commit is contained in:
Tom MacWright
2012-12-07 12:01:48 -05:00
parent 9546a6f743
commit bb6c0489a0
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -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}));
};
};
+3 -2
View File
@@ -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),
+1 -1
View File
@@ -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);