From 4f70731dfb7104e297b1f0481cb6a15260d283ae Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sat, 31 May 2014 03:23:31 -0400 Subject: [PATCH] Only render oneway markers that actually appear in the viewport (motorways and rivers used to fill the DOM tree with a lot of crap!) --- js/id/svg.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/id/svg.js b/js/id/svg.js index fc848e5de..3bba099bf 100644 --- a/js/id/svg.js +++ b/js/id/svg.js @@ -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),