UNPKG

s2-tools

Version:

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

93 lines 3.9 kB
import { RasterS2TileReader, RasterTileReader } from '.'; import type { ElevationConverter, ElevationPoint, S2TileMetadata, TileMetadata } from '.'; import type { Face, FeatureIterator, Properties, RGBA, S2Feature, S2PMTilesReader, VectorFeature } from '../..'; import type { Metadata } from 's2-tilejson'; /** * # Raster Tiles File Reader * * ## Description * Read an entire archive of raster tiles, where the max zoom data is iterated upon * * Supports reading either RGB(A) data and/or RGB(A) encoded elevation data. * * ## Usage * ```ts * import { convertTerrariumElevationData } from 's2-tools'; * import { RasterTilesFileReader } from 's2-tools/file'; * * // creates a reader for a tile set treating the max zoom as 3 instead of the metadata's max zoom * const reader = new RasterTilesFileReader('./raster-tiles-top-level-folder', 3); * // example of reading in an elevation dataset * const reader2 = new RasterTilesFileReader('./terrariumData', -1, convertTerrariumElevationData); * * // grab the metadata * const metadata = await reader.getMetadata(); * * // grab a WM tile * const tile1 = await reader.getTile(0, 0, 0); * // or if it's an S2 tile spec * const tile2 = await reader.getTileS2(0, 0, 0, 0); * * // grab all the max zoom tiles: * for await (const tile of reader) { * console.log(tile); * } * ``` */ export declare class RasterTilesFileReader<T extends Properties = RGBA | ElevationPoint> implements FeatureIterator<S2TileMetadata | TileMetadata, T, Properties> { readonly input: string | S2PMTilesReader; readonly threshold: number; readonly converter?: ElevationConverter | undefined; metadata?: Metadata; /** * @param input - the file path or S2PMTilesReader to read from * @param threshold - if non-zero its the max zoom to read all tiles in the FeatureIterator * @param converter - the elevation converter */ constructor(input: string | S2PMTilesReader, threshold?: number, converter?: ElevationConverter | undefined); /** * Get the metadata of the archive * @returns - the metadata */ getMetadata(): Promise<Metadata>; /** * Grab 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 tile */ getTile(zoom: number, x: number, y: number): Promise<RasterTileReader<T> | undefined>; /** * Grab 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 tile */ getTileS2(face: Face, zoom: number, x: number, y: number): Promise<RasterS2TileReader<T> | undefined>; /** * Return true if the tile exists * @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 */ hasTile(zoom: number, x: number, y: number): Promise<boolean>; /** * Return true if the tile exists * @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 */ hasTileS2(face: Face, zoom: number, x: number, y: number): Promise<boolean>; /** * Iterate over all tiles in the archive * @yields - the each of the tile's pixel RGBA data as lon-lat or S2 s-t coordinates with the RGBA as m-values */ [Symbol.asyncIterator](): AsyncGenerator<S2Feature<S2TileMetadata, T, Properties> | VectorFeature<TileMetadata, T, Properties>>; } //# sourceMappingURL=file.d.ts.map