Use ol.TileCache in ol.source.DebugTileSource

This commit is contained in:
Tom Payne
2013-01-23 14:28:58 +01:00
parent 09ec444958
commit 0f3d708525
+22 -7
View File
@@ -2,6 +2,7 @@ goog.provide('ol.source.DebugTileSource');
goog.require('ol.Size'); goog.require('ol.Size');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.TileCache');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.source.TileSource'); goog.require('ol.source.TileSource');
goog.require('ol.tilegrid.TileGrid'); goog.require('ol.tilegrid.TileGrid');
@@ -94,26 +95,40 @@ ol.source.DebugTileSource = function(options) {
/** /**
* @private * @private
* @type {Object.<string, ol.DebugTile_>} * @type {ol.TileCache}
* FIXME will need to expire elements from this cache
* FIXME see elemoine's work with goog.structs.LinkedMap
*/ */
this.tileCache_ = {}; this.tileCache_ = new ol.TileCache();
}; };
goog.inherits(ol.source.DebugTileSource, ol.source.TileSource); goog.inherits(ol.source.DebugTileSource, ol.source.TileSource);
/**
* @inheritDoc
*/
ol.source.DebugTileSource.prototype.canExpireCache = function() {
return this.tileCache_.canExpireCache();
};
/**
* @inheritDoc
*/
ol.source.DebugTileSource.prototype.expireCache = function(usedTiles) {
this.tileCache_.expireCache(usedTiles);
};
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.source.DebugTileSource.prototype.getTile = function(tileCoord) { ol.source.DebugTileSource.prototype.getTile = function(tileCoord) {
var key = tileCoord.toString(); var key = tileCoord.toString();
if (goog.object.containsKey(this.tileCache_, key)) { if (this.tileCache_.containsKey(key)) {
return this.tileCache_[key]; return /** @type {ol.DebugTile_} */ (this.tileCache_.get(key));
} else { } else {
var tile = new ol.DebugTile_(tileCoord, this.tileGrid); var tile = new ol.DebugTile_(tileCoord, this.tileGrid);
this.tileCache_[key] = tile; this.tileCache_.set(key, tile);
return tile; return tile;
} }
}; };