Grow cache size dynamically

This commit is contained in:
Andreas Hocevar
2020-07-11 11:30:01 +02:00
parent 5cd102af10
commit 0167c2760e
15 changed files with 40 additions and 21 deletions

View File

@@ -27,7 +27,7 @@ import {toSize} from '../size.js';
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize=128] Cache size.
* @property {number} [cacheSize] Initial tile cache size. Will auto-grow to hold at least twice the number of tiles in the viewport.
* @property {import("../extent.js").Extent} [extent]
* @property {import("../format/Feature.js").default} [format] Feature format for tiles. Used and required by the default.
* @property {boolean} [overlaps=true] This source may have overlapping geometries. Setting this
@@ -509,6 +509,15 @@ class VectorTile extends UrlTile {
Math.round(tileSize[1] * pixelRatio),
];
}
/**
* Increases the cache size if needed
* @param {number} tileCount Minimum number of tiles needed.
* @param {import("../proj/Projection.js").default} projection Projection.
*/
updateCacheSize(tileCount, projection) {
super.updateCacheSize(tileCount * 2, projection);
}
}
export default VectorTile;