Fast path for parent range when zoom factor is 2

This commit is contained in:
Tim Schaub
2017-09-02 20:36:38 -06:00
parent eb31b75caa
commit d777edcc05
+16 -3
View File
@@ -186,11 +186,24 @@ ol.tilegrid.TileGrid.prototype.forEachTileCoord = function(extent, zoom, callbac
* @template T * @template T
*/ */
ol.tilegrid.TileGrid.prototype.forEachTileCoordParentTileRange = function(tileCoord, callback, opt_this, opt_tileRange, opt_extent) { ol.tilegrid.TileGrid.prototype.forEachTileCoordParentTileRange = function(tileCoord, callback, opt_this, opt_tileRange, opt_extent) {
var tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent); var tileRange, x, y;
var tileCoordExtent = null;
var z = tileCoord[0] - 1; var z = tileCoord[0] - 1;
if (this.zoomFactor_ === 2) {
x = tileCoord[1];
y = tileCoord[2];
} else {
tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent);
}
while (z >= this.minZoom) { while (z >= this.minZoom) {
if (callback.call(opt_this, z, if (this.zoomFactor_ === 2) {
this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange))) { x = Math.floor(x / 2);
y = Math.floor(y / 2);
tileRange = ol.TileRange.createOrUpdate(x, x, y, y, opt_tileRange);
} else {
tileRange = this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange);
}
if (callback.call(opt_this, z, tileRange)) {
return true; return true;
} }
--z; --z;