From d06d00ccbbab953fe08955dd2cf40c9378b14ed9 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 21 Feb 2019 01:29:15 +0100 Subject: [PATCH 1/2] Fix typo --- src/ol/source/Tile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/source/Tile.js b/src/ol/source/Tile.js index 9ea34b0ea7..76810a610f 100644 --- a/src/ol/source/Tile.js +++ b/src/ol/source/Tile.js @@ -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]); From 4166c80c6eb339a1ca572dc7a7e2a17ee97d1bd4 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 21 Feb 2019 01:35:40 +0100 Subject: [PATCH 2/2] Test cache size --- test/spec/ol/source/tile.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/spec/ol/source/tile.test.js b/test/spec/ol/source/tile.test.js index 4f408af41e..f92cb9106b 100644 --- a/test/spec/ol/source/tile.test.js +++ b/test/spec/ol/source/tile.test.js @@ -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({