Consistent use of ol.tilecoord.getKeyZXY()
This commit is contained in:
@@ -120,7 +120,7 @@ ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange,
|
||||
var tile, tileCoordKey, loaded;
|
||||
for (var x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (var y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
tileCoordKey = this.getKeyZXY(z, x, y);
|
||||
tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
|
||||
loaded = false;
|
||||
if (tileCache.containsKey(tileCoordKey)) {
|
||||
tile = /** @type {!ol.Tile} */ (tileCache.get(tileCoordKey));
|
||||
@@ -170,16 +170,6 @@ ol.source.Tile.prototype.setKey = function(key) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} z Z.
|
||||
* @param {number} x X.
|
||||
* @param {number} y Y.
|
||||
* @return {string} Key.
|
||||
* @protected
|
||||
*/
|
||||
ol.source.Tile.prototype.getKeyZXY = ol.tilecoord.getKeyZXY;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @return {boolean} Opaque.
|
||||
|
||||
@@ -6,6 +6,7 @@ goog.require('ol.TileState');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.size');
|
||||
goog.require('ol.source.Tile');
|
||||
goog.require('ol.tilecoord');
|
||||
|
||||
|
||||
/**
|
||||
@@ -38,7 +39,7 @@ ol.inherits(ol.source.TileDebug, ol.source.Tile);
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.TileDebug.prototype.getTile = function(z, x, y) {
|
||||
var tileCoordKey = this.getKeyZXY(z, x, y);
|
||||
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||
return /** @type {!ol.source.TileDebug.Tile_} */ (this.tileCache.get(tileCoordKey));
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@ goog.require('ol.events.EventType');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.reproj.Tile');
|
||||
goog.require('ol.source.UrlTile');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid');
|
||||
|
||||
|
||||
@@ -245,7 +246,7 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
|
||||
var cache = this.getTileCacheForProjection(projection);
|
||||
var tileCoord = [z, x, y];
|
||||
var tile;
|
||||
var tileCoordKey = this.getKeyZXY.apply(this, tileCoord);
|
||||
var tileCoordKey = ol.tilecoord.getKey(tileCoord);
|
||||
if (cache.containsKey(tileCoordKey)) {
|
||||
tile = /** @type {!ol.Tile} */ (cache.get(tileCoordKey));
|
||||
}
|
||||
@@ -293,7 +294,7 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
|
||||
*/
|
||||
ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, projection) {
|
||||
var tile = null;
|
||||
var tileCoordKey = this.getKeyZXY(z, x, y);
|
||||
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
|
||||
var key = this.getKey();
|
||||
if (!this.tileCache.containsKey(tileCoordKey)) {
|
||||
tile = this.createTile_(z, x, y, pixelRatio, projection, key);
|
||||
|
||||
@@ -13,6 +13,7 @@ goog.require('ol.net');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.State');
|
||||
goog.require('ol.source.Tile');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid');
|
||||
|
||||
|
||||
@@ -223,7 +224,7 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projection) {
|
||||
var tileCoordKey = this.getKeyZXY(z, x, y);
|
||||
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
|
||||
} else {
|
||||
@@ -248,7 +249,7 @@ ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projecti
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.TileUTFGrid.prototype.useTile = function(z, x, y) {
|
||||
var tileCoordKey = this.getKeyZXY(z, x, y);
|
||||
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||
this.tileCache.get(tileCoordKey);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ goog.require('ol.TileState');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.source.Tile');
|
||||
goog.require('ol.source.TileEventType');
|
||||
goog.require('ol.tilecoord');
|
||||
|
||||
|
||||
/**
|
||||
@@ -195,7 +196,7 @@ ol.source.UrlTile.prototype.setUrls = function(urls) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.UrlTile.prototype.useTile = function(z, x, y) {
|
||||
var tileCoordKey = this.getKeyZXY(z, x, y);
|
||||
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||
this.tileCache.get(tileCoordKey);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ goog.require('ol.TileState');
|
||||
goog.require('ol.VectorImageTile');
|
||||
goog.require('ol.VectorTile');
|
||||
goog.require('ol.size');
|
||||
goog.require('ol.tilegrid');
|
||||
goog.require('ol.source.UrlTile');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid');
|
||||
|
||||
|
||||
/**
|
||||
@@ -110,7 +111,7 @@ ol.source.VectorTile.prototype.clear = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projection) {
|
||||
var tileCoordKey = this.getKeyZXY(z, x, y);
|
||||
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
||||
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
|
||||
} else {
|
||||
|
||||
@@ -5,8 +5,10 @@ goog.require('ol.proj');
|
||||
goog.require('ol.proj.Projection');
|
||||
goog.require('ol.source.Source');
|
||||
goog.require('ol.source.Tile');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
|
||||
/**
|
||||
* Tile source for tests that uses a EPSG:4326 based grid with 4 resolutions and
|
||||
* 256x256 tiles.
|
||||
@@ -40,7 +42,7 @@ ol.inherits(MockTile, ol.source.Tile);
|
||||
* @inheritDoc
|
||||
*/
|
||||
MockTile.prototype.getTile = function(z, x, y) {
|
||||
var key = this.getKeyZXY(z, x, y);
|
||||
var key = ol.tilecoord.getKeyZXY(z, x, y);
|
||||
if (this.tileCache.containsKey(key)) {
|
||||
return /** @type {!ol.Tile} */ (this.tileCache.get(key));
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
goog.require('ol.ImageTile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
@@ -9,6 +7,7 @@ goog.require('ol.proj.EPSG3857');
|
||||
goog.require('ol.proj.Projection');
|
||||
goog.require('ol.reproj.Tile');
|
||||
goog.require('ol.source.TileImage');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid');
|
||||
|
||||
|
||||
@@ -52,7 +51,7 @@ describe('ol.source.TileImage', function() {
|
||||
expect(source.getKey()).to.be('');
|
||||
source.getTileInternal(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
|
||||
expect(source.tileCache.getCount()).to.be(1);
|
||||
tile = source.tileCache.get(source.getKeyZXY(0, 0, -1));
|
||||
tile = source.tileCache.get(ol.tilecoord.getKeyZXY(0, 0, -1));
|
||||
});
|
||||
|
||||
it('gets the tile from the cache', function() {
|
||||
|
||||
Reference in New Issue
Block a user