Calculate correct scale in tiler() for non-256px tile sizes

This commit is contained in:
Bryan Housel
2018-07-25 15:11:43 -04:00
parent 395be29d38
commit 11076bf0c5
2 changed files with 4 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ export function rendererTileLayer(context) {
function tileSizeAtZoom(d, z) {
var EPSILON = 0.002;
var EPSILON = 0.002; // close seams
return ((_tileSize * Math.pow(2, z - d[2])) / _tileSize) + EPSILON;
}
@@ -272,8 +272,7 @@ export function rendererTileLayer(context) {
_source = _;
_tileSize = _source.tileSize;
_cache = {};
// tiler.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent); // not yet
tiler.zoomExtent(_source.zoomExtent);
tiler.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent);
return background;
};

View File

@@ -35,7 +35,8 @@ export function utilTiler() {
function tiler() {
var z = geoScaleToZoom(_scale / (2 * Math.PI), _tileSize);
var z0 = bound(Math.round(z));
var k = Math.pow(2, z - z0 + 8);
var log2ts = Math.log(_tileSize) * Math.LOG2E;
var k = Math.pow(2, z - z0 + log2ts);
var origin = [
(_translate[0] - _scale / 2) / k,
(_translate[1] - _scale / 2) / k