UNPKG

s2tiles

Version:

S2Tiles is a single-file archive format for tiled data that works for both WM and S2 projections. The goal is to be a "cloud optimized tile store" for vector/raster/grid data.

137 lines 5.28 kB
import type { Face, Metadata } from 's2-tilejson'; /** * Enum representing a compression algorithm used. * 0 = unknown compression, for if you must use a different or unspecified algorithm. * 1 = no compression. * 2 = gzip * 3 = brotli * 4 = zstd */ export declare const Compression: { /** Unknown compression, for if you must use a different or unspecified algorithm. */ readonly Unknown: 0; /** No compression. */ readonly None: 1; /** Gzip compression. */ readonly Gzip: 2; /** Brotli compression. */ readonly Brotli: 3; /** Zstd compression. */ readonly Zstd: 4; }; /** * Enum representing a compression algorithm used. * 0 = unknown compression, for if you must use a different or unspecified algorithm. * 1 = no compression. * 2 = gzip * 3 = brotli * 4 = zstd */ export type Compression = (typeof Compression)[keyof typeof Compression]; /** * # S2 Tiles Reader * * Reads & Writes data via the [S2Tiles specification](https://github.com/Open-S2/s2tiles/blob/master/s2tiles-spec/1.0.0/README.md). */ export declare class S2TilesStore { #private; readonly path: string; file: number; offset: number; maxzoom: number; version: number; compression: Compression; metadata?: Metadata; decoder: TextDecoder; encoder: TextEncoder; /** * @param path - the location of the S2Tiles data * @param maxzoom - set the maxzoom if you're writing * @param compression - set the compression algorithm if you're writing */ constructor(path: string, maxzoom?: number, compression?: Compression); /** * 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>; /** * Write a tile to the S2Tiles file given its (z, x, y) coordinates. * @param zoom - the zoom level * @param x - the tile X coordinate * @param y - the tile Y coordinate * @param data - the tile data to store */ writeTileWM(zoom: number, x: number, y: number, data: Uint8Array): Promise<void>; /** * Write a tile to the S2Tiles file given its (face, zoom, x, y) coordinates. * @param face - the Open S2 projection face * @param zoom - the zoom level * @param x - the tile X coordinate * @param y - the tile Y coordinate * @param data - the tile data to store */ writeTileS2(face: Face, zoom: number, x: number, y: number, data: Uint8Array): Promise<void>; /** * Finish writing by building the header with root and leaf directories * @param metadata - the metadata to store * @param tileCompression - the compression algorithm that was used on the tiles [Default: None] */ commit(metadata: Metadata, tileCompression?: Compression): Promise<void>; /** * Write a tile to the S2Tiles file given its (face, zoom, x, y) coordinates. * @param face - the Open S2 projection face * @param zoom - the zoom level * @param x - the tile X coordinate * @param y - the tile Y coordinate * @param data - the tile data to store */ putTile(face: Face, zoom: number, x: number, y: number, data: Uint8Array): Promise<void>; } /** * 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