From 177fcc7bcca140a1fe71bbb0223aa3eb8387286b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sat, 7 Oct 2017 12:37:55 -0600 Subject: [PATCH] Consistent use of ol.tilecoord.getKeyZXY() --- src/ol/source/tile.js | 12 +----------- src/ol/source/tiledebug.js | 3 ++- src/ol/source/tileimage.js | 5 +++-- src/ol/source/tileutfgrid.js | 5 +++-- src/ol/source/urltile.js | 3 ++- src/ol/source/vectortile.js | 5 +++-- test/spec/ol/source/tile.test.js | 4 +++- test/spec/ol/source/tileimage.test.js | 5 ++--- 8 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/ol/source/tile.js b/src/ol/source/tile.js index a757935d88..ddc39273c3 100644 --- a/src/ol/source/tile.js +++ b/src/ol/source/tile.js @@ -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. diff --git a/src/ol/source/tiledebug.js b/src/ol/source/tiledebug.js index 76772fd62b..80dfa8013f 100644 --- a/src/ol/source/tiledebug.js +++ b/src/ol/source/tiledebug.js @@ -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 { diff --git a/src/ol/source/tileimage.js b/src/ol/source/tileimage.js index acffdf50bf..4d5d8f9b5c 100644 --- a/src/ol/source/tileimage.js +++ b/src/ol/source/tileimage.js @@ -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); diff --git a/src/ol/source/tileutfgrid.js b/src/ol/source/tileutfgrid.js index 023fffe843..4826c9901a 100644 --- a/src/ol/source/tileutfgrid.js +++ b/src/ol/source/tileutfgrid.js @@ -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); } diff --git a/src/ol/source/urltile.js b/src/ol/source/urltile.js index 8f20a0795e..48e7d77003 100644 --- a/src/ol/source/urltile.js +++ b/src/ol/source/urltile.js @@ -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); } diff --git a/src/ol/source/vectortile.js b/src/ol/source/vectortile.js index e54f680bd7..f8801c948e 100644 --- a/src/ol/source/vectortile.js +++ b/src/ol/source/vectortile.js @@ -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 { diff --git a/test/spec/ol/source/tile.test.js b/test/spec/ol/source/tile.test.js index c7f454aa8d..5f04aac69f 100644 --- a/test/spec/ol/source/tile.test.js +++ b/test/spec/ol/source/tile.test.js @@ -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 { diff --git a/test/spec/ol/source/tileimage.test.js b/test/spec/ol/source/tileimage.test.js index 4f4c549417..9b9b98b185 100644 --- a/test/spec/ol/source/tileimage.test.js +++ b/test/spec/ol/source/tileimage.test.js @@ -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() {