diff --git a/js/id/connection.js b/js/id/connection.js index 101c7a9c8..531d89d54 100644 --- a/js/id/connection.js +++ b/js/id/connection.js @@ -16,6 +16,7 @@ iD.Connection = function() { function bboxFromAPI(box, tile, callback) { function done(err, parsed) { loadedTiles[tile.toString()] = true; + delete inflight[tile.toString()]; callback(err, parsed); } inflight[tile.toString()] = loadFromURL(bboxUrl(box), done); diff --git a/js/id/graph/graph.js b/js/id/graph/graph.js index d1f5e4cc7..9b6de7219 100644 --- a/js/id/graph/graph.js +++ b/js/id/graph/graph.js @@ -128,11 +128,19 @@ iD.Graph.prototype = { }, difference: function (graph) { - var result = [], entity, id; + var result = [], entity, oldentity, id; for (id in this.entities) { entity = this.entities[id]; - if (entity !== graph.entities[id]) { + oldentity = graph.entities[id]; + if (entity !== oldentity) { + if (entity && entity.type === 'way') { + result = oldentity + ? result + .concat(_.difference(entity.nodes, oldentity.nodes)) + .concat(_.difference(oldentity.nodes, entity.nodes)) + : result.concat(entity.nodes); + } result.push(id); } } @@ -141,6 +149,7 @@ iD.Graph.prototype = { entity = graph.entities[id]; if (entity && !this.entities.hasOwnProperty(id)) { result.push(id); + if (entity.type === 'way') result = result.concat(entity.nodes); } } diff --git a/js/id/modes/add_area.js b/js/id/modes/add_area.js index 33facb041..6977f2e15 100644 --- a/js/id/modes/add_area.js +++ b/js/id/modes/add_area.js @@ -23,8 +23,7 @@ iD.modes.AddArea = function() { history.perform( iD.actions.AddWay(way), iD.actions.AddWayNode(way.id, datum.id), - iD.actions.AddWayNode(way.id, datum.id), - 'started an area'); + iD.actions.AddWayNode(way.id, datum.id)); } else { // start from a new node @@ -33,8 +32,7 @@ iD.modes.AddArea = function() { iD.actions.AddWay(way), iD.actions.AddNode(node), iD.actions.AddWayNode(way.id, node.id), - iD.actions.AddWayNode(way.id, node.id), - 'started an area'); + iD.actions.AddWayNode(way.id, node.id)); } controller.enter(iD.modes.DrawArea(way.id)); diff --git a/js/id/modes/add_line.js b/js/id/modes/add_line.js index bc87238ca..60f376181 100644 --- a/js/id/modes/add_line.js +++ b/js/id/modes/add_line.js @@ -33,8 +33,7 @@ iD.modes.AddLine = function() { } else { history.perform( iD.actions.AddWay(way), - iD.actions.AddWayNode(way.id, datum.id), - 'started a line'); + iD.actions.AddWayNode(way.id, datum.id)); } } else if (datum.type === 'way') { @@ -46,8 +45,7 @@ iD.modes.AddLine = function() { iD.actions.AddWay(way), iD.actions.AddNode(node), iD.actions.AddWayNode(datum.id, node.id, choice.index), - iD.actions.AddWayNode(way.id, node.id), - 'started a line'); + iD.actions.AddWayNode(way.id, node.id)); } else { // begin a new way @@ -56,8 +54,7 @@ iD.modes.AddLine = function() { history.perform( iD.actions.AddWay(way), iD.actions.AddNode(node), - iD.actions.AddWayNode(way.id, node.id), - 'started a line'); + iD.actions.AddWayNode(way.id, node.id)); } controller.enter(iD.modes.DrawLine(way.id, direction)); diff --git a/js/id/modes/draw_area.js b/js/id/modes/draw_area.js index d868a7620..75b84af65 100644 --- a/js/id/modes/draw_area.js +++ b/js/id/modes/draw_area.js @@ -42,22 +42,28 @@ iD.modes.DrawArea = function(wayId) { var datum = d3.select(d3.event.target).datum() || {}; if (datum.id === tailId || datum.id === headId) { - history.replace(iD.actions.DeleteNode(node.id)); - controller.enter(iD.modes.Select(way)); + if (way.nodes.length > 3) { + history.replace(iD.actions.DeleteNode(node.id)); + controller.enter(iD.modes.Select(way)); + } else { + // Areas with less than 3 nodes gets deleted + history.replace(iD.actions.DeleteWay(way.id)); + controller.enter(iD.modes.Browse()); + } } else if (datum.type === 'node' && datum.id !== node.id) { // connect the way to an existing node history.replace( iD.actions.DeleteNode(node.id), iD.actions.AddWayNode(way.id, datum.id, -1), - 'added to an area'); + way.nodes.length > 2 ? 'added to an area' : ''); controller.enter(iD.modes.DrawArea(wayId)); } else { history.replace( iD.actions.Noop(), - 'added to an area'); + way.nodes.length > 2 ? 'added to an area' : ''); controller.enter(iD.modes.DrawArea(wayId)); } diff --git a/js/id/modes/draw_line.js b/js/id/modes/draw_line.js index 9c3d4b38e..700944b18 100644 --- a/js/id/modes/draw_line.js +++ b/js/id/modes/draw_line.js @@ -42,12 +42,18 @@ iD.modes.DrawLine = function(wayId, direction) { if (datum.id === tailId) { // connect the way in a loop - history.replace( - iD.actions.DeleteNode(node.id), - iD.actions.AddWayNode(wayId, tailId, index), - 'added to a line'); + if (way.nodes.length > 2) { + history.replace( + iD.actions.DeleteNode(node.id), + iD.actions.AddWayNode(wayId, tailId, index), + 'added to a line'); - controller.enter(iD.modes.Select(way)); + controller.enter(iD.modes.Select(way)); + + } else { + history.replace(iD.actions.DeleteWay(way.id)); + controller.enter(iD.modes.Browse()); + } } else if (datum.id === headId) { // finish the way