mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 02:41:09 +00:00
formatting, short-circuit getZxy based on header minzoom/maxzoom
This commit is contained in:
9
js/v3.ts
9
js/v3.ts
@@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user