Merge pull request #226 from twpayne/preserve-low-resolution-tiles

Preserve low resolution tiles
This commit is contained in:
Tom Payne
2013-02-22 02:14:41 -08:00
6 changed files with 55 additions and 16 deletions

View File

@@ -109,3 +109,14 @@ ol.source.ImageTileSource.prototype.getTile = function(tileCoord) {
ol.source.ImageTileSource.prototype.getTileCoordUrl = function(tileCoord) {
return this.tileUrlFunction(tileCoord);
};
/**
* @inheritDoc
*/
ol.source.ImageTileSource.prototype.useTile = function(tileCoord) {
var key = tileCoord.toString();
if (this.tileCache_.containsKey(key)) {
this.tileCache_.get(key);
}
};

View File

@@ -119,3 +119,29 @@ ol.source.TileSource.prototype.getTile = goog.abstractMethod;
ol.source.TileSource.prototype.getTileGrid = function() {
return this.tileGrid;
};
/**
* @param {number} z Z.
* @param {ol.Extent} extent Extent.
*/
ol.source.TileSource.prototype.useLowResolutionTiles = function(z, extent) {
var tileGrid = this.getTileGrid();
var tileRange, x, y, zKey;
// FIXME this should loop up to tileGrid's minZ when implemented
for (; z >= 0; --z) {
tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
this.useTile(z + '/' + x + '/' + y);
}
}
}
};
/**
* Marks a tile coord as being used, without triggering a load.
* @param {string} tileCoordKey Tile coordinate key.
*/
ol.source.TileSource.prototype.useTile = goog.nullFunction;