Draw only visible midpoints (#804)

This commit is contained in:
John Firebaugh
2013-02-17 11:06:36 -08:00
parent 9fcda7ffc2
commit e154a94ef0
2 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ iD.Map = function(context) {
.call(vertices, graph, all, filter)
.call(lines, graph, all, filter)
.call(areas, graph, all, filter)
.call(midpoints, graph, all, filter)
.call(midpoints, graph, all, filter, extent)
.call(labels, graph, all, filter, dimensions, !difference);
}
dispatch.drawn(map);
+11 -8
View File
@@ -1,5 +1,5 @@
iD.svg.Midpoints = function(projection) {
return function drawMidpoints(surface, graph, entities, filter) {
return function drawMidpoints(surface, graph, entities, filter, extent) {
var midpoints = {};
if (!surface.select('.layer-hit g.vertex').node()) {
@@ -22,13 +22,16 @@ iD.svg.Midpoints = function(projection) {
if (midpoints[id]) {
midpoints[id].ways.push({id: entity.id, index: j + 1});
} else if (iD.geo.dist(projection(a.loc), projection(b.loc)) > 40) {
midpoints[id] = {
type: 'midpoint',
id: id,
loc: iD.geo.interp(a.loc, b.loc, 0.5),
ways: [{id: entity.id, index: j + 1}]
};
} else {
var loc = iD.geo.interp(a.loc, b.loc, 0.5);
if (extent.intersects(loc) && iD.geo.dist(projection(a.loc), projection(b.loc)) > 40) {
midpoints[id] = {
type: 'midpoint',
id: id,
loc: loc,
ways: [{id: entity.id, index: j + 1}]
};
}
}
}
}