From 2d987a3ece6113a3f6cbbeb1dbc8944519ce855c Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sat, 9 Apr 2016 23:04:02 -0400 Subject: [PATCH] Don't fetch overlay tiles or mapillary data around Null Island (closes #2751) --- js/id/renderer/tile_layer.js | 16 ++++++++++++++++ js/id/services/mapillary.js | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/js/id/renderer/tile_layer.js b/js/id/renderer/tile_layer.js index d0e0e8a33..11863e450 100644 --- a/js/id/renderer/tile_layer.js +++ b/js/id/renderer/tile_layer.js @@ -8,6 +8,19 @@ iD.TileLayer = function() { transformProp = iD.util.prefixCSSProperty('Transform'), source = d3.functor(''); + + // blacklist overlay tiles around Null Island.. + function nearNullIsland(x, y, z) { + if (z >= 7) { + var center = Math.pow(2, z - 1), + width = Math.pow(2, z - 6), + min = center - (width / 2), + max = center + (width / 2) - 1; + return x >= min && x <= max && y >= min && y <= max; + } + return false; + } + function tileSizeAtZoom(d, z) { var epsilon = 0.002; return ((tileSize * Math.pow(2, z - d[2])) / tileSize) + epsilon; @@ -78,6 +91,9 @@ iD.TileLayer = function() { }); requests = uniqueBy(requests, 3).filter(function(r) { + if (!!source.overlay && nearNullIsland(r[0], r[1], r[2])) { + return false; + } // don't re-request tiles which have failed in the past return cache[r[3]] !== false; }); diff --git a/js/id/services/mapillary.js b/js/id/services/mapillary.js index 87d96af94..231d2a943 100644 --- a/js/id/services/mapillary.js +++ b/js/id/services/mapillary.js @@ -36,6 +36,17 @@ iD.services.mapillary = function() { i.abort(); } + function nearNullIsland(x, y, z) { + if (z >= 7) { + var center = Math.pow(2, z - 1), + width = Math.pow(2, z - 6), + min = center - (width / 2), + max = center + (width / 2) - 1; + return x >= min && x <= max && y >= min && y <= max; + } + return false; + } + function getTiles(projection, dimensions) { var s = projection.scale() * 2 * Math.PI, z = Math.max(Math.log(s) / Math.log(2) - 8, 0), @@ -64,7 +75,10 @@ iD.services.mapillary = function() { function loadTiles(which, url, projection, dimensions) { - var tiles = getTiles(projection, dimensions); + var tiles = getTiles(projection, dimensions).filter(function(t) { + var xyz = t.id.split(','); + return !nearNullIsland(xyz[0], xyz[1], xyz[2]); + }); _.filter(which.inflight, function(v, k) { var wanted = _.find(tiles, function(tile) { return k === (tile.id + ',0'); });