mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 07:25:15 +02:00
Don't fetch overlay tiles or mapillary data around Null Island
(closes #2751)
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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'); });
|
||||
|
||||
Reference in New Issue
Block a user