@loaders.gl/pmtiles
Version:
Framework-independent loader for the pmtiles format
32 lines (31 loc) • 962 B
JavaScript
// loaders.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
/**
* A PMTiles library compatible source that reads from blobs
* @deprecated TODO - reimplement as ReadableFileSource
* Use loaders.gl HTTP range requests instead
*/
export class BlobSource {
blob;
key;
constructor(blob, key) {
this.blob = blob;
this.key = key;
}
// TODO - how is this used?
getKey() {
// @ts-expect-error url is only defined on File subclass
return this.blob.url || '';
}
async getBytes(offset, length, signal) {
const slice = this.blob.slice(offset, offset + length);
const data = await slice.arrayBuffer();
return {
data
// etag: response.headers.get('ETag') || undefined,
// cacheControl: response.headers.get('Cache-Control') || undefined,
// expires: response.headers.get('Expires') || undefined
};
}
}