mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-24 09:04:02 +02:00
Always use rounded projection
This commit is contained in:
+11
-10
@@ -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() {
|
||||
|
||||
@@ -6,7 +6,6 @@ iD.svg = {
|
||||
},
|
||||
|
||||
PointTransform: function (projection) {
|
||||
projection = iD.svg.RoundProjection(projection);
|
||||
return function (entity) {
|
||||
return 'translate(' + projection(entity.loc) + ')';
|
||||
};
|
||||
|
||||
+3
-3
@@ -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) {
|
||||
|
||||
+3
-3
@@ -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'),
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
+2
-2
@@ -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++) {
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user