mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
rename Response > SourceData
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
|||||||
Cache,
|
Cache,
|
||||||
BufferPosition,
|
BufferPosition,
|
||||||
Source,
|
Source,
|
||||||
Response,
|
SourceData,
|
||||||
VersionMismatch,
|
VersionMismatch,
|
||||||
PMTiles,
|
PMTiles,
|
||||||
} from "./v3";
|
} from "./v3";
|
||||||
@@ -135,7 +135,7 @@ class TestNodeFileSource implements Source {
|
|||||||
async getBytes(
|
async getBytes(
|
||||||
offset: number,
|
offset: number,
|
||||||
length: number
|
length: number
|
||||||
): Promise<Response> {
|
): Promise<SourceData> {
|
||||||
const slice = new Uint8Array(this.buffer.slice(offset, offset + length))
|
const slice = new Uint8Array(this.buffer.slice(offset, offset + length))
|
||||||
.buffer;
|
.buffer;
|
||||||
return {data:slice, etag:this.etag};
|
return {data:slice, etag:this.etag};
|
||||||
|
|||||||
12
js/v3.ts
12
js/v3.ts
@@ -213,7 +213,7 @@ export function findTile(entries: Entry[], tileId: number): Entry | null {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Response {
|
export interface SourceData {
|
||||||
data: ArrayBuffer;
|
data: ArrayBuffer;
|
||||||
etag?: string;
|
etag?: string;
|
||||||
expires?: string;
|
expires?: string;
|
||||||
@@ -227,7 +227,7 @@ export interface Source {
|
|||||||
offset: number,
|
offset: number,
|
||||||
length: number,
|
length: number,
|
||||||
signal?: AbortSignal
|
signal?: AbortSignal
|
||||||
) => Promise<Response>;
|
) => Promise<SourceData>;
|
||||||
|
|
||||||
getKey: () => string;
|
getKey: () => string;
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,7 @@ export class FileAPISource implements Source {
|
|||||||
return this.file.name;
|
return this.file.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBytes(offset: number, length: number): Promise<Response> {
|
async getBytes(offset: number, length: number): Promise<SourceData> {
|
||||||
const blob = this.file.slice(offset, offset + length);
|
const blob = this.file.slice(offset, offset + length);
|
||||||
const a = await blob.arrayBuffer();
|
const a = await blob.arrayBuffer();
|
||||||
return { data: a };
|
return { data: a };
|
||||||
@@ -265,7 +265,7 @@ export class FetchSource implements Source {
|
|||||||
offset: number,
|
offset: number,
|
||||||
length: number,
|
length: number,
|
||||||
signal?: AbortSignal
|
signal?: AbortSignal
|
||||||
): Promise<Response> {
|
): Promise<SourceData> {
|
||||||
let controller;
|
let controller;
|
||||||
if (!signal) {
|
if (!signal) {
|
||||||
// TODO check this works or assert 206
|
// TODO check this works or assert 206
|
||||||
@@ -545,7 +545,7 @@ export class PMTiles {
|
|||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
signal?: AbortSignal
|
signal?: AbortSignal
|
||||||
): Promise<Response | undefined> {
|
): Promise<SourceData | undefined> {
|
||||||
const tile_id = zxyToTileId(z, x, y);
|
const tile_id = zxyToTileId(z, x, y);
|
||||||
const header = await this.cache.getHeader(this.source);
|
const header = await this.cache.getHeader(this.source);
|
||||||
|
|
||||||
@@ -594,7 +594,7 @@ export class PMTiles {
|
|||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
signal?: AbortSignal
|
signal?: AbortSignal
|
||||||
): Promise<Response | undefined> {
|
): Promise<SourceData | undefined> {
|
||||||
try {
|
try {
|
||||||
return await this.getZxyAttempt(z, x, y, signal);
|
return await this.getZxyAttempt(z, x, y, signal);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user