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