Avoid stuck maps when resolving views from a GeoTIFF

This commit is contained in:
Tim Schaub
2022-08-28 10:17:26 -05:00
parent 1dc8a18362
commit 02cf27149a
7 changed files with 15 additions and 8 deletions

View File

@@ -667,12 +667,11 @@ class GeoTIFFSource extends DataTile {
}
}
const additionalBands = this.addAlpha_ ? 1 : 0;
this.bandCount =
samplesPerPixel.reduce((accumulator, value) => {
accumulator += value;
return accumulator;
}, 0) + additionalBands;
let bandCount = this.addAlpha_ ? 1 : 0;
for (let sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) {
bandCount += samplesPerPixel[sourceIndex];
}
this.bandCount = bandCount;
const tileGrid = new TileGrid({
extent: extent,
@@ -687,12 +686,19 @@ class GeoTIFFSource extends DataTile {
this.setLoader(this.loadTile_.bind(this));
this.setState('ready');
let zoom = 0;
if (resolutions.length === 1) {
resolutions = [resolutions[0] * 2, resolutions[0]];
zoom = 1;
}
this.viewResolver({
showFullExtent: true,
projection: this.projection,
resolutions: resolutions,
center: toUserCoordinate(getCenter(extent), this.projection),
extent: toUserExtent(extent, this.projection),
zoom: 0,
zoom: zoom,
});
}

View File

@@ -140,7 +140,8 @@ describe('ol/source/GeoTIFF', function () {
expect(projection.getUnits()).to.be('degrees');
expect(viewOptions.extent).to.eql([-180, -90, 180, 90]);
expect(viewOptions.center).to.eql([0, 0]);
expect(viewOptions.resolutions).to.eql([0.703125]);
expect(viewOptions.resolutions).to.eql([1.40625, 0.703125]);
expect(viewOptions.showFullExtent).to.be(true);
done();
});
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 85 KiB