formatting, short-circuit getZxy based on header minzoom/maxzoom

This commit is contained in:
Brandon Liu
2022-10-01 18:38:51 +08:00
parent 9de085be8b
commit 87bf3994d0

View File

@@ -238,7 +238,7 @@ export class FileAPISource implements Source {
async getBytes(
offset: number,
length: number,
length: number
): Promise<[ArrayBuffer, undefined]> {
const blob = this.file.slice(offset, offset + length);
const a = await blob.arrayBuffer();
@@ -471,7 +471,8 @@ export class Cache {
resolve(directory);
if (this.cache.has(cacheKey)) {
this.cache.get(cacheKey)!.size = ENTRY_SIZE_BYTES * directory.length;
this.cache.get(cacheKey)!.size =
ENTRY_SIZE_BYTES * directory.length;
this.sizeBytes += ENTRY_SIZE_BYTES * directory.length;
}
this.prune();
@@ -528,6 +529,10 @@ export class PMTiles {
const tile_id = zxyToTileId(z, x, y);
const header = await this.cache.getHeader(this.source);
if (z < header.minzoom || z > header.maxzoom) {
return undefined;
}
let d_o = header.rootDirectoryOffset;
let d_l = header.rootDirectoryLength;
for (let depth = 0; depth < 5; depth++) {