Only render oneway markers that actually appear in the viewport

(motorways and rivers used to fill the DOM tree with a lot of crap!)
This commit is contained in:
Bryan Housel
2014-05-31 03:23:31 -04:00
parent 3e138bf16b
commit 4f70731dfb
+4 -2
View File
@@ -43,6 +43,7 @@ iD.svg = {
i = 0,
offset = dt,
segments = [],
viewport = iD.geo.Extent(projection.clipExtent()),
coordinates = graph.childNodes(entity).map(function(n) {
return n.loc;
});
@@ -61,9 +62,10 @@ iD.svg = {
b = [x, y];
if (a) {
var span = iD.geo.euclideanDistance(a, b) - offset;
var extent = iD.geo.Extent(a).extend(b),
span = iD.geo.euclideanDistance(a, b) - offset;
if (span >= 0) {
if (extent.intersects(viewport) && span >= 0) {
var angle = Math.atan2(b[1] - a[1], b[0] - a[0]),
dx = dt * Math.cos(angle),
dy = dt * Math.sin(angle),