Merge pull request #9251 from ahocevar/cache-size

Fix cache size calculation
This commit is contained in:
Andreas Hocevar
2019-02-21 01:57:40 +01:00
committed by GitHub
2 changed files with 5 additions and 1 deletions

View File

@@ -75,7 +75,7 @@ class TileSource extends Source {
if (tileGrid) {
toSize(tileGrid.getTileSize(tileGrid.getMinZoom()), tileSize);
}
const canUseScreen = 'screen ' in self;
const canUseScreen = 'screen' in self;
const width = canUseScreen ? (screen.availWidth || screen.width) : 1920;
const height = canUseScreen ? (screen.availHeight || screen.height) : 1080;
cacheSize = 4 * Math.ceil(width / tileSize[0]) * Math.ceil(height / tileSize[1]);

View File

@@ -59,6 +59,10 @@ describe('ol.source.Tile', function() {
expect(source).to.be.a(Source);
expect(source).to.be.a(TileSource);
});
it('sets a screen dependent cache size', function() {
const source = new TileSource({});
expect(source.tileCache.highWaterMark).to.be(4 * Math.ceil(screen.availWidth / 256) * Math.ceil(screen.availHeight / 256));
});
it('sets a custom cache size', function() {
const projection = getProjection('EPSG:4326');
const source = new TileSource({