geotiff.d.ts 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /**
  2. * Creates a new GeoTIFF from a remote URL.
  3. * @param {string} url The URL to access the image from
  4. * @param {object} [options] Additional options to pass to the source.
  5. * See {@link makeRemoteSource} for details.
  6. * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
  7. * to be aborted
  8. * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
  9. */
  10. export function fromUrl(url: string, options?: object, signal?: AbortSignal | undefined): Promise<GeoTIFF>;
  11. /**
  12. * Construct a new GeoTIFF from an
  13. * [ArrayBuffer]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer}.
  14. * @param {ArrayBuffer} arrayBuffer The data to read the file from.
  15. * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
  16. * to be aborted
  17. * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
  18. */
  19. export function fromArrayBuffer(arrayBuffer: ArrayBuffer, signal?: AbortSignal | undefined): Promise<GeoTIFF>;
  20. /**
  21. * Construct a GeoTIFF from a local file path. This uses the node
  22. * [filesystem API]{@link https://nodejs.org/api/fs.html} and is
  23. * not available on browsers.
  24. *
  25. * N.B. After the GeoTIFF has been completely processed it needs
  26. * to be closed but only if it has been constructed from a file.
  27. * @param {string} path The file path to read from.
  28. * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
  29. * to be aborted
  30. * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
  31. */
  32. export function fromFile(path: string, signal?: AbortSignal | undefined): Promise<GeoTIFF>;
  33. /**
  34. * Construct a GeoTIFF from an HTML
  35. * [Blob]{@link https://developer.mozilla.org/en-US/docs/Web/API/Blob} or
  36. * [File]{@link https://developer.mozilla.org/en-US/docs/Web/API/File}
  37. * object.
  38. * @param {Blob|File} blob The Blob or File object to read from.
  39. * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
  40. * to be aborted
  41. * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
  42. */
  43. export function fromBlob(blob: Blob | File, signal?: AbortSignal | undefined): Promise<GeoTIFF>;
  44. /**
  45. * Construct a MultiGeoTIFF from the given URLs.
  46. * @param {string} mainUrl The URL for the main file.
  47. * @param {string[]} overviewUrls An array of URLs for the overview images.
  48. * @param {Object} [options] Additional options to pass to the source.
  49. * See [makeRemoteSource]{@link module:source.makeRemoteSource}
  50. * for details.
  51. * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
  52. * to be aborted
  53. * @returns {Promise<MultiGeoTIFF>} The resulting MultiGeoTIFF file.
  54. */
  55. export function fromUrls(mainUrl: string, overviewUrls?: string[], options?: any, signal?: AbortSignal | undefined): Promise<MultiGeoTIFF>;
  56. /**
  57. * Main creating function for GeoTIFF files.
  58. * @param {(Array)} array of pixel values
  59. * @returns {metadata} metadata
  60. */
  61. export function writeArrayBuffer(values: any, metadata: any): any;
  62. export { default as BaseDecoder } from "./compression/basedecoder.js";
  63. export default GeoTIFF;
  64. export type TypedArray = Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array;
  65. export type Dimensions = {
  66. height: number;
  67. width: number;
  68. };
  69. /**
  70. * The autogenerated docs are a little confusing here. The effective type is:
  71. *
  72. * `TypedArray & { height: number; width: number}`
  73. */
  74. export type TypedArrayWithDimensions = TypedArray & Dimensions;
  75. /**
  76. * The autogenerated docs are a little confusing here. The effective type is:
  77. *
  78. * `TypedArray[] & { height: number; width: number}`
  79. */
  80. export type TypedArrayArrayWithDimensions = TypedArray[] & Dimensions;
  81. /**
  82. * The autogenerated docs are a little confusing here. The effective type is:
  83. *
  84. * `(TypedArray | TypedArray[]) & { height: number; width: number}`
  85. */
  86. export type ReadRasterResult = TypedArrayWithDimensions | TypedArrayArrayWithDimensions;
  87. export type GeoTIFFOptions = {
  88. /**
  89. * whether or not decoded tiles shall be cached.
  90. */
  91. cache?: boolean | undefined;
  92. };
  93. /**
  94. * @typedef {Object} GeoTIFFOptions
  95. * @property {boolean} [cache=false] whether or not decoded tiles shall be cached.
  96. */
  97. /**
  98. * The abstraction for a whole GeoTIFF file.
  99. * @augments GeoTIFFBase
  100. */
  101. export class GeoTIFF extends GeoTIFFBase {
  102. /**
  103. * Parse a (Geo)TIFF file from the given source.
  104. *
  105. * @param {*} source The source of data to parse from.
  106. * @param {GeoTIFFOptions} [options] Additional options.
  107. * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
  108. * to be aborted
  109. */
  110. static fromSource(source: any, options?: GeoTIFFOptions | undefined, signal?: AbortSignal | undefined): Promise<GeoTIFF>;
  111. /**
  112. * @constructor
  113. * @param {*} source The datasource to read from.
  114. * @param {boolean} littleEndian Whether the image uses little endian.
  115. * @param {boolean} bigTiff Whether the image uses bigTIFF conventions.
  116. * @param {number} firstIFDOffset The numeric byte-offset from the start of the image
  117. * to the first IFD.
  118. * @param {GeoTIFFOptions} [options] further options.
  119. */
  120. constructor(source: any, littleEndian: boolean, bigTiff: boolean, firstIFDOffset: number, options?: GeoTIFFOptions | undefined);
  121. source: any;
  122. littleEndian: boolean;
  123. bigTiff: boolean;
  124. firstIFDOffset: number;
  125. cache: boolean;
  126. ifdRequests: any[];
  127. ghostValues: {} | null;
  128. getSlice(offset: any, size: any): Promise<DataSlice>;
  129. /**
  130. * Instructs to parse an image file directory at the given file offset.
  131. * As there is no way to ensure that a location is indeed the start of an IFD,
  132. * this function must be called with caution (e.g only using the IFD offsets from
  133. * the headers or other IFDs).
  134. * @param {number} offset the offset to parse the IFD at
  135. * @returns {Promise<ImageFileDirectory>} the parsed IFD
  136. */
  137. parseFileDirectoryAt(offset: number): Promise<ImageFileDirectory>;
  138. requestIFD(index: any): Promise<any>;
  139. /**
  140. * Get the n-th internal subfile of an image. By default, the first is returned.
  141. *
  142. * @param {number} [index=0] the index of the image to return.
  143. * @returns {Promise<GeoTIFFImage>} the image at the given index
  144. */
  145. getImage(index?: number | undefined): Promise<GeoTIFFImage>;
  146. /**
  147. * Returns the count of the internal subfiles.
  148. *
  149. * @returns {Promise<number>} the number of internal subfile images
  150. */
  151. getImageCount(): Promise<number>;
  152. /**
  153. * Get the values of the COG ghost area as a parsed map.
  154. * See https://gdal.org/drivers/raster/cog.html#header-ghost-area for reference
  155. * @returns {Promise<Object>} the parsed ghost area or null, if no such area was found
  156. */
  157. getGhostValues(): Promise<any>;
  158. /**
  159. * Closes the underlying file buffer
  160. * N.B. After the GeoTIFF has been completely processed it needs
  161. * to be closed but only if it has been constructed from a file.
  162. */
  163. close(): any;
  164. }
  165. /**
  166. * Wrapper for GeoTIFF files that have external overviews.
  167. * @augments GeoTIFFBase
  168. */
  169. export class MultiGeoTIFF extends GeoTIFFBase {
  170. /**
  171. * Construct a new MultiGeoTIFF from a main and several overview files.
  172. * @param {GeoTIFF} mainFile The main GeoTIFF file.
  173. * @param {GeoTIFF[]} overviewFiles An array of overview files.
  174. */
  175. constructor(mainFile: GeoTIFF, overviewFiles: GeoTIFF[]);
  176. mainFile: GeoTIFF;
  177. overviewFiles: GeoTIFF[];
  178. imageFiles: GeoTIFF[];
  179. fileDirectoriesPerFile: ImageFileDirectory[] | null;
  180. fileDirectoriesPerFileParsing: any;
  181. imageCount: number | null;
  182. parseFileDirectoriesPerFile(): Promise<ImageFileDirectory[]>;
  183. /**
  184. * Get the n-th internal subfile of an image. By default, the first is returned.
  185. *
  186. * @param {number} [index=0] the index of the image to return.
  187. * @returns {Promise<GeoTIFFImage>} the image at the given index
  188. */
  189. getImage(index?: number | undefined): Promise<GeoTIFFImage>;
  190. /**
  191. * Returns the count of the internal subfiles.
  192. *
  193. * @returns {Promise<number>} the number of internal subfile images
  194. */
  195. getImageCount(): Promise<number>;
  196. imageCounts: number[] | undefined;
  197. }
  198. import * as globals from "./globals.js";
  199. import * as rgb from "./rgb.js";
  200. import { getDecoder } from "./compression/index.js";
  201. import { addDecoder } from "./compression/index.js";
  202. import { setLogger } from "./logging.js";
  203. import Pool from "./pool.js";
  204. import GeoTIFFImage from "./geotiffimage.js";
  205. declare class GeoTIFFBase {
  206. /**
  207. * (experimental) Reads raster data from the best fitting image. This function uses
  208. * the image with the lowest resolution that is still a higher resolution than the
  209. * requested resolution.
  210. * When specified, the `bbox` option is translated to the `window` option and the
  211. * `resX` and `resY` to `width` and `height` respectively.
  212. * Then, the [readRasters]{@link GeoTIFFImage#readRasters} method of the selected
  213. * image is called and the result returned.
  214. * @see GeoTIFFImage.readRasters
  215. * @param {import('./geotiffimage').ReadRasterOptions} [options={}] optional parameters
  216. * @returns {Promise<ReadRasterResult>} the decoded array(s), with `height` and `width`, as a promise
  217. */
  218. readRasters(options?: import("./geotiffimage.js").ReadRasterOptions | undefined): Promise<ReadRasterResult>;
  219. }
  220. import DataSlice from "./dataslice.js";
  221. /**
  222. * Data class to store the parsed file directory, geo key directory and
  223. * offset to the next IFD
  224. */
  225. declare class ImageFileDirectory {
  226. constructor(fileDirectory: any, geoKeyDirectory: any, nextIFDByteOffset: any);
  227. fileDirectory: any;
  228. geoKeyDirectory: any;
  229. nextIFDByteOffset: any;
  230. }
  231. export { globals, rgb, getDecoder, addDecoder, setLogger, Pool, GeoTIFFImage };
  232. //# sourceMappingURL=geotiff.d.ts.map