gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
106 lines • 4.28 kB
TypeScript
import type { Header } from './pmtiles.js';
import type { Face, Metadata } from 's2-tilejson';
import type { ReaderInputs } from '../index.js';
/** A description of where a tile can be found in the archive. Both offset and length are in bytes */
export interface S2PMTilesTileEntry {
offset: number;
length: number;
}
/**
* # (S2) PMTiles Reader
*
* ## Description
* A V3.0 PMTiles reader for reading standard WebMercator Tile data and V1.0 S2 Tile data.
*
* A Modified implementation of the PMTiles library. It is backwards compatible but
* offers support for the S2 Projection.
*
* You can learn more about the [S2PMTiles Specification here](https://github.com/Open-S2/s2-pmtiles/blob/master/s2-pmtiles-spec/1.0.0/README.md).
*
* ## Usage
* ```ts
* import { S2PMTilesReader } from 'gis-tools-ts';
* import { FileReader } from 'gis-tools-ts/file';
* // or use the MMapReader if using Bun / FetchReader for web:
* // import { MMapReader } from 'gis-tools-ts/mmap';
* // import { FetchReader } from 'gis-tools-ts';
*
* const reader = new S2PMTilesReader(new FileReader('./data.pmtiles'));
*
* // pull out the header
* const header = reader.getHeader();
*
* // get the metadata
* const metadata = await reader.getMetadata();
*
* // S2 specific functions
* const hasTile = await reader.hasTileS2(0, 0, 0, 0);
* const tile = await reader.getTileS2(0, 0, 0, 0);
*
* // WM functions
* const hasTile = await reader.hasTile(0, 0, 0);
* const tile = await reader.getTile(0, 0, 0);
* ```
*
* ## Links
* - https://github.com/Open-S2/s2-pmtiles
* - https://github.com/Open-S2/s2-pmtiles/blob/master/s2-pmtiles-spec/1.0.0/README.md
* - https://github.com/protomaps/PMTiles
* - https://github.com/protomaps/PMTiles/blob/main/spec/v3/spec.md
*/
export declare class S2PMTilesReader {
#private;
readonly path: string | ReaderInputs;
/**
* Given an input path, read in the header and root directory
* @param path - the location of the PMTiles data
* @param rangeRequests - FetchReader specific; enable range requests or use urlParam "bytes"
* @param maxSize - the max size of the cache before dumping old data. Defaults to 20.
*/
constructor(path: string | ReaderInputs, rangeRequests?: boolean, maxSize?: number);
/**
* Get the header of the archive
* @returns - the header of the archive
*/
getHeader(): Promise<Header>;
/**
* Get the metadata of the archive
* @returns - the metadata of the archive
*/
getMetadata(): Promise<Metadata>;
/**
* Check if an S2 tile exists in the archive
* @param face - the Open S2 projection face
* @param zoom - the zoom level of the tile
* @param x - the x coordinate of the tile
* @param y - the y coordinate of the tile
* @returns - true if the tile exists in the archive
*/
hasTileS2(face: Face, zoom: number, x: number, y: number): Promise<boolean>;
/**
* Get the bytes of the tile at the given (face, zoom, x, y) coordinates
* @param face - the Open S2 projection face
* @param zoom - the zoom level of the tile
* @param x - the x coordinate of the tile
* @param y - the y coordinate of the tile
* @returns - the bytes of the tile at the given (face, zoom, x, y) coordinates, or undefined if the tile does not exist in the archive.
*/
getTileS2(face: Face, zoom: number, x: number, y: number): Promise<Uint8Array | undefined>;
/**
* Check if a tile exists in the archive
* @param zoom - the zoom level of the tile
* @param x - the x coordinate of the tile
* @param y - the y coordinate of the tile
* @returns - true if the tile exists in the archive
*/
hasTile(zoom: number, x: number, y: number): Promise<boolean>;
/**
* Get the bytes of the tile at the given (zoom, x, y) coordinates
* @param zoom - the zoom level of the tile
* @param x - the x coordinate of the tile
* @param y - the y coordinate of the tile
* @returns - the bytes of the tile at the given (z, x, y) coordinates, or undefined if the tile does not exist in the archive.
*/
getTile(zoom: number, x: number, y: number): Promise<Uint8Array | undefined>;
}
//# sourceMappingURL=reader.d.ts.map