From 8e6e860f87f9c2f0325247932c3e0daa8e416ac1 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 19 Feb 2013 18:06:18 -0500 Subject: [PATCH 1/4] Fix removing from tree --- js/id/core/tree.js | 4 ++-- test/spec/core/tree.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/id/core/tree.js b/js/id/core/tree.js index 94b28f12e..94b174230 100644 --- a/js/id/core/tree.js +++ b/js/id/core/tree.js @@ -12,8 +12,8 @@ iD.Tree = function(graph) { function extentRectangle(extent) { x = m * extent[0][0], y = m * extent[0][1], - dx = m * extent[1][0] - x || 1, - dy = m * extent[1][1] - y || 1; + dx = m * extent[1][0] - x || 2, + dy = m * extent[1][1] - y || 2; return new RTree.Rectangle(~~x, ~~y, ~~dx - 1, ~~dy - 1); } diff --git a/test/spec/core/tree.js b/test/spec/core/tree.js index 8cd4e55b6..1719f0d64 100644 --- a/test/spec/core/tree.js +++ b/test/spec/core/tree.js @@ -52,5 +52,13 @@ describe("iD.Tree", function() { var g = tree.graph().replace(n1).replace(n2); expect(tree.intersects(iD.geo.Extent([0, 0], [1.1, 1.1]), g)).to.eql([n1]); }); + + it("doesn't include removed entities", function() { + var n1 = iD.Node({ id: 'n1', loc: [1, 1]}); + var g = tree.graph().replace(n1); + expect(tree.intersects(iD.geo.Extent([0, 0], [2, 2]), g)).to.eql([n1]); + g = g.remove(n1); + expect(tree.intersects(iD.geo.Extent([0, 0], [2, 2]), g)).to.eql([]); + }); }); }); From 5a61ccade496484be65be6b031709c1aca6b637b Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 19 Feb 2013 18:11:32 -0500 Subject: [PATCH 2/4] Fix leaking global --- js/id/ui/inspector.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index 259cabcf6..8c13239cf 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -16,14 +16,13 @@ iD.ui.Inspector = function() { entity = selection.datum(); - var iwrap = selection - messagewrap = iwrap.append('div') + var messagewrap = selection.append('div') .attr('class', 'message inspector-inner fillL'), message = messagewrap.append('h3'); - inspectorbody = iwrap.append('div') + inspectorbody = selection.append('div') .attr('class', 'fillL'), - iwrap.append('div') + selection.append('div') .attr('class', 'inspector-actions pad1 col12') .call(drawButtons); @@ -57,7 +56,7 @@ iD.ui.Inspector = function() { inspectorbody.call(tagEditor); } - iwrap.call(iD.ui.Toggle(true)); + selection.call(iD.ui.Toggle(true)); } function drawButtons(selection) { From 85f39134b502c60169ab501bfadc2840769df8e8 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 19 Feb 2013 19:25:35 -0500 Subject: [PATCH 3/4] Add address ui element with street suggestions --- css/app.css | 17 ++++++++++++++++- index.html | 1 + js/id/geo.js | 4 ++++ js/id/ui/preset.js | 5 +++++ presets/presets.json | 4 ++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/css/app.css b/css/app.css index ec71f7ac5..9e874aa55 100644 --- a/css/app.css +++ b/css/app.css @@ -1586,4 +1586,19 @@ div.combobox { } @media only screen and (max-height: 840px) { -} \ No newline at end of file +} + +/* Address input */ + +.preset-input .addr-housename { + width: 300px; + display: block; +} + +.preset-input .addr-number { + width: 50px; +} + +.preset-input .addr-streetname { + width: 250px; +} diff --git a/index.html b/index.html index bb49d19ef..cdebb64ad 100644 --- a/index.html +++ b/index.html @@ -93,6 +93,7 @@ + diff --git a/js/id/geo.js b/js/id/geo.js index 682980758..f0c30d4a3 100644 --- a/js/id/geo.js +++ b/js/id/geo.js @@ -85,3 +85,7 @@ iD.geo.pathLength = function(path) { } return length; }; + +iD.geo.metresToCoordinates = function(loc, vector) { + return [vector[1] / 111200, vector[0] / 111200 / Math.cos(loc[1])]; +}; diff --git a/js/id/ui/preset.js b/js/id/ui/preset.js index 9c8e94f2c..9f61c0134 100644 --- a/js/id/ui/preset.js +++ b/js/id/ui/preset.js @@ -134,6 +134,11 @@ iD.ui.preset = function() { // Multiple elements, eg, address } else { if (d.type === 'address') { + wrap.append('div') + .attr('class', 'col8 preset-input', d) + .call(iD.ui.preset.address() + .context(context) + .entity(entity)); } } }); diff --git a/presets/presets.json b/presets/presets.json index af5c4828e..04a046f50 100644 --- a/presets/presets.json +++ b/presets/presets.json @@ -19,6 +19,10 @@ { "key": "cuisine", "type": "combo" + }, + { + "type": "address", + "title": "Address" } ] }, From cdec43359d46e0f14896a87e701307de3d5d6428 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 19 Feb 2013 19:33:04 -0500 Subject: [PATCH 4/4] Fix combobox mousedown and drag --- js/lib/d3.combobox.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/lib/d3.combobox.js b/js/lib/d3.combobox.js index 07b214746..815256045 100644 --- a/js/lib/d3.combobox.js +++ b/js/lib/d3.combobox.js @@ -226,6 +226,8 @@ d3.combobox = function() { } function mousedown() { + + input.node().focus(); update(''); var entries = container.selectAll('a'),