From 9f1506af5e755b755231b6f3e8799b3fd475b315 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 17 Jan 2013 09:48:21 -0800 Subject: [PATCH] Always use rounded projection --- js/id/renderer/map.js | 21 +++++++++++---------- js/id/svg.js | 1 - js/id/svg/areas.js | 6 +++--- js/id/svg/lines.js | 6 +++--- js/id/svg/midpoints.js | 4 ++-- js/id/svg/points.js | 4 ++-- js/id/svg/vertices.js | 4 ++-- test/spec/svg/areas.js | 2 +- test/spec/svg/points.js | 2 +- test/spec/svg/vertices.js | 4 ++-- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 9edb347e4..467f7f351 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -5,6 +5,7 @@ iD.Map = function() { translateStart, keybinding = d3.keybinding(), projection = d3.geo.mercator().scale(1024), + roundedProjection = iD.svg.RoundProjection(projection), zoom = d3.behavior.zoom() .translate(projection.translate()) .scale(projection.scale()) @@ -16,11 +17,11 @@ iD.Map = function() { background = iD.Background() .projection(projection), transformProp = iD.util.prefixCSSProperty('Transform'), - points = iD.svg.Points(), - vertices = iD.svg.Vertices(), - lines = iD.svg.Lines(), - areas = iD.svg.Areas(), - midpoints = iD.svg.Midpoints(), + points = iD.svg.Points(roundedProjection), + vertices = iD.svg.Vertices(roundedProjection), + lines = iD.svg.Lines(roundedProjection), + areas = iD.svg.Areas(roundedProjection), + midpoints = iD.svg.Midpoints(roundedProjection), tail = d3.tail(), surface, tilegroup; @@ -97,11 +98,11 @@ iD.Map = function() { } surface - .call(points, graph, all, filter, projection) - .call(vertices, graph, all, filter, projection) - .call(lines, graph, all, filter, projection) - .call(areas, graph, all, filter, projection) - .call(midpoints, graph, all, filter, projection); + .call(points, graph, all, filter) + .call(vertices, graph, all, filter) + .call(lines, graph, all, filter) + .call(areas, graph, all, filter) + .call(midpoints, graph, all, filter); } function editOff() { diff --git a/js/id/svg.js b/js/id/svg.js index 5860126e9..e1d26e058 100644 --- a/js/id/svg.js +++ b/js/id/svg.js @@ -6,7 +6,6 @@ iD.svg = { }, PointTransform: function (projection) { - projection = iD.svg.RoundProjection(projection); return function (entity) { return 'translate(' + projection(entity.loc) + ')'; }; diff --git a/js/id/svg/areas.js b/js/id/svg/areas.js index ff24afecc..4fe06ba92 100644 --- a/js/id/svg/areas.js +++ b/js/id/svg/areas.js @@ -1,4 +1,4 @@ -iD.svg.Areas = function() { +iD.svg.Areas = function(projection) { var area_stack = { building: 0, @@ -26,7 +26,7 @@ iD.svg.Areas = function() { return as - bs; } - return function drawAreas(surface, graph, entities, filter, projection) { + return function drawAreas(surface, graph, entities, filter) { var areas = []; for (var i = 0; i < entities.length; i++) { @@ -47,7 +47,7 @@ iD.svg.Areas = function() { var nodes = _.pluck(entity.nodes, 'loc'); if (nodes.length === 0) return (lineStrings[entity.id] = ''); else return (lineStrings[entity.id] = - 'M' + nodes.map(iD.svg.RoundProjection(projection)).join('L')); + 'M' + nodes.map(projection).join('L')); } function drawPaths(group, areas, filter, classes) { diff --git a/js/id/svg/lines.js b/js/id/svg/lines.js index 3f1b634d7..4a2acfe38 100644 --- a/js/id/svg/lines.js +++ b/js/id/svg/lines.js @@ -1,4 +1,4 @@ -iD.svg.Lines = function() { +iD.svg.Lines = function(projection) { var arrowtext = '►\u3000\u3000', alength; @@ -53,7 +53,7 @@ iD.svg.Lines = function() { return paths; } - return function drawLines(surface, graph, entities, filter, projection) { + return function drawLines(surface, graph, entities, filter) { if (!alength) { var arrow = surface.append('text').text(arrowtext); @@ -80,7 +80,7 @@ iD.svg.Lines = function() { var nodes = _.pluck(entity.nodes, 'loc'); if (nodes.length === 0) return (lineStrings[entity.id] = ''); else return (lineStrings[entity.id] = - 'M' + nodes.map(iD.svg.RoundProjection(projection)).join('L')); + 'M' + nodes.map(projection).join('L')); } var casing = surface.select('.layer-casing'), diff --git a/js/id/svg/midpoints.js b/js/id/svg/midpoints.js index 9c060ea3b..321e75c8e 100644 --- a/js/id/svg/midpoints.js +++ b/js/id/svg/midpoints.js @@ -1,5 +1,5 @@ -iD.svg.Midpoints = function() { - return function drawMidpoints(surface, graph, entities, filter, projection) { +iD.svg.Midpoints = function(projection) { + return function drawMidpoints(surface, graph, entities, filter) { var midpoints = []; for (var i = 0; i < entities.length; i++) { diff --git a/js/id/svg/points.js b/js/id/svg/points.js index 7a2600814..37c4bbf91 100644 --- a/js/id/svg/points.js +++ b/js/id/svg/points.js @@ -1,4 +1,4 @@ -iD.svg.Points = function() { +iD.svg.Points = function(projection) { function imageHref(d) { // TODO: optimize for (var k in d.tags) { @@ -10,7 +10,7 @@ iD.svg.Points = function() { return 'icons/unknown.png'; } - return function drawPoints(surface, graph, entities, filter, projection) { + return function drawPoints(surface, graph, entities, filter) { var points = []; for (var i = 0; i < entities.length; i++) { diff --git a/js/id/svg/vertices.js b/js/id/svg/vertices.js index 700ef5538..ff775fa3e 100644 --- a/js/id/svg/vertices.js +++ b/js/id/svg/vertices.js @@ -1,5 +1,5 @@ -iD.svg.Vertices = function() { - return function drawVertices(surface, graph, entities, filter, projection) { +iD.svg.Vertices = function(projection) { + return function drawVertices(surface, graph, entities, filter) { var vertices = []; for (var i = 0; i < entities.length; i++) { diff --git a/test/spec/svg/areas.js b/test/spec/svg/areas.js index 54a7c1d35..5e910dbfc 100644 --- a/test/spec/svg/areas.js +++ b/test/spec/svg/areas.js @@ -12,7 +12,7 @@ describe("iD.svg.Areas", function () { var area = iD.Way({tags: {area: 'yes', building: 'yes'}}), graph = iD.Graph([area]); - surface.call(iD.svg.Areas(), graph, [area], filter, projection); + surface.call(iD.svg.Areas(projection), graph, [area], filter); expect(surface.select('.area')).to.be.classed('tag-building'); expect(surface.select('.area')).to.be.classed('tag-building-yes'); diff --git a/test/spec/svg/points.js b/test/spec/svg/points.js index 664f88a80..be06ae487 100644 --- a/test/spec/svg/points.js +++ b/test/spec/svg/points.js @@ -12,7 +12,7 @@ describe("iD.svg.Points", function () { var node = iD.Node({tags: {amenity: "cafe"}, loc: [0, 0], _poi: true}), graph = iD.Graph([node]); - surface.call(iD.svg.Points(), graph, [node], filter, projection); + surface.call(iD.svg.Points(projection), graph, [node], filter); expect(surface.select('.point')).to.be.classed('tag-amenity'); expect(surface.select('.point')).to.be.classed('tag-amenity-cafe'); diff --git a/test/spec/svg/vertices.js b/test/spec/svg/vertices.js index 760734053..dccdf80a0 100644 --- a/test/spec/svg/vertices.js +++ b/test/spec/svg/vertices.js @@ -12,7 +12,7 @@ describe("iD.svg.Vertices", function () { var node = iD.Node({tags: {highway: "traffic_signals"}, loc: [0, 0]}), graph = iD.Graph([node]); - surface.call(iD.svg.Vertices(), graph, [node], filter, projection); + surface.call(iD.svg.Vertices(projection), graph, [node], filter); expect(surface.select('.vertex')).to.be.classed('tag-highway'); expect(surface.select('.vertex')).to.be.classed('tag-highway-traffic_signals'); @@ -24,7 +24,7 @@ describe("iD.svg.Vertices", function () { way2 = iD.Way({nodes: [node.id]}), graph = iD.Graph([node, way1, way2]); - surface.call(iD.svg.Vertices(), graph, [node], filter, projection); + surface.call(iD.svg.Vertices(projection), graph, [node], filter); expect(surface.select('.vertex')).to.be.classed('shared'); });