Make tile keys stable to avoid TileQueue confusion

This commit is contained in:
ahocevar
2018-12-04 00:18:14 +01:00
parent 6202a0cf05
commit df59b894b1
2 changed files with 5 additions and 15 deletions
+3 -13
View File
@@ -93,11 +93,6 @@ class VectorImageTile extends Tile {
*/ */
this.extent = null; this.extent = null;
/**
* @type {number}
*/
this.sourceRevision_ = sourceRevision;
/** /**
* @type {import("./tilecoord.js").TileCoord} * @type {import("./tilecoord.js").TileCoord}
*/ */
@@ -118,6 +113,8 @@ class VectorImageTile extends Tile {
*/ */
this.sourceTileListenerKeys_ = []; this.sourceTileListenerKeys_ = [];
this.key = sourceRevision.toString();
if (urlTileCoord && sourceTileGrid) { if (urlTileCoord && sourceTileGrid) {
const extent = this.extent = tileGrid.getTileCoordExtent(urlTileCoord); const extent = this.extent = tileGrid.getTileCoordExtent(urlTileCoord);
const resolution = this.resolution_ = tileGrid.getResolution(urlTileCoord[0]); const resolution = this.resolution_ = tileGrid.getResolution(urlTileCoord[0]);
@@ -233,7 +230,7 @@ class VectorImageTile extends Tile {
for (let i = 0, ii = tileKeys.length; i < ii; ++i) { for (let i = 0, ii = tileKeys.length; i < ii; ++i) {
this.sourceTiles_[tileKeys[i]].consumers++; this.sourceTiles_[tileKeys[i]].consumers++;
} }
const tile = new VectorImageTile(this.tileCoord, TileState.IDLE, undefined, null, null, const tile = new VectorImageTile(this.tileCoord, TileState.IDLE, Number(this.key), null, null,
this.wrappedTileCoord, null, null, null, this.sourceTiles_, this.wrappedTileCoord, null, null, null, this.sourceTiles_,
undefined, null, null, null); undefined, null, null, null);
tile.extent = this.extent; tile.extent = this.extent;
@@ -269,13 +266,6 @@ class VectorImageTile extends Tile {
return this.replayState_[key]; return this.replayState_[key];
} }
/**
* @inheritDoc
*/
getKey() {
return this.tileKeys.join('/') + '-' + this.sourceRevision_;
}
/** /**
* @param {string} tileKey Key (tileCoord) of the source tile. * @param {string} tileKey Key (tileCoord) of the source tile.
* @return {import("./VectorTile.js").default} Source tile. * @return {import("./VectorTile.js").default} Source tile.
@@ -245,7 +245,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
sourceTile.getImage = function() { sourceTile.getImage = function() {
return document.createElement('canvas'); return document.createElement('canvas');
}; };
const tile = new VectorImageTile([0, 0, 0], undefined, undefined, undefined, const tile = new VectorImageTile([0, 0, 0], undefined, 1, undefined,
undefined, [0, 0, 0], undefined, createXYZ(), createXYZ(), {'0,0,0': sourceTile}, undefined, undefined, [0, 0, 0], undefined, createXYZ(), createXYZ(), {'0,0,0': sourceTile}, undefined,
undefined, undefined, undefined); undefined, undefined, undefined);
tile.transition_ = 0; tile.transition_ = 0;
@@ -338,7 +338,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
} }
}; };
frameState.layerStates[getUid(layer)] = {}; frameState.layerStates[getUid(layer)] = {};
renderer.renderedTiles = [new TileClass([0, 0, -1])]; renderer.renderedTiles = [new TileClass([0, 0, -1], undefined, 1)];
renderer.forEachFeatureAtCoordinate( renderer.forEachFeatureAtCoordinate(
coordinate, frameState, 0, spy, undefined); coordinate, frameState, 0, spy, undefined);
expect(spy.callCount).to.be(1); expect(spy.callCount).to.be(1);