Merge pull request #9251 from ahocevar/cache-size
Fix cache size calculation
This commit is contained in:
@@ -75,7 +75,7 @@ class TileSource extends Source {
|
|||||||
if (tileGrid) {
|
if (tileGrid) {
|
||||||
toSize(tileGrid.getTileSize(tileGrid.getMinZoom()), tileSize);
|
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 width = canUseScreen ? (screen.availWidth || screen.width) : 1920;
|
||||||
const height = canUseScreen ? (screen.availHeight || screen.height) : 1080;
|
const height = canUseScreen ? (screen.availHeight || screen.height) : 1080;
|
||||||
cacheSize = 4 * Math.ceil(width / tileSize[0]) * Math.ceil(height / tileSize[1]);
|
cacheSize = 4 * Math.ceil(width / tileSize[0]) * Math.ceil(height / tileSize[1]);
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ describe('ol.source.Tile', function() {
|
|||||||
expect(source).to.be.a(Source);
|
expect(source).to.be.a(Source);
|
||||||
expect(source).to.be.a(TileSource);
|
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() {
|
it('sets a custom cache size', function() {
|
||||||
const projection = getProjection('EPSG:4326');
|
const projection = getProjection('EPSG:4326');
|
||||||
const source = new TileSource({
|
const source = new TileSource({
|
||||||
|
|||||||
Reference in New Issue
Block a user