Tile grid and cache for one resolution only

This commit is contained in:
ahocevar
2013-06-21 18:53:15 +02:00
parent 89c23b5560
commit f20e6002cc
@@ -316,20 +316,16 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
if (!frameState.viewHints[ol.ViewHint.ANIMATING] && if (!frameState.viewHints[ol.ViewHint.ANIMATING] &&
!frameState.viewHints[ol.ViewHint.INTERACTING]) { !frameState.viewHints[ol.ViewHint.INTERACTING]) {
// avoid rendering issues for very high zoom levels // avoid rendering issues for very high zoom levels
var newResolution = Math.max(resolution, ol.renderer.canvas.MIN_RESOLUTION); var gridResolution = Math.max(resolution,
var oldResolutions = goog.isNull(this.tileGrid_) ? [] : ol.renderer.canvas.MIN_RESOLUTION);
this.tileGrid_.getResolutions(); if (gridResolution !== this.renderedResolution_) {
if (!goog.array.contains(oldResolutions, newResolution)) {
var newResolutions = oldResolutions.concat([]);
goog.array.binaryInsert(newResolutions, newResolution,
function(a, b) { return b - a; });
tileGrid = new ol.tilegrid.TileGrid({ tileGrid = new ol.tilegrid.TileGrid({
origin: [0, 0], origin: [0, 0],
projection: view2DState.projection, projection: view2DState.projection,
resolutions: newResolutions, resolutions: [gridResolution],
tileSize: [512, 512] tileSize: [512, 512]
}); });
this.updateTileCache_(oldResolutions, newResolutions); this.tileCache_.clear();
this.tileGrid_ = tileGrid; this.tileGrid_ = tileGrid;
} }
} }
@@ -531,25 +527,6 @@ ol.renderer.canvas.VectorLayer.prototype.pruneTileCache_ = function() {
}; };
/**
* @private
* @param {Array.<number>} oldResolutions Resolutions of the old tile grid.
* @param {Array.<number>} newResolutions Resolutions of the new tile grid.
*/
ol.renderer.canvas.VectorLayer.prototype.updateTileCache_ =
function(oldResolutions, newResolutions) {
var keys = this.tileCache_.getKeys(),
tileCoord, key, i;
for (i = keys.length - 1; i >= 0; --i) {
key = keys[i];
tileCoord = ol.TileCoord.createFromString(key);
tileCoord.z = goog.array.indexOf(newResolutions,
oldResolutions[tileCoord.z]);
this.tileCache_.set(tileCoord.toString(), this.tileCache_.pop());
}
};
/** /**
* @type {number} * @type {number}
*/ */