Remove interim tile handling for now
This commit is contained in:
@@ -146,10 +146,9 @@ class Tile extends EventTarget {
|
||||
* Get the interim tile most suitable for rendering using the chain of interim
|
||||
* tiles. This corresponds to the most recent tile that has been loaded, if no
|
||||
* such tile exists, the original tile is returned.
|
||||
* @param {import("./layer/Layer").default} layer Layer.
|
||||
* @return {!Tile} Best tile for rendering.
|
||||
*/
|
||||
getInterimTile(layer) {
|
||||
getInterimTile() {
|
||||
if (!this.interimTile) {
|
||||
//empty chain
|
||||
return this;
|
||||
|
||||
@@ -6,10 +6,9 @@ import Tile from './Tile.js';
|
||||
import TileState from './TileState.js';
|
||||
import {createCanvasContext2D} from './dom.js';
|
||||
import {listen, unlistenByKey} from './events.js';
|
||||
import {containsExtent, getHeight, getIntersection, getWidth} from './extent.js';
|
||||
import {getHeight, getIntersection, getWidth} from './extent.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {loadFeaturesXhr} from './featureloader.js';
|
||||
import {VOID} from './functions.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,11 +39,10 @@ class VectorImageTile extends Tile {
|
||||
* instantiate for source tiles.
|
||||
* @param {function(this: import("./source/VectorTile.js").default, import("./events/Event.js").default)} handleTileChange
|
||||
* Function to call when a source tile's state changes.
|
||||
* @param {number} zoom Integer zoom to render the tile for.
|
||||
*/
|
||||
constructor(tileCoord, state, sourceRevision, format, tileLoadFunction,
|
||||
urlTileCoord, tileUrlFunction, sourceTileGrid, tileGrid, sourceTiles,
|
||||
pixelRatio, projection, tileClass, handleTileChange, zoom) {
|
||||
pixelRatio, projection, tileClass, handleTileChange) {
|
||||
|
||||
super(tileCoord, state, {transition: 0});
|
||||
|
||||
@@ -109,18 +107,10 @@ class VectorImageTile extends Tile {
|
||||
*/
|
||||
this.sourceTileListenerKeys_ = [];
|
||||
|
||||
/**
|
||||
* Use only source tiles that are loaded already
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isInterimTile = zoom != tileCoord[0];
|
||||
|
||||
if (urlTileCoord) {
|
||||
const extent = this.extent = tileGrid.getTileCoordExtent(urlTileCoord);
|
||||
const resolution = tileGrid.getResolution(zoom);
|
||||
const resolution = tileGrid.getResolution(urlTileCoord[0]);
|
||||
const sourceZ = sourceTileGrid.getZForResolution(resolution);
|
||||
const isInterimTile = this.isInterimTile;
|
||||
let loadCount = 0;
|
||||
sourceTileGrid.forEachTileCoord(extent, sourceZ, function(sourceTileCoord) {
|
||||
let sharedExtent = getIntersection(extent,
|
||||
sourceTileGrid.getTileCoordExtent(sourceTileCoord));
|
||||
@@ -131,10 +121,9 @@ class VectorImageTile extends Tile {
|
||||
if (getWidth(sharedExtent) / resolution >= 0.5 &&
|
||||
getHeight(sharedExtent) / resolution >= 0.5) {
|
||||
// only include source tile if overlap is at least 1 pixel
|
||||
++loadCount;
|
||||
const sourceTileKey = sourceTileCoord.toString();
|
||||
let sourceTile = sourceTiles[sourceTileKey];
|
||||
if (!sourceTile && !isInterimTile) {
|
||||
if (!sourceTile) {
|
||||
const tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection);
|
||||
sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord,
|
||||
tileUrl == undefined ? TileState.EMPTY : TileState.IDLE,
|
||||
@@ -143,64 +132,19 @@ class VectorImageTile extends Tile {
|
||||
this.sourceTileListenerKeys_.push(
|
||||
listen(sourceTile, EventType.CHANGE, handleTileChange));
|
||||
}
|
||||
if (sourceTile && (!isInterimTile || sourceTile.getState() == TileState.LOADED)) {
|
||||
sourceTile.consumers++;
|
||||
this.tileKeys.push(sourceTileKey);
|
||||
}
|
||||
sourceTile.consumers++;
|
||||
this.tileKeys.push(sourceTileKey);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
if (isInterimTile && loadCount == this.tileKeys.length) {
|
||||
this.finishLoading_();
|
||||
}
|
||||
|
||||
this.createInterimTile_ = function(layerId) {
|
||||
if (this.getState() !== TileState.LOADED && !isInterimTile) {
|
||||
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) {
|
||||
const lowResExecutorGroup = sourceTile.getLowResExecutorGroup(layerId, zoom, extent);
|
||||
if (lowResExecutorGroup) {
|
||||
// reuse existing replay if we're rendering an interim tile
|
||||
sourceTile.setExecutorGroup(layerId, this.tileCoord.toString(), lowResExecutorGroup);
|
||||
bestZoom = sourceTileCoord[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bestZoom !== -1) {
|
||||
this.interimTile = new VectorImageTile(tileCoord, state, sourceRevision,
|
||||
format, tileLoadFunction, urlTileCoord, tileUrlFunction,
|
||||
sourceTileGrid, tileGrid, sourceTiles, pixelRatio, projection,
|
||||
tileClass, VOID, bestZoom);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getInterimTile(layer) {
|
||||
if (!this.interimTile) {
|
||||
this.createInterimTile_(getUid(layer));
|
||||
}
|
||||
return super.getInterimTile(layer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
disposeInternal() {
|
||||
delete this.createInterimTile_;
|
||||
this.state = TileState.ABORT;
|
||||
this.changed();
|
||||
if (this.interimTile) {
|
||||
this.interimTile.dispose();
|
||||
}
|
||||
|
||||
for (let i = 0, ii = this.tileKeys.length; i < ii; ++i) {
|
||||
const sourceTileKey = this.tileKeys[i];
|
||||
|
||||
@@ -100,7 +100,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
||||
}
|
||||
}
|
||||
if (!this.isDrawableTile_(tile)) {
|
||||
tile = tile.getInterimTile(tileLayer);
|
||||
tile = tile.getInterimTile();
|
||||
}
|
||||
return tile;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,6 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
||||
*/
|
||||
createExecutorGroup_(tile, pixelRatio, projection) {
|
||||
const layer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer());
|
||||
const layerId = getUid(layer);
|
||||
const revision = layer.getRevision();
|
||||
const renderOrder = /** @type {import("../../render.js").OrderFunction} */ (layer.getRenderOrder()) || null;
|
||||
|
||||
@@ -217,13 +216,6 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
||||
if (sourceTile.getState() != TileState.LOADED) {
|
||||
continue;
|
||||
}
|
||||
if (tile.isInterimTile) {
|
||||
// reuse existing replay if we're rendering an interim tile
|
||||
sourceTile.setExecutorGroup(layerId, tile.tileCoord.toString(),
|
||||
sourceTile.getLowResExecutorGroup(layerId, zoom, tileExtent));
|
||||
continue;
|
||||
}
|
||||
|
||||
const sourceTileCoord = sourceTile.tileCoord;
|
||||
const sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
|
||||
const sharedExtent = getIntersection(tileExtent, sourceTileExtent);
|
||||
|
||||
@@ -171,7 +171,7 @@ class VectorTile extends UrlTile {
|
||||
this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction,
|
||||
this.tileGrid, this.getTileGridForProjection(projection),
|
||||
this.sourceTiles_, pixelRatio, projection, this.tileClass,
|
||||
this.handleTileChange.bind(this), tileCoord[0]);
|
||||
this.handleTileChange.bind(this));
|
||||
|
||||
this.tileCache.set(tileCoordKey, tile);
|
||||
return tile;
|
||||
|
||||
@@ -244,8 +244,8 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
||||
};
|
||||
const tileUrlFunction = function() {};
|
||||
const tile = new VectorImageTile([0, 0, 0], undefined, undefined, undefined,
|
||||
undefined, [0, 0, 0], tileUrlFunction, createXYZ(), createXYZ(), {}, undefined,
|
||||
undefined, VectorTile, undefined, 0);
|
||||
undefined, [0, 0, 0], undefined, createXYZ(), createXYZ(), undefined, undefined,
|
||||
undefined, undefined, undefined);
|
||||
tile.transition_ = 0;
|
||||
tile.wrappedTileCoord = [0, 0, 0];
|
||||
tile.setState(TileState.LOADED);
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('ol.VectorImageTile', function() {
|
||||
defaultLoadFunction, [0, 0, 0], function() {
|
||||
return url;
|
||||
}, createXYZ(), createXYZ(), {},
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {});
|
||||
|
||||
tile.load();
|
||||
const sourceTile = tile.getTile(tile.tileKeys[0]);
|
||||
@@ -41,7 +41,7 @@ describe('ol.VectorImageTile', function() {
|
||||
}, [0, 0, 0], function() {
|
||||
return url;
|
||||
}, createXYZ(), createXYZ(), {},
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {});
|
||||
|
||||
tile.load();
|
||||
let calls = 0;
|
||||
@@ -65,7 +65,7 @@ describe('ol.VectorImageTile', function() {
|
||||
defaultLoadFunction, [0, 0, 0], function() {
|
||||
return url;
|
||||
}, createXYZ(), createXYZ(), {},
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {});
|
||||
|
||||
tile.load();
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('ol.VectorImageTile', function() {
|
||||
const tile = new VectorImageTile([0, 0, 0], 0, url, format,
|
||||
defaultLoadFunction, [0, 0, 0], function() {},
|
||||
createXYZ(), createXYZ(), {},
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {});
|
||||
|
||||
tile.load();
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('ol.VectorImageTile', function() {
|
||||
return url;
|
||||
}, tileGrid,
|
||||
createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}),
|
||||
sourceTiles, 1, getProjection('EPSG:4326'), VectorTile, function() {}, 1);
|
||||
sourceTiles, 1, getProjection('EPSG:4326'), VectorTile, function() {});
|
||||
tile.load();
|
||||
expect(tile.tileKeys.length).to.be(1);
|
||||
expect(tile.getTile(tile.tileKeys[0]).tileCoord).to.eql([0, 16, 9]);
|
||||
@@ -118,7 +118,7 @@ describe('ol.VectorImageTile', function() {
|
||||
defaultLoadFunction, [0, 0, 0], function() {
|
||||
return url;
|
||||
}, createXYZ(), createXYZ({tileSize: 512}), {},
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {});
|
||||
|
||||
tile.load();
|
||||
expect(tile.loadListenerKeys_.length).to.be(4);
|
||||
@@ -138,7 +138,7 @@ describe('ol.VectorImageTile', function() {
|
||||
defaultLoadFunction, [0, 0, 0], function() {
|
||||
return url;
|
||||
}, createXYZ(), createXYZ({tileSize: 512}), {},
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0);
|
||||
1, getProjection('EPSG:3857'), VectorTile, function() {});
|
||||
|
||||
tile.load();
|
||||
listenOnce(tile, 'change', function() {
|
||||
|
||||
Reference in New Issue
Block a user