403 lines
16 KiB
TypeScript
403 lines
16 KiB
TypeScript
/**
|
|
* Creates a new GeoTIFF from a remote URL.
|
|
* @param {string} url The URL to access the image from
|
|
* @param {RemoteSourceOptions} [options] Additional options to pass to the source.
|
|
* See {@link makeRemoteSource} for details.
|
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
* @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
|
|
*/
|
|
export function fromUrl(url: string, options?: RemoteSourceOptions, signal?: AbortSignal): Promise<GeoTIFF>;
|
|
/**
|
|
* Creates a new GeoTIFF from a custom {@link BaseClient}.
|
|
* @param {BaseClient} client The client.
|
|
* @param {RemoteSourceOptions} [options] Additional options to pass to the source.
|
|
* See {@link makeRemoteSource} for details.
|
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
* @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
|
|
*/
|
|
export function fromCustomClient(client: BaseClient, options?: RemoteSourceOptions, signal?: AbortSignal): Promise<GeoTIFF>;
|
|
/**
|
|
* Construct a new GeoTIFF from an
|
|
* [ArrayBuffer]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer}.
|
|
* @param {ArrayBuffer} arrayBuffer The data to read the file from.
|
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
* @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
|
|
*/
|
|
export function fromArrayBuffer(arrayBuffer: ArrayBuffer, signal?: AbortSignal): Promise<GeoTIFF>;
|
|
/**
|
|
* Construct a GeoTIFF from a local file path. This uses the node
|
|
* [filesystem API]{@link https://nodejs.org/api/fs.html} and is
|
|
* not available on browsers.
|
|
*
|
|
* N.B. After the GeoTIFF has been completely processed it needs
|
|
* to be closed but only if it has been constructed from a file.
|
|
* @param {string} path The file path to read from.
|
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
* @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
|
|
*/
|
|
export function fromFile(path: string, signal?: AbortSignal): Promise<GeoTIFF>;
|
|
/**
|
|
* Construct a GeoTIFF from an HTML
|
|
* [Blob]{@link https://developer.mozilla.org/en-US/docs/Web/API/Blob} or
|
|
* [File]{@link https://developer.mozilla.org/en-US/docs/Web/API/File}
|
|
* object.
|
|
* @param {Blob|File} blob The Blob or File object to read from.
|
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
* @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
|
|
*/
|
|
export function fromBlob(blob: Blob | File, signal?: AbortSignal): Promise<GeoTIFF>;
|
|
/**
|
|
* Construct a MultiGeoTIFF from the given URLs.
|
|
* @param {string} mainUrl The URL for the main file.
|
|
* @param {string[]} overviewUrls An array of URLs for the overview images.
|
|
* @param {RemoteSourceOptions} [options] Additional options to pass to the source.
|
|
* See [makeRemoteSource]{@link module:source.makeRemoteSource}
|
|
* for details.
|
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
* @returns {Promise<MultiGeoTIFF>} The resulting MultiGeoTIFF file.
|
|
*/
|
|
export function fromUrls(mainUrl: string, overviewUrls?: string[], options?: RemoteSourceOptions, signal?: AbortSignal): Promise<MultiGeoTIFF>;
|
|
/**
|
|
* Main creating function for GeoTIFF files.
|
|
* @param {Array<number>|Array<Array<Array<number>>>|TypedArray} values The pixel values to write.
|
|
* Can be a flat array of all pixels or a 3-dimensional array of shape `[band][row][column]`.
|
|
* @param {GeotiffWriterMetadata} metadata
|
|
* @returns {ArrayBuffer}
|
|
*/
|
|
export function writeArrayBuffer(values: Array<number> | Array<Array<Array<number>>> | TypedArray, metadata: GeotiffWriterMetadata): ArrayBuffer;
|
|
export { default as BaseDecoder } from "./compression/basedecoder.js";
|
|
export { ImageFileDirectory } from "./imagefiledirectory.js";
|
|
export default GeoTIFF;
|
|
export type TypedArray = Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array;
|
|
export type Dimensions = {
|
|
height: number;
|
|
width: number;
|
|
};
|
|
/**
|
|
* The autogenerated docs are a little confusing here. The effective type is:
|
|
*
|
|
* `TypedArray & { height: number; width: number}`
|
|
*/
|
|
export type TypedArrayWithDimensions = TypedArray & Dimensions;
|
|
/**
|
|
* The autogenerated docs are a little confusing here. The effective type is:
|
|
*
|
|
* `TypedArray[] & { height: number; width: number}`
|
|
*/
|
|
export type TypedArrayArrayWithDimensions = TypedArray[] & Dimensions;
|
|
export type GeotiffWriterMetadata = {
|
|
ImageWidth?: number | number[] | undefined;
|
|
ImageLength?: number | number[] | undefined;
|
|
width?: number | undefined;
|
|
height?: number | undefined;
|
|
BitsPerSample?: number | number[] | undefined;
|
|
Compression?: number | number[] | undefined;
|
|
PlanarConfiguration?: number | number[] | undefined;
|
|
ExtraSamples?: number | number[] | undefined;
|
|
PhotometricInterpretation?: number | number[] | undefined;
|
|
SamplesPerPixel?: number | number[] | undefined;
|
|
StripByteCounts?: number | number[] | undefined;
|
|
ModelPixelScale?: number[] | undefined;
|
|
ModelTransformation?: number[] | undefined;
|
|
ModelTiepoint?: number[] | undefined;
|
|
GeoKeyDirectory?: number[] | undefined;
|
|
GeoAsciiParams?: string | undefined;
|
|
GeoDoubleParams?: number[] | undefined;
|
|
Orientation?: number | number[] | undefined;
|
|
ResolutionUnit?: number | number[] | undefined;
|
|
XPosition?: number | number[] | undefined;
|
|
YPosition?: number | number[] | undefined;
|
|
RowsPerStrip?: number | number[] | undefined;
|
|
SampleFormat?: number[] | undefined;
|
|
TileWidth?: number | number[] | undefined;
|
|
TileLength?: number | number[] | undefined;
|
|
TileOffsets?: number[] | undefined;
|
|
TileByteCounts?: number[] | undefined;
|
|
GDAL_NODATA?: string | undefined;
|
|
GeographicTypeGeoKey?: number | number[] | undefined;
|
|
ProjectedCSTypeGeoKey?: number | number[] | undefined;
|
|
GeogCitationGeoKey?: string | undefined;
|
|
GTCitationGeoKey?: string | undefined;
|
|
GTModelTypeGeoKey?: number | number[] | undefined;
|
|
GTRasterTypeGeoKey?: number | number[] | undefined;
|
|
};
|
|
/**
|
|
* The autogenerated docs are a little confusing here. The effective type is:
|
|
*
|
|
* `(TypedArray | TypedArray[]) & { height: number; width: number}`
|
|
*/
|
|
export type ReadRasterResult = TypedArrayWithDimensions | TypedArrayArrayWithDimensions;
|
|
/**
|
|
* Use the {@link Pool.bindParameters} method to get a decoder worker for
|
|
* a specific compression and its parameters.
|
|
*/
|
|
export type DecoderWorker = {
|
|
/**
|
|
* A function that takes a compressed buffer and returns a promise resolving to the decoded buffer.
|
|
*/
|
|
decode: (buffer: ArrayBufferLike) => Promise<ArrayBufferLike>;
|
|
};
|
|
export type ReadRastersOptions = {
|
|
/**
|
|
* the subset to read data from in pixels. Whole window if not specified.
|
|
*/
|
|
window?: number[] | undefined;
|
|
/**
|
|
* the selection of samples to read from. Default is all samples.
|
|
* All samples if not specified.
|
|
*/
|
|
samples?: number[] | undefined;
|
|
/**
|
|
* The optional decoder pool to use.
|
|
*/
|
|
pool?: Pool | null | undefined;
|
|
/**
|
|
* The desired width of the output. When the width is not the
|
|
* same as the images, resampling will be performed.
|
|
*/
|
|
width?: number | undefined;
|
|
/**
|
|
* The desired height of the output. When the width is not the
|
|
* same as the images, resampling will be performed.
|
|
*/
|
|
height?: number | undefined;
|
|
/**
|
|
* The desired resampling method.
|
|
*/
|
|
resampleMethod?: string | undefined;
|
|
/**
|
|
* An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
*/
|
|
signal?: AbortSignal | undefined;
|
|
/**
|
|
* The value to use for parts of the image
|
|
* outside of the images extent. When multiple samples are requested and `interleave` is
|
|
* `false`, an array of fill values can be passed.
|
|
*/
|
|
fillValue?: number | number[] | undefined;
|
|
/**
|
|
* whether the data shall be read
|
|
* in one single array or separate arrays.
|
|
*/
|
|
interleave?: boolean | undefined;
|
|
};
|
|
export type ReadRGBOptions = {
|
|
/**
|
|
* the subset to read data from in pixels. Whole window if not specified.
|
|
*/
|
|
window?: number[] | undefined;
|
|
/**
|
|
* The optional decoder pool to use.
|
|
*/
|
|
pool?: Pool | null | undefined;
|
|
/**
|
|
* The desired width of the output. When the width is no the
|
|
* same as the images, resampling will be performed.
|
|
*/
|
|
width?: number | undefined;
|
|
/**
|
|
* The desired height of the output. When the width is no the
|
|
* same as the images, resampling will be performed.
|
|
*/
|
|
height?: number | undefined;
|
|
/**
|
|
* The desired resampling method.
|
|
*/
|
|
resampleMethod?: string | undefined;
|
|
/**
|
|
* Enable reading alpha channel if present.
|
|
*/
|
|
enableAlpha?: boolean | undefined;
|
|
/**
|
|
* An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
*/
|
|
signal?: AbortSignal | undefined;
|
|
/**
|
|
* whether the data shall be read
|
|
* in one single array or separate arrays.
|
|
*/
|
|
interleave?: boolean | undefined;
|
|
};
|
|
export type BlockedSourceOptions = {
|
|
/**
|
|
* Block size for a BlockedSource.
|
|
*/
|
|
blockSize?: number | undefined;
|
|
/**
|
|
* The number of blocks to cache.
|
|
*/
|
|
cacheSize?: number | undefined;
|
|
};
|
|
export type RemoteSourceOptions = {
|
|
/**
|
|
* Additional headers to add to each request
|
|
*/
|
|
headers?: Record<string, string> | undefined;
|
|
/**
|
|
* Maximum number of ranges to request in a single HTTP request. 0 means no multi-range requests.
|
|
*/
|
|
maxRanges?: number | undefined;
|
|
/**
|
|
* Whether to allow full file responses when requesting ranges
|
|
*/
|
|
allowFullFile?: boolean | undefined;
|
|
/**
|
|
* When the Fetch API would be used, force using XMLHttpRequest instead.
|
|
*/
|
|
forceXHR?: boolean | undefined;
|
|
};
|
|
export type GeoTIFFOptions = {
|
|
/**
|
|
* whether or not decoded tiles shall be cached.
|
|
*/
|
|
cache?: boolean | undefined;
|
|
};
|
|
/**
|
|
* @typedef {Object} GeoTIFFOptions
|
|
* @property {boolean} [cache=false] whether or not decoded tiles shall be cached.
|
|
*/
|
|
/**
|
|
* The abstraction for a whole GeoTIFF file.
|
|
*/
|
|
export class GeoTIFF extends GeoTIFFBase {
|
|
/**
|
|
* Parse a (Geo)TIFF file from the given source.
|
|
*
|
|
* @param {BaseSource} source The source of data to parse from.
|
|
* @param {GeoTIFFOptions} [options] Additional options.
|
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
* to be aborted
|
|
*/
|
|
static fromSource(source: BaseSource, options?: GeoTIFFOptions, signal?: AbortSignal): Promise<GeoTIFF>;
|
|
/**
|
|
* @constructor
|
|
* @param {BaseSource} source The datasource to read from.
|
|
* @param {boolean} littleEndian Whether the image uses little endian.
|
|
* @param {boolean} bigTiff Whether the image uses bigTIFF conventions.
|
|
* @param {number} firstIFDOffset The numeric byte-offset from the start of the image
|
|
* to the first IFD.
|
|
* @param {GeoTIFFOptions} [options] further options.
|
|
*/
|
|
constructor(source: BaseSource, littleEndian: boolean, bigTiff: boolean, firstIFDOffset: number, options?: GeoTIFFOptions);
|
|
source: BaseSource;
|
|
parser: ImageFileDirectoryParser;
|
|
littleEndian: boolean;
|
|
bigTiff: boolean;
|
|
firstIFDOffset: number;
|
|
cache: boolean;
|
|
/** @type {Array<Promise<import('./imagefiledirectory.js').ImageFileDirectory> | undefined>} */
|
|
ifdRequests: Array<Promise<import("./imagefiledirectory.js").ImageFileDirectory> | undefined>;
|
|
/** @type {Record<string, unknown>|null} */
|
|
ghostValues: Record<string, unknown> | null;
|
|
/**
|
|
* @param {number} offset
|
|
* @param {number} [size]
|
|
* @returns {Promise<DataSlice>}
|
|
*/
|
|
getSlice(offset: number, size?: number): Promise<DataSlice>;
|
|
/**
|
|
* @param {number} index
|
|
* @return {Promise<import('./imagefiledirectory.js').ImageFileDirectory>}
|
|
*/
|
|
requestIFD(index: number): Promise<import("./imagefiledirectory.js").ImageFileDirectory>;
|
|
/**
|
|
* Get the values of the COG ghost area as a parsed map.
|
|
* See https://gdal.org/drivers/raster/cog.html#header-ghost-area for reference
|
|
* @returns {Promise<Record<string, unknown>|null>} the parsed ghost area or null, if no such area was found
|
|
*/
|
|
getGhostValues(): Promise<Record<string, unknown> | null>;
|
|
/**
|
|
* Closes the underlying file buffer
|
|
* N.B. After the GeoTIFF has been completely processed it needs
|
|
* to be closed but only if it has been constructed from a file.
|
|
*/
|
|
close(): false | Promise<void>;
|
|
}
|
|
import { BaseClient } from './source/client/base.js';
|
|
/**
|
|
* Wrapper for GeoTIFF files that have external overviews.
|
|
* @augments GeoTIFFBase
|
|
*/
|
|
export class MultiGeoTIFF extends GeoTIFFBase {
|
|
/**
|
|
* Construct a new MultiGeoTIFF from a main and several overview files.
|
|
* @param {GeoTIFF} mainFile The main GeoTIFF file.
|
|
* @param {GeoTIFF[]} overviewFiles An array of overview files.
|
|
*/
|
|
constructor(mainFile: GeoTIFF, overviewFiles: GeoTIFF[]);
|
|
mainFile: GeoTIFF;
|
|
overviewFiles: GeoTIFF[];
|
|
imageFiles: GeoTIFF[];
|
|
fileDirectoriesPerFile: import("./imagefiledirectory.js").ImageFileDirectory[] | null;
|
|
fileDirectoriesPerFileParsing: any;
|
|
imageCount: number | null;
|
|
parseFileDirectoriesPerFile(): Promise<import("./imagefiledirectory.js").ImageFileDirectory[]>;
|
|
imageCounts: number[] | undefined;
|
|
}
|
|
import * as globals from './globals.js';
|
|
import { registerTag } from './globals.js';
|
|
import * as rgb from './rgb.js';
|
|
import { getDecoder } from './compression/index.js';
|
|
import { addDecoder } from './compression/index.js';
|
|
import { setLogger } from './logging.js';
|
|
import Pool from './pool.js';
|
|
import GeoTIFFImage from './geotiffimage.js';
|
|
import { BaseResponse } from './source/client/base.js';
|
|
declare class GeoTIFFBase {
|
|
/**
|
|
* @param {number} [_index=0] the index of the image to return.
|
|
* @returns {Promise<GeoTIFFImage>} the image at the given index
|
|
*/
|
|
getImage(_index?: number): Promise<GeoTIFFImage>;
|
|
/**
|
|
* @returns {Promise<number>} the number of internal subfile images
|
|
*/
|
|
getImageCount(): Promise<number>;
|
|
/**
|
|
* @typedef {Object} ReadRastersWindowOptions
|
|
* @property {number} [resX] desired Y resolution (world units per pixel)
|
|
* @property {number} [resY] desired X resolution (world units per pixel)
|
|
* @property {Array<number>} [bbox] the subset to read data from in
|
|
* geographical coordinates. Whole image if not specified.
|
|
*/
|
|
/**
|
|
* (experimental) Reads raster data from the best fitting image. This function uses
|
|
* the image with the lowest resolution that is still a higher resolution than the
|
|
* requested resolution.
|
|
* When specified, the `bbox` option is translated to the `window` option and the
|
|
* `resX` and `resY` to `width` and `height` respectively.
|
|
* Then, the [readRasters]{@link GeoTIFFImage#readRasters} method of the selected
|
|
* image is called and the result returned.
|
|
* @see GeoTIFFImage.readRasters
|
|
* @param {ReadRastersOptions & ReadRastersWindowOptions} options optional parameters
|
|
* @returns {Promise<ReadRasterResult>} the decoded array(s), with `height` and `width`, as a promise
|
|
*/
|
|
readRasters(options?: ReadRastersOptions & {
|
|
/**
|
|
* desired Y resolution (world units per pixel)
|
|
*/
|
|
resX?: number | undefined;
|
|
/**
|
|
* desired X resolution (world units per pixel)
|
|
*/
|
|
resY?: number | undefined;
|
|
/**
|
|
* the subset to read data from in
|
|
* geographical coordinates. Whole image if not specified.
|
|
*/
|
|
bbox?: number[] | undefined;
|
|
}): Promise<ReadRasterResult>;
|
|
}
|
|
import type { BaseSource } from './source/basesource.js';
|
|
import { ImageFileDirectoryParser } from './imagefiledirectory.js';
|
|
import DataSlice from './dataslice.js';
|
|
export { globals, registerTag, rgb, getDecoder, addDecoder, setLogger, Pool, GeoTIFFImage, BaseClient, BaseResponse };
|
|
//# sourceMappingURL=geotiff.d.ts.map
|