Tune tile priority functions

This commit is contained in:
Tom Payne
2013-03-26 20:38:34 +01:00
parent 5e8b0de66d
commit 1d22d2fdde
2 changed files with 10 additions and 5 deletions
+8 -4
View File
@@ -500,12 +500,16 @@ ol.Map.prototype.getTilePriority =
if (!frameState.wantedTiles[tileSourceKey][coordKey]) { if (!frameState.wantedTiles[tileSourceKey][coordKey]) {
return ol.structs.PriorityQueue.DROP; return ol.structs.PriorityQueue.DROP;
} }
// Prioritize tiles closest to the focus. The + 1 helps to prioritize tiles // Prioritize the highest zoom level tiles closest to the focus.
// at higher zoom levels over tiles at lower zoom levels, even if the tile's // Tiles at higher zoom levels are prioritized using Math.log(tileResolution).
// center is close to the focus. // Within a zoom level, tiles are prioritized by the distance in pixels
// between the center of the tile and the focus. The factor of 65536 means
// that the prioritization should behave as desired for tiles up to
// 65536 * Math.log(2) = 45426 pixels from the focus.
var deltaX = tileCenter.x - frameState.focus.x; var deltaX = tileCenter.x - frameState.focus.x;
var deltaY = tileCenter.y - frameState.focus.y; var deltaY = tileCenter.y - frameState.focus.y;
return tileResolution * (deltaX * deltaX + deltaY * deltaY + 1); return 65536 * Math.log(tileResolution) +
Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution;
}; };
+2 -1
View File
@@ -176,7 +176,8 @@ ol.renderer.webgl.Map = function(container, map) {
var tileResolution = /** @type {number} */ (element[2]); var tileResolution = /** @type {number} */ (element[2]);
var deltaX = tileCenter.x - this.focus_.x; var deltaX = tileCenter.x - this.focus_.x;
var deltaY = tileCenter.y - this.focus_.y; var deltaY = tileCenter.y - this.focus_.y;
return tileResolution * (deltaX * deltaX + deltaY * deltaY + 1); return 65536 * Math.log(tileResolution) +
Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution;
}, this), }, this),
/** /**
* @param {Array} element Element. * @param {Array} element Element.