Smarter interim tile creation
This commit is contained in:
@@ -6,7 +6,7 @@ import Tile from './Tile.js';
|
||||
import TileState from './TileState.js';
|
||||
import {createCanvasContext2D} from './dom.js';
|
||||
import {listen, unlistenByKey} from './events.js';
|
||||
import {getHeight, getIntersection, getWidth} from './extent.js';
|
||||
import {containsExtent, getHeight, getIntersection, getWidth} from './extent.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {loadFeaturesXhr} from './featureloader.js';
|
||||
import {VOID} from './functions.js';
|
||||
@@ -103,6 +103,8 @@ class VectorImageTile extends Tile {
|
||||
*/
|
||||
this.sourceTileListenerKeys_ = [];
|
||||
|
||||
this.sourceTilesLoaded = false;
|
||||
|
||||
/**
|
||||
* Use only source tiles that are loaded already
|
||||
* @type {boolean}
|
||||
@@ -148,16 +150,24 @@ class VectorImageTile extends Tile {
|
||||
this.finishLoading_();
|
||||
}
|
||||
|
||||
if (zoom <= tileCoord[0] && this.state != TileState.LOADED) {
|
||||
while (zoom > tileGrid.getMinZoom()) {
|
||||
if (!this.sourceTilesLoaded && !useLoadedOnly) {
|
||||
let bestZoom = -1;
|
||||
for (const key in sourceTiles) {
|
||||
const sourceTile = sourceTiles[key];
|
||||
if (sourceTile.getState() === TileState.LOADED) {
|
||||
const sourceTileCoord = sourceTile.tileCoord;
|
||||
const sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
|
||||
if (containsExtent(sourceTileExtent, extent) && sourceTileCoord[0] > bestZoom) {
|
||||
bestZoom = sourceTileCoord[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bestZoom !== -1) {
|
||||
const tile = new VectorImageTile(tileCoord, state, sourceRevision,
|
||||
format, tileLoadFunction, urlTileCoord, tileUrlFunction,
|
||||
sourceTileGrid, tileGrid, sourceTiles, pixelRatio, projection,
|
||||
tileClass, VOID, --zoom);
|
||||
if (tile.state == TileState.LOADED) {
|
||||
this.interimTile = tile;
|
||||
break;
|
||||
}
|
||||
tileClass, VOID, bestZoom);
|
||||
this.interimTile = tile;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,6 +178,7 @@ class VectorImageTile extends Tile {
|
||||
* @inheritDoc
|
||||
*/
|
||||
disposeInternal() {
|
||||
this.getInterimTile = super.getInterimTile;
|
||||
this.state = TileState.ABORT;
|
||||
this.changed();
|
||||
if (this.interimTile) {
|
||||
@@ -312,6 +323,7 @@ class VectorImageTile extends Tile {
|
||||
if (loaded == this.tileKeys.length) {
|
||||
this.loadListenerKeys_.forEach(unlistenByKey);
|
||||
this.loadListenerKeys_.length = 0;
|
||||
this.sourceTilesLoaded = true;
|
||||
this.setState(TileState.LOADED);
|
||||
} else {
|
||||
this.setState(empty == this.tileKeys.length ? TileState.EMPTY : TileState.ERROR);
|
||||
|
||||
Reference in New Issue
Block a user