Consistent use of ol.tilecoord.getKeyZXY()

This commit is contained in:
Tim Schaub
2017-10-07 12:37:55 -06:00
parent dbaf24ec39
commit bedec9d596
8 changed files with 19 additions and 23 deletions

View File

@@ -120,7 +120,7 @@ ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange,
var tile, tileCoordKey, loaded; var tile, tileCoordKey, loaded;
for (var x = tileRange.minX; x <= tileRange.maxX; ++x) { for (var x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (var y = tileRange.minY; y <= tileRange.maxY; ++y) { for (var y = tileRange.minY; y <= tileRange.maxY; ++y) {
tileCoordKey = this.getKeyZXY(z, x, y); tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
loaded = false; loaded = false;
if (tileCache.containsKey(tileCoordKey)) { if (tileCache.containsKey(tileCoordKey)) {
tile = /** @type {!ol.Tile} */ (tileCache.get(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. * @param {ol.proj.Projection} projection Projection.
* @return {boolean} Opaque. * @return {boolean} Opaque.

View File

@@ -6,6 +6,7 @@ goog.require('ol.TileState');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.size'); goog.require('ol.size');
goog.require('ol.source.Tile'); goog.require('ol.source.Tile');
goog.require('ol.tilecoord');
/** /**
@@ -38,7 +39,7 @@ ol.inherits(ol.source.TileDebug, ol.source.Tile);
* @inheritDoc * @inheritDoc
*/ */
ol.source.TileDebug.prototype.getTile = function(z, x, y) { 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)) { if (this.tileCache.containsKey(tileCoordKey)) {
return /** @type {!ol.source.TileDebug.Tile_} */ (this.tileCache.get(tileCoordKey)); return /** @type {!ol.source.TileDebug.Tile_} */ (this.tileCache.get(tileCoordKey));
} else { } else {

View File

@@ -9,6 +9,7 @@ goog.require('ol.events.EventType');
goog.require('ol.proj'); goog.require('ol.proj');
goog.require('ol.reproj.Tile'); goog.require('ol.reproj.Tile');
goog.require('ol.source.UrlTile'); goog.require('ol.source.UrlTile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid'); 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 cache = this.getTileCacheForProjection(projection);
var tileCoord = [z, x, y]; var tileCoord = [z, x, y];
var tile; var tile;
var tileCoordKey = this.getKeyZXY.apply(this, tileCoord); var tileCoordKey = ol.tilecoord.getKey(tileCoord);
if (cache.containsKey(tileCoordKey)) { if (cache.containsKey(tileCoordKey)) {
tile = /** @type {!ol.Tile} */ (cache.get(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) { ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, projection) {
var tile = null; var tile = null;
var tileCoordKey = this.getKeyZXY(z, x, y); var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
var key = this.getKey(); var key = this.getKey();
if (!this.tileCache.containsKey(tileCoordKey)) { if (!this.tileCache.containsKey(tileCoordKey)) {
tile = this.createTile_(z, x, y, pixelRatio, projection, key); tile = this.createTile_(z, x, y, pixelRatio, projection, key);

View File

@@ -13,6 +13,7 @@ goog.require('ol.net');
goog.require('ol.proj'); goog.require('ol.proj');
goog.require('ol.source.State'); goog.require('ol.source.State');
goog.require('ol.source.Tile'); goog.require('ol.source.Tile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid'); goog.require('ol.tilegrid');
@@ -223,7 +224,7 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
* @inheritDoc * @inheritDoc
*/ */
ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projection) { 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)) { if (this.tileCache.containsKey(tileCoordKey)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey)); return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
} else { } else {
@@ -248,7 +249,7 @@ ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projecti
* @inheritDoc * @inheritDoc
*/ */
ol.source.TileUTFGrid.prototype.useTile = function(z, x, y) { 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)) { if (this.tileCache.containsKey(tileCoordKey)) {
this.tileCache.get(tileCoordKey); this.tileCache.get(tileCoordKey);
} }

View File

@@ -5,6 +5,7 @@ goog.require('ol.TileState');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.source.Tile'); goog.require('ol.source.Tile');
goog.require('ol.source.TileEventType'); goog.require('ol.source.TileEventType');
goog.require('ol.tilecoord');
/** /**
@@ -195,7 +196,7 @@ ol.source.UrlTile.prototype.setUrls = function(urls) {
* @inheritDoc * @inheritDoc
*/ */
ol.source.UrlTile.prototype.useTile = function(z, x, y) { 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)) { if (this.tileCache.containsKey(tileCoordKey)) {
this.tileCache.get(tileCoordKey); this.tileCache.get(tileCoordKey);
} }

View File

@@ -5,8 +5,9 @@ goog.require('ol.TileState');
goog.require('ol.VectorImageTile'); goog.require('ol.VectorImageTile');
goog.require('ol.VectorTile'); goog.require('ol.VectorTile');
goog.require('ol.size'); goog.require('ol.size');
goog.require('ol.tilegrid');
goog.require('ol.source.UrlTile'); goog.require('ol.source.UrlTile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid');
/** /**
@@ -110,7 +111,7 @@ ol.source.VectorTile.prototype.clear = function() {
* @inheritDoc * @inheritDoc
*/ */
ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projection) { 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)) { if (this.tileCache.containsKey(tileCoordKey)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey)); return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
} else { } else {

View File

@@ -5,8 +5,10 @@ goog.require('ol.proj');
goog.require('ol.proj.Projection'); goog.require('ol.proj.Projection');
goog.require('ol.source.Source'); goog.require('ol.source.Source');
goog.require('ol.source.Tile'); goog.require('ol.source.Tile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid.TileGrid'); goog.require('ol.tilegrid.TileGrid');
/** /**
* Tile source for tests that uses a EPSG:4326 based grid with 4 resolutions and * Tile source for tests that uses a EPSG:4326 based grid with 4 resolutions and
* 256x256 tiles. * 256x256 tiles.
@@ -40,7 +42,7 @@ ol.inherits(MockTile, ol.source.Tile);
* @inheritDoc * @inheritDoc
*/ */
MockTile.prototype.getTile = function(z, x, y) { 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)) { if (this.tileCache.containsKey(key)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(key)); return /** @type {!ol.Tile} */ (this.tileCache.get(key));
} else { } else {

View File

@@ -1,5 +1,3 @@
goog.require('ol.ImageTile'); goog.require('ol.ImageTile');
goog.require('ol.TileState'); goog.require('ol.TileState');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
@@ -9,6 +7,7 @@ goog.require('ol.proj.EPSG3857');
goog.require('ol.proj.Projection'); goog.require('ol.proj.Projection');
goog.require('ol.reproj.Tile'); goog.require('ol.reproj.Tile');
goog.require('ol.source.TileImage'); goog.require('ol.source.TileImage');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid'); goog.require('ol.tilegrid');
@@ -52,7 +51,7 @@ describe('ol.source.TileImage', function() {
expect(source.getKey()).to.be(''); expect(source.getKey()).to.be('');
source.getTileInternal(0, 0, -1, 1, ol.proj.get('EPSG:3857')); source.getTileInternal(0, 0, -1, 1, ol.proj.get('EPSG:3857'));
expect(source.tileCache.getCount()).to.be(1); 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() { it('gets the tile from the cache', function() {