Add projection parameter to ol.source.Tile#expireCache and #useTile

This is required to be able to determine which cache the xyz coordinates
refer to (in case we have more caches).
This commit is contained in:
Petr Sloup
2015-06-10 10:38:46 +02:00
parent e0cfa1951a
commit b0694c1e3b
3 changed files with 43 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ goog.provide('ol.source.TileImage');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.ImageTile');
goog.require('ol.TileCache');
goog.require('ol.TileCoord');
@@ -96,6 +97,34 @@ ol.source.TileImage.defaultTileLoadFunction = function(imageTile, src) {
};
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.canExpireCache = function() {
var canExpire = this.tileCache.canExpireCache();
if (canExpire) {
return true;
} else {
return goog.object.some(this.tileCacheForProjection, function(tileCache) {
return tileCache.canExpireCache();
});
}
};
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.expireCache = function(projection, usedTiles) {
var usedTileCache = this.getTileCacheForProjection(projection);
this.tileCache.expireCache(this.tileCache == usedTileCache ? usedTiles : {});
goog.object.forEach(this.tileCacheForProjection, function(tileCache) {
return tileCache.expireCache(tileCache == usedTileCache ? usedTiles : {});
});
};
/**
* @inheritDoc
*/
@@ -274,9 +303,10 @@ ol.source.TileImage.prototype.setTileUrlFunction = function(tileUrlFunction) {
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.useTile = function(z, x, y) {
ol.source.TileImage.prototype.useTile = function(z, x, y, projection) {
var tileCache = this.getTileCacheForProjection(projection);
var tileCoordKey = this.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
this.tileCache.get(tileCoordKey);
if (!goog.isNull(tileCache) && tileCache.containsKey(tileCoordKey)) {
tileCache.get(tileCoordKey);
}
};