From 42b6f04a358434dcfc59925cc1a4475b977d3271 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 12 Nov 2012 18:55:33 -0500 Subject: [PATCH] Tune up road drawing --- js/iD/actions/actions.js | 15 +++++++++++---- js/iD/renderer/Map.js | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/js/iD/actions/actions.js b/js/iD/actions/actions.js index f0581130c..4a12dfb9d 100644 --- a/js/iD/actions/actions.js +++ b/js/iD/actions/actions.js @@ -99,6 +99,7 @@ iD.actions.AddRoad = { way.nodes.push(node.id); this.map.operate(iD.operations.changeWayNodes(way, node)); + this.map.selectClick(way); this.controller.go(iD.actions.DrawRoad(way)); }.bind(this)); @@ -119,8 +120,9 @@ iD.actions.DrawRoad = function(way) { return { enter: function() { var surface = this.map.surface; - this.nextnode = iD.actions._node([0, 0]); - way.nodes = [way.nodes[0], this.nextnode.id]; + var lastNode = this.map.history.graph().entity(way.nodes[way.nodes.length - 1]); + this.nextnode = iD.actions._node([lastNode.lon, lastNode.lat]); + way.nodes.push(this.nextnode.id); this.map.operate(iD.operations.changeWayNodes(way, this.nextnode)); surface.on('mousemove.drawroad', function() { var ll = this.map.projection.invert(d3.mouse(surface.node())); @@ -136,16 +138,21 @@ iD.actions.DrawRoad = function(way) { way.nodes.push(node.id); this.map.operate(iD.operations.changeWayNodes(way, node)); way.nodes = way.nodes.slice(); - way.nodes.push(this.falsenode.id); + way.nodes.push(this.nextnode.id); + this.controller.go(iD.actions.DrawRoad(way)); }.bind(this)); surface.on('dblclick.drawroad', function() { d3.event.stopPropagation(); + var a = this.map.history.graph().entity(way.nodes.pop()); + var b = this.map.history.graph().entity(way.nodes.pop()); + this.map.operate(iD.operations.changeWayNodes(way, a)); + this.map.operate(iD.operations.remove(a)); + this.map.operate(iD.operations.remove(b)); this.exit(); }.bind(this)); }, exit: function() { - this.map.operate(iD.operations.addTemporary(this.falsenode)); this.map.surface.on('mousemove.drawroad', null); this.map.surface.on('click.drawroad', null); d3.select(document).on('.drawroad', null); diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index 710c2f8f3..eafe50c90 100755 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -215,6 +215,7 @@ iD.Map = function(elem) { } function selectClick(d) { + if (selection[0] === d.id) return; selection = [d.id]; drawVector(); d3.select('.inspector-wrap')