From bb6c0489a004f2b62379c0f81831fc8fb3c6c753 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 7 Dec 2012 12:01:48 -0500 Subject: [PATCH] Fix adding to ways in the reverse direction --- js/id/actions/add_way_node.js | 2 +- js/id/modes/add_road.js | 5 +++-- js/id/modes/draw_road.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/id/actions/add_way_node.js b/js/id/actions/add_way_node.js index 69361b8dc..d685c3295 100644 --- a/js/id/actions/add_way_node.js +++ b/js/id/actions/add_way_node.js @@ -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})); }; }; diff --git a/js/id/modes/add_road.js b/js/id/modes/add_road.js index 5f05c3f77..d3e57b066 100644 --- a/js/id/modes/add_road.js +++ b/js/id/modes/add_road.js @@ -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), diff --git a/js/id/modes/draw_road.js b/js/id/modes/draw_road.js index a09a69368..56058e017 100644 --- a/js/id/modes/draw_road.js +++ b/js/id/modes/draw_road.js @@ -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);