Skip to content

Commit

Permalink
Add information about maxCacheByteSize when not being set
Browse files Browse the repository at this point in the history
  • Loading branch information
sraimund committed Sep 13, 2024
1 parent 6501da8 commit fe866c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/api-reference/geo-layers/tile-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ If not supplied, the `maxCacheSize` is calculated as `5` times the number of til

The maximum memory used for caching tiles. If this limit is supplied, `getTileData` must return an object that contains a `byteLength` field.

If not supplied, the `maxCacheByteSize` is set to `Infinity`.

- Default: `null`


Expand Down
4 changes: 2 additions & 2 deletions modules/geo-layers/src/tileset-2d/tileset-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export class Tileset2D {
const maxCacheSize =
opts.maxCacheSize ??
// @ts-expect-error called only when selectedTiles is initialized
(opts.maxCacheByteSize ? Infinity : DEFAULT_CACHE_SCALE * this.selectedTiles.length);
(opts.maxCacheByteSize != null ? Infinity : DEFAULT_CACHE_SCALE * this.selectedTiles.length);
const maxCacheByteSize = opts.maxCacheByteSize ?? Infinity;

const overflown = _cache.size > maxCacheSize || this._cacheByteSize > maxCacheByteSize;
Expand All @@ -480,7 +480,7 @@ export class Tileset2D {
for (const [id, tile] of _cache) {
if (!tile.isVisible && !tile.isSelected) {
// delete tile
this._cacheByteSize -= opts.maxCacheByteSize ? tile.byteLength : 0;
this._cacheByteSize -= opts.maxCacheByteSize != null ? tile.byteLength : 0;
_cache.delete(id);
this.opts.onTileUnload?.(tile);
}
Expand Down

0 comments on commit fe866c2

Please sign in to comment.