Always go through source tile change logic
This commit is contained in:
+66
-62
@@ -200,74 +200,78 @@ class VectorTile extends UrlTile {
|
|||||||
const minZoom = sourceTileGrid.getMinZoom();
|
const minZoom = sourceTileGrid.getMinZoom();
|
||||||
|
|
||||||
const previousSourceTiles = this.sourceTilesByTileKey_[tile.getKey()];
|
const previousSourceTiles = this.sourceTilesByTileKey_[tile.getKey()];
|
||||||
|
let sourceTiles, covered, empty, loadedZ;
|
||||||
if (previousSourceTiles && previousSourceTiles.length > 0 && previousSourceTiles[0].tileCoord[0] === sourceZ) {
|
if (previousSourceTiles && previousSourceTiles.length > 0 && previousSourceTiles[0].tileCoord[0] === sourceZ) {
|
||||||
return previousSourceTiles;
|
sourceTiles = previousSourceTiles;
|
||||||
}
|
|
||||||
|
|
||||||
const sourceTiles = [];
|
|
||||||
let loadedZ = sourceZ + 1;
|
|
||||||
let covered, empty;
|
|
||||||
do {
|
|
||||||
--loadedZ;
|
|
||||||
covered = true;
|
covered = true;
|
||||||
empty = true;
|
empty = false;
|
||||||
sourceTileGrid.forEachTileCoord(extent, loadedZ, function(sourceTileCoord) {
|
loadedZ = sourceZ;
|
||||||
const coordKey = getKey(sourceTileCoord);
|
} else {
|
||||||
let sourceTile;
|
sourceTiles = [];
|
||||||
if (coordKey in this.sourceTileByCoordKey_) {
|
loadedZ = sourceZ + 1;
|
||||||
sourceTile = this.sourceTileByCoordKey_[coordKey];
|
do {
|
||||||
const state = sourceTile.getState();
|
--loadedZ;
|
||||||
if (state === TileState.LOADED || state === TileState.ERROR || state === TileState.EMPTY) {
|
covered = true;
|
||||||
empty = empty && state === TileState.EMPTY;
|
empty = true;
|
||||||
sourceTiles.push(sourceTile);
|
sourceTileGrid.forEachTileCoord(extent, loadedZ, function(sourceTileCoord) {
|
||||||
|
const coordKey = getKey(sourceTileCoord);
|
||||||
|
let sourceTile;
|
||||||
|
if (coordKey in this.sourceTileByCoordKey_) {
|
||||||
|
sourceTile = this.sourceTileByCoordKey_[coordKey];
|
||||||
|
const state = sourceTile.getState();
|
||||||
|
if (state === TileState.LOADED || state === TileState.ERROR || state === TileState.EMPTY) {
|
||||||
|
empty = empty && state === TileState.EMPTY;
|
||||||
|
sourceTiles.push(sourceTile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (loadedZ === sourceZ) {
|
||||||
|
const tileUrl = this.tileUrlFunction(sourceTileCoord, pixelRatio, projection);
|
||||||
|
if (tileUrl !== undefined) {
|
||||||
|
sourceTile = new this.tileClass(sourceTileCoord, TileState.IDLE, tileUrl,
|
||||||
|
this.format_, this.tileLoadFunction);
|
||||||
|
sourceTile.extent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
|
||||||
|
sourceTile.projection = projection;
|
||||||
|
sourceTile.resolution = sourceTileGrid.getResolution(sourceTileCoord[0]);
|
||||||
|
this.sourceTileByCoordKey_[coordKey] = sourceTile;
|
||||||
|
empty = false;
|
||||||
|
listen(sourceTile, EventType.CHANGE, this.handleTileChange, this);
|
||||||
|
sourceTile.load();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
empty = false;
|
||||||
|
}
|
||||||
|
covered = false;
|
||||||
|
if (!sourceTile) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (loadedZ === sourceZ) {
|
if (sourceTile.getState() !== TileState.EMPTY && tile.getState() === TileState.IDLE) {
|
||||||
const tileUrl = this.tileUrlFunction(sourceTileCoord, pixelRatio, projection);
|
tile.loadingSourceTiles++;
|
||||||
if (tileUrl !== undefined) {
|
const key = listen(sourceTile, EventType.CHANGE, function() {
|
||||||
sourceTile = new this.tileClass(sourceTileCoord, TileState.IDLE, tileUrl,
|
const state = sourceTile.getState();
|
||||||
this.format_, this.tileLoadFunction);
|
const sourceTileKey = sourceTile.getKey();
|
||||||
sourceTile.extent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
|
if (state === TileState.LOADED || state === TileState.ERROR) {
|
||||||
sourceTile.projection = projection;
|
if (state === TileState.LOADED) {
|
||||||
sourceTile.resolution = sourceTileGrid.getResolution(sourceTileCoord[0]);
|
unlistenByKey(key);
|
||||||
this.sourceTileByCoordKey_[coordKey] = sourceTile;
|
tile.loadingSourceTiles--;
|
||||||
empty = false;
|
delete tile.errorSourceTileKeys[sourceTileKey];
|
||||||
listen(sourceTile, EventType.CHANGE, this.handleTileChange, this);
|
} else if (state === TileState.ERROR) {
|
||||||
sourceTile.load();
|
tile.errorSourceTileKeys[sourceTileKey] = true;
|
||||||
|
}
|
||||||
|
if (tile.loadingSourceTiles - Object.keys(tile.errorSourceTileKeys).length === 0) {
|
||||||
|
tile.hifi = true;
|
||||||
|
tile.sourceZ = sourceZ;
|
||||||
|
tile.setState(isEmpty(tile.errorSourceTileKeys) ? TileState.LOADED : TileState.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
}.bind(this));
|
||||||
empty = false;
|
if (!covered) {
|
||||||
|
sourceTiles.length = 0;
|
||||||
}
|
}
|
||||||
covered = false;
|
} while (!covered && loadedZ > minZoom);
|
||||||
if (!sourceTile) {
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sourceTile.getState() !== TileState.EMPTY && tile.getState() === TileState.IDLE) {
|
|
||||||
tile.loadingSourceTiles++;
|
|
||||||
const key = listen(sourceTile, EventType.CHANGE, function() {
|
|
||||||
const state = sourceTile.getState();
|
|
||||||
const sourceTileKey = sourceTile.getKey();
|
|
||||||
if (state === TileState.LOADED || state === TileState.ERROR) {
|
|
||||||
if (state === TileState.LOADED) {
|
|
||||||
unlistenByKey(key);
|
|
||||||
tile.loadingSourceTiles--;
|
|
||||||
delete tile.errorSourceTileKeys[sourceTileKey];
|
|
||||||
} else if (state === TileState.ERROR) {
|
|
||||||
tile.errorSourceTileKeys[sourceTileKey] = true;
|
|
||||||
}
|
|
||||||
if (tile.loadingSourceTiles - Object.keys(tile.errorSourceTileKeys).length === 0) {
|
|
||||||
tile.hifi = true;
|
|
||||||
tile.sourceZ = sourceZ;
|
|
||||||
tile.setState(isEmpty(tile.errorSourceTileKeys) ? TileState.LOADED : TileState.ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
if (!covered) {
|
|
||||||
sourceTiles.length = 0;
|
|
||||||
}
|
|
||||||
} while (!covered && loadedZ > minZoom);
|
|
||||||
if (!empty && tile.getState() === TileState.IDLE) {
|
if (!empty && tile.getState() === TileState.IDLE) {
|
||||||
tile.setState(TileState.LOADING);
|
tile.setState(TileState.LOADING);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user