UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

108 lines 4.2 kB
import { Compression } from '../../util/index.js'; import type { Metadata } from 's2-tilejson'; import type { Face, ReaderInputs } from '../../index.js'; /** * # S2 Tiles Reader * * ## Description * * An S2 Tile Reader to store tile and metadata in a cloud optimized format. Similar to PMTiles * but simplified to have as few features as possible. * * Reads either a Web Mercator tile or an S2 tile to the folder location given its (zoom, x, y) or (face, zoom, x, y) coordinates. * * Reads data via the [S2Tiles specification](https://github.com/Open-S2/s2tiles/blob/master/s2tiles-spec/1.0.0/README.md). * * ## Usage * * ```ts * import { S2TilesReader } 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 S2TilesReader(new FileReader('./data.s2tiles')); * * // 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.hasTileWM(0, 0, 0); * const tile = await reader.getTileWM(0, 0, 0); * ``` * * ## Links * - https://github.com/Open-S2/s2tiles/blob/master/s2tiles-spec/1.0.0/README.md */ export declare class S2TilesReader { #private; readonly path: string | ReaderInputs; version: number; maxzoom: number; compression: Compression; metadata?: Metadata; decoder: TextDecoder; /** * @param path - the location of the S2Tiles 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 metadata of the archive * @returns - the metadata of the archive */ getMetadata(): Promise<Metadata>; /** Setup the reader */ setup(): Promise<void>; /** * 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 */ hasTileWM(zoom: number, x: number, y: number): Promise<boolean>; /** * 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 (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. */ getTileWM(zoom: number, x: number, y: number): Promise<Uint8Array | undefined>; /** * 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<undefined | Uint8Array>; } /** * Get the path to a tile * @param zoom - the zoom * @param x - the x * @param y - the y * @returns - The path as a collection of offsets pointing to the tile Node in the directory */ export declare function getS2TilePath(zoom: number, x: number, y: number): number[]; //# sourceMappingURL=index.d.ts.map