No ERROR state for render tiles

This commit is contained in:
Andreas Hocevar
2019-10-10 14:46:27 +02:00
parent 9acba8f82a
commit 0cb9d73848
2 changed files with 10 additions and 7 deletions

View File

@@ -12,7 +12,6 @@ import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid.
import {buffer as bufferExtent, getIntersection, intersects} from '../extent.js'; import {buffer as bufferExtent, getIntersection, intersects} 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 {isEmpty} from '../obj.js';
import {equals} from '../array.js'; import {equals} from '../array.js';
/** /**
@@ -252,10 +251,11 @@ class VectorTile extends UrlTile {
} else if (state === TileState.ERROR) { } else if (state === TileState.ERROR) {
tile.errorSourceTileKeys[sourceTileKey] = true; tile.errorSourceTileKeys[sourceTileKey] = true;
} }
if (tile.loadingSourceTiles - Object.keys(tile.errorSourceTileKeys).length === 0) { const errorTileCount = Object.keys(tile.errorSourceTileKeys).length;
tile.hifi = true; if (tile.loadingSourceTiles - errorTileCount === 0) {
tile.hifi = errorTileCount === 0;
tile.sourceZ = sourceZ; tile.sourceZ = sourceZ;
tile.setState(isEmpty(tile.errorSourceTileKeys) ? TileState.LOADED : TileState.ERROR); tile.setState(TileState.LOADED);
} }
} }
}; };

View File

@@ -27,9 +27,11 @@ describe('ol.VectorRenderTile', function() {
listen(tile, 'change', function(e) { listen(tile, 'change', function(e) {
++calls; ++calls;
if (calls === 1) { if (calls === 1) {
expect(tile.getState()).to.be(TileState.ERROR); expect(tile.getState()).to.be(TileState.LOADED);
expect(tile.hifi).to.be(false);
setTimeout(function() { setTimeout(function() {
sourceTile.setState(TileState.LOADED); sourceTile.setState(TileState.LOADED);
expect(tile.hifi).to.be(true);
}, 0); }, 0);
} else if (calls === 2) { } else if (calls === 2) {
done(); done();
@@ -37,7 +39,7 @@ describe('ol.VectorRenderTile', function() {
}); });
}); });
it('sets ERROR state when source tiles fail to load', function(done) { it('sets LOADED state and hifi==false when source tiles fail to load', function(done) {
const source = new VectorTileSource({ const source = new VectorTileSource({
format: new GeoJSON(), format: new GeoJSON(),
url: 'spec/ol/data/unavailable.json' url: 'spec/ol/data/unavailable.json'
@@ -47,7 +49,8 @@ describe('ol.VectorRenderTile', function() {
tile.load(); tile.load();
listen(tile, 'change', function(e) { listen(tile, 'change', function(e) {
expect(tile.getState()).to.be(TileState.ERROR); expect(tile.getState()).to.be(TileState.LOADED);
expect(tile.hifi).to.be(false);
done(); done();
}); });
}); });