mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Use utilTiler's Null Island filter for overlay sources
This commit is contained in:
@@ -8,7 +8,7 @@ import { utilPrefixCSSProperty, utilTiler } from '../util';
|
||||
export function rendererTileLayer(context) {
|
||||
var tileSize = 256;
|
||||
var transformProp = utilPrefixCSSProperty('Transform');
|
||||
var geotile = utilTiler();
|
||||
var tiler = utilTiler();
|
||||
|
||||
var _projection;
|
||||
var _cache = {};
|
||||
@@ -17,19 +17,6 @@ export function rendererTileLayer(context) {
|
||||
var _source;
|
||||
|
||||
|
||||
// blacklist overlay tiles around Null Island..
|
||||
function nearNullIsland(x, y, z) {
|
||||
if (z >= 7) {
|
||||
var center = Math.pow(2, z - 1);
|
||||
var width = Math.pow(2, z - 6);
|
||||
var min = center - (width / 2);
|
||||
var 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;
|
||||
@@ -94,7 +81,7 @@ export function rendererTileLayer(context) {
|
||||
_projection.translate()[1] + pixelOffset[1]
|
||||
];
|
||||
|
||||
geotile
|
||||
tiler
|
||||
.scale(_projection.scale() * 2 * Math.PI)
|
||||
.translate(translate);
|
||||
|
||||
@@ -116,7 +103,9 @@ export function rendererTileLayer(context) {
|
||||
var showDebug = context.getDebug('tile') && !_source.overlay;
|
||||
|
||||
if (_source.validZoom(_zoom)) {
|
||||
geotile().forEach(function(d) {
|
||||
tiler.skipNullIsland(!!_source.overlay);
|
||||
|
||||
tiler().forEach(function(d) {
|
||||
addSource(d);
|
||||
if (d[3] === '') return;
|
||||
if (typeof d[3] !== 'string') return; // Workaround for #2295
|
||||
@@ -127,15 +116,11 @@ export function rendererTileLayer(context) {
|
||||
});
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function load(d) {
|
||||
_cache[d[3]] = true;
|
||||
d3_select(this)
|
||||
@@ -179,7 +164,7 @@ export function rendererTileLayer(context) {
|
||||
|
||||
// Pick a representative tile near the center of the viewport
|
||||
// (This is useful for sampling the imagery vintage)
|
||||
var dims = geotile.size();
|
||||
var dims = tiler.size();
|
||||
var mapCenter = [dims[0] / 2, dims[1] / 2];
|
||||
var minDist = Math.max(dims[0], dims[1]);
|
||||
var nearCenter;
|
||||
@@ -276,8 +261,8 @@ export function rendererTileLayer(context) {
|
||||
|
||||
|
||||
background.dimensions = function(_) {
|
||||
if (!arguments.length) return geotile.size();
|
||||
geotile.size(_);
|
||||
if (!arguments.length) return tiler.size();
|
||||
tiler.size(_);
|
||||
return background;
|
||||
};
|
||||
|
||||
@@ -286,7 +271,7 @@ export function rendererTileLayer(context) {
|
||||
if (!arguments.length) return _source;
|
||||
_source = _;
|
||||
_cache = {};
|
||||
geotile.scaleExtent(_source.scaleExtent);
|
||||
tiler.scaleExtent(_source.scaleExtent);
|
||||
return background;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user