From f00ad5b169448417c8e26aa1d8e2d4f42d191c46 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Tue, 6 Nov 2012 17:22:46 -0500 Subject: [PATCH] Fix dragging ways, add way method to connection --- index.html | 2 +- js/iD/Connection.js | 14 +++++++++++--- js/iD/graph/Graph.js | 4 ++-- js/iD/renderer/Map.js | 6 +++--- js/iD/ui/Inspector.js | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index de35df4d1..e83b5cb60 100755 --- a/index.html +++ b/index.html @@ -111,7 +111,7 @@ d3.select('#redo').on('click', map.redo); d3.select(document).on('keydown', function() { - console.log(d3.event); + // console.log(d3.event); // cmd-z if (d3.event.which === 90 && d3.event.metaKey) { map.undo(); diff --git a/js/iD/Connection.js b/js/iD/Connection.js index fb28c2d3f..a37be63b0 100755 --- a/js/iD/Connection.js +++ b/js/iD/Connection.js @@ -4,11 +4,16 @@ iD.Connection = function(graph) { var connection = {}; // Request data within the bbox from an external OSM server. - function loadFromAPI(box, callback) { + function bboxFromAPI(box, callback) { loadFromURL(apiURL + 'map?bbox=' + [box[0][0], box[1][1], box[1][0], box[0][1]], callback); } + // Request data within the bbox from an external OSM server. + function wayFromAPI(id, callback) { + loadFromURL(apiURL + 'way/' + id + '/full', callback); + } + function loadFromURL(url, callback) { d3.xml(url, parse(callback)); } @@ -87,9 +92,12 @@ iD.Connection = function(graph) { } connection.graph = graph; - connection.loadFromAPI = loadFromAPI; - connection.objectData = objectData; + + connection.bboxFromAPI = bboxFromAPI; + connection.wayFromAPI = wayFromAPI; connection.loadFromURL = loadFromURL; + + connection.objectData = objectData; connection.apiURL = apiURL; return connection; diff --git a/js/iD/graph/Graph.js b/js/iD/graph/Graph.js index 31d9d6c79..54dada92b 100644 --- a/js/iD/graph/Graph.js +++ b/js/iD/graph/Graph.js @@ -4,12 +4,12 @@ iD.Graph.prototype = { // a pointer to the top of the stack. head: {}, + // a pointer to the latest annotation annotation: null, // stack of previous versions of this datastructure prev: [], - - // messages + // stack of previous annotations annotations: [], // get all points that are not part of a way. this is an expensive diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index a5d70d9da..d741a40d8 100755 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -38,7 +38,7 @@ iD.Map = function(elem) { // this is used with handles dragbehavior = d3.behavior.drag() .origin(function(d) { - var data = (typeof d === 'number') ? graph.head[d] : d; + var data = (typeof d === 'string') ? graph.head[d] : d; graph.modify(function(o) { var c = {}; c[data.id] = pdata.object(data).set({ modified: true }).get(); @@ -57,7 +57,7 @@ iD.Map = function(elem) { drawVector(); }) .on('dragend', function(d) { - var data = (typeof d === 'number') ? graph.head[d] : d; + var data = (typeof d === 'string') ? graph.head[d] : d; graph.modify(function(o) { var c = {}; c[data.id] = pdata.object(c[data.id]).get(); @@ -205,7 +205,7 @@ iD.Map = function(elem) { } var download = _.debounce(function() { - connection.loadFromAPI(getExtent(), drawVector); + connection.bboxFromAPI(getExtent(), drawVector); }, 1000); function deselectClick() { diff --git a/js/iD/ui/Inspector.js b/js/iD/ui/Inspector.js index 889656a1b..43d45e69e 100644 --- a/js/iD/ui/Inspector.js +++ b/js/iD/ui/Inspector.js @@ -17,7 +17,7 @@ iD.Inspector = function(graph) { head.append('a') .attr('class', 'permalink') .attr('href', 'http://www.openstreetmap.org/browse/' + - d.type + '/' + d.id) + d.type + '/' + d.id.slice(1)) .text('OSM'); head.append('a')