UNPKG

s2-tools

Version:

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

188 lines 6.58 kB
import type { ArrayTypes, Decoder, GridReader, ImageFileDirectory } from '.'; import type { ProjectionTransformDefinition } from '../../proj4'; import type { RGBA, Reader } from '..'; import type { VectorMultiPointGeometry, VectorPoint } from '../../geometry'; /** Metadata for a GeoTIFF image */ export interface GeoTIFFMetadata { height: number; width: number; alpha: boolean; } /** Result of getMultiPointVector */ export interface VectorMultiPointResult { geometry: VectorMultiPointGeometry<RGBA>; width: number; height: number; alpha: boolean; } /** Raster data */ export interface Raster { width: number; height: number; data: ArrayTypes; alpha: boolean; } /** A tiepoint structured for decoding images */ export interface TiePoint { i: number; j: number; k: number; x: number; y: number; z: number; } /** A Container for a GeoTIFF image */ export declare class GeoTIFFImage { #private; /** * @param reader - the reader containing the input data * @param imageDirectory - the image directory * @param littleEndian - true if little endian false if big endian * @param gridStore - the grid readers to utilize if needed * @param definitions - an array of projection definitions for the transformer if needed * @param epsgCodes - a record of EPSG codes to use for the transformer if needed */ constructor(reader: Reader, imageDirectory: ImageFileDirectory, littleEndian: boolean, gridStore: GridReader[], definitions?: ProjectionTransformDefinition[], epsgCodes?: Record<string, string>); /** * Get the image width * @returns - the image width */ get width(): number; /** * Get the image height * @returns - the image height */ get height(): number; /** * Get the tile width * @returns - the tile width */ get tileWidth(): number; /** * Get the tile height * @returns - the tile height */ get tileHeight(): number; /** * Get the block width * @returns - the block width */ get blockWidth(): number; /** * Get the block height * @param y - the y coordinate of the block * @returns - the block height */ getBlockHeight(y: number): number; /** * Calculates the number of bytes for each pixel across all samples. Only full * bytes are supported, an exception is thrown when this is not the case. * @returns the bytes per pixel */ get bytesPerPixel(): number; /** * Returns the number of samples per pixel. * @returns the number of samples per pixel */ get samplesPerPixel(): number; /** * Returns the sample format * @param sampleIndex - the sample index to start at * @returns the sample format code */ getSampleFormat(sampleIndex?: number): number; /** * Returns the number of bits per sample * @param sampleIndex - the sample index to start at * @returns the number of bits per sample at the sample index */ getBitsPerSample(sampleIndex?: number): number; /** * Convert the data format and bits per sample to the appropriate array type * @param raster - the data * @returns - the array */ rasterToArrayType(raster: number[]): ArrayTypes; /** * Returns an array of tiepoints. * @returns - An array of tiepoints */ get tiePoints(): TiePoint[]; /** * Returns the image origin as a XYZ-vector. When the image has no affine * transformation, then an exception is thrown. * @returns The origin as a vector */ get origin(): VectorPoint; /** * Returns the image origin as a XYZ-vector in lon-lat space. When the image has no affine * transformation, then an exception is thrown. * @returns The origin as a lon-lat vector */ get originLL(): VectorPoint; /** * Returns the image resolution as a XYZ-vector. When the image has no affine * transformation, then an exception is thrown. in cases when the current image does * not have the required tags on its own. * @returns The resolution as a vector */ get resolution(): VectorPoint; /** * Returns the image resolution as a XYZ-vector in lon-lat space. When the image has no affine * transformation, then an exception is thrown. in cases when the current image does not * have the required tags on its own. * @returns The resolution as a lon-lat vector */ get resolutionLL(): VectorPoint; /** * Returns whether or not the pixels of the image depict an area (or point). * @returns Whether the pixels are a point */ get pixelIsArea(): boolean; /** * Returns the image bounding box as an array of 4 values: min-x, min-y, * max-x and max-y. When the image has no affine transformation, then an * exception is thrown. * @param transform - apply affine transformation or proj4 transformation * @returns The bounding box */ getBoundingBox(transform?: boolean): [minX: number, minY: number, maxX: number, maxY: number]; /** * Returns the raster data of the image. * @param samples - Samples to read from the image * @returns - The raster data */ rasterData(samples?: number[]): Promise<Raster>; /** * Returns the RGBA raster data of the image. * @returns - The RGBA raster data */ getRGBA(): Promise<Raster>; /** * Build a vector feature from the image * @returns - The vector feature with rgba values incoded into the points */ getMultiPointVector(): Promise<VectorMultiPointResult>; /** * Returns the reader for a sample * @param sampleIndex - the index of the sample * @returns - a function to read each sample value */ getReaderForSample(sampleIndex: number): (offset: number, littleEndian: boolean) => number; /** * Get the data for a tile or strip * @param x - the tile or strip x coordinate * @param y - the tile or strip y coordinate * @param sample - the sample * @param decodeFn - the function to decode the data * @returns - the data as a buffer */ getTileOrStrip(x: number, y: number, sample: number, decodeFn: Decoder): Promise<ArrayBufferLike>; /** * Apply the predictor if necessary * @param data - the raw data * @returns - the data with the predictor applied */ maybeApplyPredictor(data: ArrayBufferLike): ArrayBufferLike; } //# sourceMappingURL=image.d.ts.map