diff --git a/src/ol/Tile.js b/src/ol/Tile.js index 91c4ca3f69..f7a9dc0e78 100644 --- a/src/ol/Tile.js +++ b/src/ol/Tile.js @@ -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; diff --git a/src/ol/VectorImageTile.js b/src/ol/VectorImageTile.js index 829d7734d3..85ad648f50 100644 --- a/src/ol/VectorImageTile.js +++ b/src/ol/VectorImageTile.js @@ -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]; diff --git a/src/ol/renderer/canvas/TileLayer.js b/src/ol/renderer/canvas/TileLayer.js index eca296b5c8..ef9b0059a6 100644 --- a/src/ol/renderer/canvas/TileLayer.js +++ b/src/ol/renderer/canvas/TileLayer.js @@ -100,7 +100,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer { } } if (!this.isDrawableTile_(tile)) { - tile = tile.getInterimTile(tileLayer); + tile = tile.getInterimTile(); } return tile; } diff --git a/src/ol/renderer/canvas/VectorTileLayer.js b/src/ol/renderer/canvas/VectorTileLayer.js index 029403edf3..5331a24fd7 100644 --- a/src/ol/renderer/canvas/VectorTileLayer.js +++ b/src/ol/renderer/canvas/VectorTileLayer.js @@ -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); diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 63a266215a..5be126a92f 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -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; diff --git a/test/spec/ol/renderer/canvas/vectortilelayer.test.js b/test/spec/ol/renderer/canvas/vectortilelayer.test.js index 2dd459d0ca..6801a21231 100644 --- a/test/spec/ol/renderer/canvas/vectortilelayer.test.js +++ b/test/spec/ol/renderer/canvas/vectortilelayer.test.js @@ -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); diff --git a/test/spec/ol/vectorimagetile.test.js b/test/spec/ol/vectorimagetile.test.js index e5f7809f68..63a1073b4b 100644 --- a/test/spec/ol/vectorimagetile.test.js +++ b/test/spec/ol/vectorimagetile.test.js @@ -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() {