Simpler and faster VectorTile loading

This commit is contained in:
Andreas Hocevar
2021-05-30 21:22:03 +02:00
parent 04e323d69e
commit 5ab7cbf905
7 changed files with 98 additions and 188 deletions

View File

@@ -305,7 +305,7 @@ describe('ol.source.VectorTile', function () {
let count = 0;
let tile = source.getTile(0, 0, 0, 1, map.getView().getProjection());
tile.addEventListener('change', function onTileChange(e) {
if (e.target.getState() !== TileState.LOADED && !e.target.hifi) {
if (e.target.getState() !== TileState.LOADED) {
return;
}
e.target.removeEventListener('change', onTileChange);

View File

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