merged from 'master'

This commit is contained in:
Thomas Hervey
2018-07-21 21:45:08 -04:00
2 changed files with 10 additions and 32 deletions
+9 -24
View File
@@ -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;
};
+1 -8
View File
@@ -7,7 +7,6 @@ export function utilTiler() {
var _scale = 256;
var _scaleExtent = [0, 20];
var _translate = [_size[0] / 2, _size[1] / 2];
var _zoomDelta = 0;
var _margin = 0;
var _skipNullIsland = false;
@@ -34,7 +33,7 @@ export function utilTiler() {
function tiler() {
var z = Math.max(Math.log(_scale) / Math.LN2 - 8, 0);
var z0 = bound(Math.round(z + _zoomDelta));
var z0 = bound(Math.round(z));
var k = Math.pow(2, z - z0 + 8);
var origin = [
(_translate[0] - _scale / 2) / k,
@@ -139,12 +138,6 @@ export function utilTiler() {
};
tiler.zoomDelta = function(val) {
if (!arguments.length) return _zoomDelta;
_zoomDelta = +val;
return tiler;
};
// number to extend the rows/columns beyond those covering the viewport
tiler.margin = function(val) {
if (!arguments.length) return _margin;