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:
@@ -194,7 +194,8 @@ ol.renderer.Layer.prototype.scheduleExpireCache =
|
|||||||
*/
|
*/
|
||||||
function(tileSource, map, frameState) {
|
function(tileSource, map, frameState) {
|
||||||
var tileSourceKey = goog.getUid(tileSource).toString();
|
var tileSourceKey = goog.getUid(tileSource).toString();
|
||||||
tileSource.expireCache(frameState.usedTiles[tileSourceKey]);
|
tileSource.expireCache(frameState.viewState.projection,
|
||||||
|
frameState.usedTiles[tileSourceKey]);
|
||||||
}, tileSource));
|
}, tileSource));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -327,7 +328,7 @@ ol.renderer.Layer.prototype.manageTilePyramid = function(
|
|||||||
opt_tileCallback.call(opt_this, tile);
|
opt_tileCallback.call(opt_this, tile);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tileSource.useTile(z, x, y);
|
tileSource.useTile(z, x, y, projection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.provide('ol.source.TileImage');
|
|||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
|
goog.require('goog.object');
|
||||||
goog.require('ol.ImageTile');
|
goog.require('ol.ImageTile');
|
||||||
goog.require('ol.TileCache');
|
goog.require('ol.TileCache');
|
||||||
goog.require('ol.TileCoord');
|
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
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -274,9 +303,10 @@ ol.source.TileImage.prototype.setTileUrlFunction = function(tileUrlFunction) {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @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);
|
var tileCoordKey = this.getKeyZXY(z, x, y);
|
||||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
if (!goog.isNull(tileCache) && tileCache.containsKey(tileCoordKey)) {
|
||||||
this.tileCache.get(tileCoordKey);
|
tileCache.get(tileCoordKey);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,10 +98,14 @@ ol.source.Tile.prototype.canExpireCache = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param {ol.proj.Projection} projection
|
||||||
* @param {Object.<string, ol.TileRange>} usedTiles Used tiles.
|
* @param {Object.<string, ol.TileRange>} usedTiles Used tiles.
|
||||||
*/
|
*/
|
||||||
ol.source.Tile.prototype.expireCache = function(usedTiles) {
|
ol.source.Tile.prototype.expireCache = function(projection, usedTiles) {
|
||||||
this.tileCache.expireCache(usedTiles);
|
var tileCache = this.getTileCacheForProjection(projection);
|
||||||
|
if (!goog.isNull(tileCache)) {
|
||||||
|
tileCache.expireCache(usedTiles);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -267,6 +271,7 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction =
|
|||||||
* @param {number} z Tile coordinate z.
|
* @param {number} z Tile coordinate z.
|
||||||
* @param {number} x Tile coordinate x.
|
* @param {number} x Tile coordinate x.
|
||||||
* @param {number} y Tile coordinate y.
|
* @param {number} y Tile coordinate y.
|
||||||
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
*/
|
*/
|
||||||
ol.source.Tile.prototype.useTile = ol.nullFunction;
|
ol.source.Tile.prototype.useTile = ol.nullFunction;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user