Remove interim tile handling for now

This commit is contained in:
ahocevar
2018-11-21 06:06:33 +01:00
parent 43759fd846
commit 82e2a84862
7 changed files with 18 additions and 83 deletions

View File

@@ -146,10 +146,9 @@ class Tile extends EventTarget {
* Get the interim tile most suitable for rendering using the chain of interim * 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 * tiles. This corresponds to the most recent tile that has been loaded, if no
* such tile exists, the original tile is returned. * such tile exists, the original tile is returned.
* @param {import("./layer/Layer").default} layer Layer.
* @return {!Tile} Best tile for rendering. * @return {!Tile} Best tile for rendering.
*/ */
getInterimTile(layer) { getInterimTile() {
if (!this.interimTile) { if (!this.interimTile) {
//empty chain //empty chain
return this; return this;

View File

@@ -6,10 +6,9 @@ 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 {containsExtent, getHeight, getIntersection, getWidth} from './extent.js'; import {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';
/** /**
@@ -40,11 +39,10 @@ class VectorImageTile extends Tile {
* instantiate for source tiles. * instantiate for source tiles.
* @param {function(this: import("./source/VectorTile.js").default, import("./events/Event.js").default)} handleTileChange * @param {function(this: import("./source/VectorTile.js").default, import("./events/Event.js").default)} handleTileChange
* Function to call when a source tile's state changes. * 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, constructor(tileCoord, state, sourceRevision, format, tileLoadFunction,
urlTileCoord, tileUrlFunction, sourceTileGrid, tileGrid, sourceTiles, urlTileCoord, tileUrlFunction, sourceTileGrid, tileGrid, sourceTiles,
pixelRatio, projection, tileClass, handleTileChange, zoom) { pixelRatio, projection, tileClass, handleTileChange) {
super(tileCoord, state, {transition: 0}); super(tileCoord, state, {transition: 0});
@@ -109,18 +107,10 @@ class VectorImageTile extends Tile {
*/ */
this.sourceTileListenerKeys_ = []; this.sourceTileListenerKeys_ = [];
/**
* Use only source tiles that are loaded already
* @type {boolean}
*/
this.isInterimTile = zoom != tileCoord[0];
if (urlTileCoord) { if (urlTileCoord) {
const extent = this.extent = tileGrid.getTileCoordExtent(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 sourceZ = sourceTileGrid.getZForResolution(resolution);
const isInterimTile = this.isInterimTile;
let loadCount = 0;
sourceTileGrid.forEachTileCoord(extent, sourceZ, function(sourceTileCoord) { sourceTileGrid.forEachTileCoord(extent, sourceZ, function(sourceTileCoord) {
let sharedExtent = getIntersection(extent, let sharedExtent = getIntersection(extent,
sourceTileGrid.getTileCoordExtent(sourceTileCoord)); sourceTileGrid.getTileCoordExtent(sourceTileCoord));
@@ -131,10 +121,9 @@ class VectorImageTile extends Tile {
if (getWidth(sharedExtent) / resolution >= 0.5 && if (getWidth(sharedExtent) / resolution >= 0.5 &&
getHeight(sharedExtent) / resolution >= 0.5) { getHeight(sharedExtent) / resolution >= 0.5) {
// only include source tile if overlap is at least 1 pixel // only include source tile if overlap is at least 1 pixel
++loadCount;
const sourceTileKey = sourceTileCoord.toString(); const sourceTileKey = sourceTileCoord.toString();
let sourceTile = sourceTiles[sourceTileKey]; let sourceTile = sourceTiles[sourceTileKey];
if (!sourceTile && !isInterimTile) { if (!sourceTile) {
const tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection); const tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection);
sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord, sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord,
tileUrl == undefined ? TileState.EMPTY : TileState.IDLE, tileUrl == undefined ? TileState.EMPTY : TileState.IDLE,
@@ -143,64 +132,19 @@ class VectorImageTile extends Tile {
this.sourceTileListenerKeys_.push( this.sourceTileListenerKeys_.push(
listen(sourceTile, EventType.CHANGE, handleTileChange)); listen(sourceTile, EventType.CHANGE, handleTileChange));
} }
if (sourceTile && (!isInterimTile || sourceTile.getState() == TileState.LOADED)) {
sourceTile.consumers++; sourceTile.consumers++;
this.tileKeys.push(sourceTileKey); this.tileKeys.push(sourceTileKey);
} }
}
}.bind(this)); }.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 * @inheritDoc
*/ */
disposeInternal() { disposeInternal() {
delete this.createInterimTile_;
this.state = TileState.ABORT; this.state = TileState.ABORT;
this.changed(); this.changed();
if (this.interimTile) {
this.interimTile.dispose();
}
for (let i = 0, ii = this.tileKeys.length; i < ii; ++i) { for (let i = 0, ii = this.tileKeys.length; i < ii; ++i) {
const sourceTileKey = this.tileKeys[i]; const sourceTileKey = this.tileKeys[i];

View File

@@ -100,7 +100,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
} }
} }
if (!this.isDrawableTile_(tile)) { if (!this.isDrawableTile_(tile)) {
tile = tile.getInterimTile(tileLayer); tile = tile.getInterimTile();
} }
return tile; return tile;
} }

View File

@@ -195,7 +195,6 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
*/ */
createExecutorGroup_(tile, pixelRatio, projection) { createExecutorGroup_(tile, pixelRatio, projection) {
const layer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer()); const layer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer());
const layerId = getUid(layer);
const revision = layer.getRevision(); const revision = layer.getRevision();
const renderOrder = /** @type {import("../../render.js").OrderFunction} */ (layer.getRenderOrder()) || null; const renderOrder = /** @type {import("../../render.js").OrderFunction} */ (layer.getRenderOrder()) || null;
@@ -217,13 +216,6 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
if (sourceTile.getState() != TileState.LOADED) { if (sourceTile.getState() != TileState.LOADED) {
continue; 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 sourceTileCoord = sourceTile.tileCoord;
const sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord); const sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
const sharedExtent = getIntersection(tileExtent, sourceTileExtent); const sharedExtent = getIntersection(tileExtent, sourceTileExtent);

View File

@@ -171,7 +171,7 @@ class VectorTile extends UrlTile {
this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction, this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction,
this.tileGrid, this.getTileGridForProjection(projection), this.tileGrid, this.getTileGridForProjection(projection),
this.sourceTiles_, pixelRatio, projection, this.tileClass, this.sourceTiles_, pixelRatio, projection, this.tileClass,
this.handleTileChange.bind(this), tileCoord[0]); this.handleTileChange.bind(this));
this.tileCache.set(tileCoordKey, tile); this.tileCache.set(tileCoordKey, tile);
return tile; return tile;

View File

@@ -244,8 +244,8 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
}; };
const tileUrlFunction = function() {}; const tileUrlFunction = function() {};
const tile = new VectorImageTile([0, 0, 0], undefined, undefined, undefined, const tile = new VectorImageTile([0, 0, 0], undefined, undefined, undefined,
undefined, [0, 0, 0], tileUrlFunction, createXYZ(), createXYZ(), {}, undefined, undefined, [0, 0, 0], undefined, createXYZ(), createXYZ(), undefined, undefined,
undefined, VectorTile, undefined, 0); undefined, undefined, undefined);
tile.transition_ = 0; tile.transition_ = 0;
tile.wrappedTileCoord = [0, 0, 0]; tile.wrappedTileCoord = [0, 0, 0];
tile.setState(TileState.LOADED); tile.setState(TileState.LOADED);

View File

@@ -17,7 +17,7 @@ describe('ol.VectorImageTile', function() {
defaultLoadFunction, [0, 0, 0], function() { defaultLoadFunction, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ(), {}, }, createXYZ(), createXYZ(), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
const sourceTile = tile.getTile(tile.tileKeys[0]); const sourceTile = tile.getTile(tile.tileKeys[0]);
@@ -41,7 +41,7 @@ describe('ol.VectorImageTile', function() {
}, [0, 0, 0], function() { }, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ(), {}, }, createXYZ(), createXYZ(), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
let calls = 0; let calls = 0;
@@ -65,7 +65,7 @@ describe('ol.VectorImageTile', function() {
defaultLoadFunction, [0, 0, 0], function() { defaultLoadFunction, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ(), {}, }, createXYZ(), createXYZ(), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
@@ -81,7 +81,7 @@ describe('ol.VectorImageTile', function() {
const tile = new VectorImageTile([0, 0, 0], 0, url, format, const tile = new VectorImageTile([0, 0, 0], 0, url, format,
defaultLoadFunction, [0, 0, 0], function() {}, defaultLoadFunction, [0, 0, 0], function() {},
createXYZ(), createXYZ(), {}, createXYZ(), createXYZ(), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
@@ -105,7 +105,7 @@ describe('ol.VectorImageTile', function() {
return url; return url;
}, tileGrid, }, tileGrid,
createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}), 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(); tile.load();
expect(tile.tileKeys.length).to.be(1); expect(tile.tileKeys.length).to.be(1);
expect(tile.getTile(tile.tileKeys[0]).tileCoord).to.eql([0, 16, 9]); 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() { defaultLoadFunction, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ({tileSize: 512}), {}, }, createXYZ(), createXYZ({tileSize: 512}), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
expect(tile.loadListenerKeys_.length).to.be(4); expect(tile.loadListenerKeys_.length).to.be(4);
@@ -138,7 +138,7 @@ describe('ol.VectorImageTile', function() {
defaultLoadFunction, [0, 0, 0], function() { defaultLoadFunction, [0, 0, 0], function() {
return url; return url;
}, createXYZ(), createXYZ({tileSize: 512}), {}, }, createXYZ(), createXYZ({tileSize: 512}), {},
1, getProjection('EPSG:3857'), VectorTile, function() {}, 0); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
listenOnce(tile, 'change', function() { listenOnce(tile, 'change', function() {