Lazily create interim tiles (fixes most tests)
This commit is contained in:
@@ -103,8 +103,6 @@ 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}
|
||||||
@@ -150,7 +148,8 @@ class VectorImageTile extends Tile {
|
|||||||
this.finishLoading_();
|
this.finishLoading_();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.sourceTilesLoaded && !useLoadedOnly) {
|
this.createInterimTile_ = function() {
|
||||||
|
if (this.getState() !== TileState.LOADED && !useLoadedOnly) {
|
||||||
let bestZoom = -1;
|
let bestZoom = -1;
|
||||||
for (const key in sourceTiles) {
|
for (const key in sourceTiles) {
|
||||||
const sourceTile = sourceTiles[key];
|
const sourceTile = sourceTiles[key];
|
||||||
@@ -171,14 +170,22 @@ class VectorImageTile extends Tile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getInterimTile() {
|
||||||
|
if (!this.interimTile) {
|
||||||
|
this.createInterimTile_();
|
||||||
|
}
|
||||||
|
return super.getInterimTile();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
disposeInternal() {
|
disposeInternal() {
|
||||||
this.getInterimTile = super.getInterimTile;
|
delete this.createInterimTile_;
|
||||||
this.state = TileState.ABORT;
|
this.state = TileState.ABORT;
|
||||||
this.changed();
|
this.changed();
|
||||||
if (this.interimTile) {
|
if (this.interimTile) {
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
|||||||
tileGrid: createXYZ()
|
tileGrid: createXYZ()
|
||||||
});
|
});
|
||||||
source.getTile = function() {
|
source.getTile = function() {
|
||||||
|
arguments[1] = TileState.LOADED;
|
||||||
const tile = VectorTileSource.prototype.getTile.apply(source, arguments);
|
const tile = VectorTileSource.prototype.getTile.apply(source, arguments);
|
||||||
tile.setState(TileState.LOADED);
|
tile.setState(TileState.LOADED);
|
||||||
return tile;
|
return tile;
|
||||||
@@ -106,7 +107,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
|||||||
map.removeLayer(layer);
|
map.removeLayer(layer);
|
||||||
map.addLayer(testLayer);
|
map.addLayer(testLayer);
|
||||||
const spy = sinon.spy(CanvasVectorTileLayerRenderer.prototype,
|
const spy = sinon.spy(CanvasVectorTileLayerRenderer.prototype,
|
||||||
'getTransform');
|
'getRenderTransform');
|
||||||
map.renderSync();
|
map.renderSync();
|
||||||
expect(spy.callCount).to.be(0);
|
expect(spy.callCount).to.be(0);
|
||||||
spy.restore();
|
spy.restore();
|
||||||
@@ -114,7 +115,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
|||||||
|
|
||||||
it('renders both replays and images for hybrid rendering', function() {
|
it('renders both replays and images for hybrid rendering', function() {
|
||||||
const spy1 = sinon.spy(CanvasVectorTileLayerRenderer.prototype,
|
const spy1 = sinon.spy(CanvasVectorTileLayerRenderer.prototype,
|
||||||
'getTransform');
|
'getRenderTransform');
|
||||||
const spy2 = sinon.spy(CanvasVectorTileLayerRenderer.prototype,
|
const spy2 = sinon.spy(CanvasVectorTileLayerRenderer.prototype,
|
||||||
'renderTileImage_');
|
'renderTileImage_');
|
||||||
map.renderSync();
|
map.renderSync();
|
||||||
@@ -129,7 +130,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
|||||||
renderer: function() {}
|
renderer: function() {}
|
||||||
}));
|
}));
|
||||||
const spy = sinon.spy(CanvasVectorTileLayerRenderer.prototype,
|
const spy = sinon.spy(CanvasVectorTileLayerRenderer.prototype,
|
||||||
'getTransform');
|
'getRenderTransform');
|
||||||
map.renderSync();
|
map.renderSync();
|
||||||
expect(spy.callCount).to.be(1);
|
expect(spy.callCount).to.be(1);
|
||||||
spy.restore();
|
spy.restore();
|
||||||
|
|||||||
Reference in New Issue
Block a user