Replace getTile with getTileZXY

This massively reduces the number of temporary ol.TileCoord objects.

Previously an ol.TileCoord object was generated for every potentially
visible tile at the current zoom level and lower, every frame.  This
commit eliminates all of those.  Now new ol.TileCoord objects are only
allocated when a new tile is created.
This commit is contained in:
Tom Payne
2013-03-24 14:51:54 +01:00
parent 247fc8f031
commit dfb631a08f
9 changed files with 87 additions and 75 deletions

View File

@@ -122,13 +122,13 @@ ol.source.DebugTileSource.prototype.expireCache = function(usedTiles) {
/**
* @inheritDoc
*/
ol.source.DebugTileSource.prototype.getTile = function(tileCoord) {
var key = tileCoord.toString();
if (this.tileCache_.containsKey(key)) {
return /** @type {!ol.DebugTile_} */ (this.tileCache_.get(key));
ol.source.DebugTileSource.prototype.getTileZXY = function(z, x, y) {
var tileCoordKey = ol.TileCoord.getKeyZXY(z, x, y);
if (this.tileCache_.containsKey(tileCoordKey)) {
return /** @type {!ol.DebugTile_} */ (this.tileCache_.get(tileCoordKey));
} else {
var tile = new ol.DebugTile_(tileCoord, this.tileGrid);
this.tileCache_.set(key, tile);
var tile = new ol.DebugTile_(new ol.TileCoord(z, x, y), this.tileGrid);
this.tileCache_.set(tileCoordKey, tile);
return tile;
}
};