geotiff 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist-browser/geotiff.js +3 -2
  2. package/dist-browser/geotiff.js.map +1 -1
  3. package/dist-module/compression/basedecoder.d.ts +4 -0
  4. package/dist-module/compression/basedecoder.d.ts.map +1 -1
  5. package/dist-module/compression/basedecoder.js +6 -0
  6. package/dist-module/compression/index.d.ts +4 -4
  7. package/dist-module/compression/index.d.ts.map +1 -1
  8. package/dist-module/compression/index.js +4 -4
  9. package/dist-module/compression/jpeg.d.ts +6 -1
  10. package/dist-module/compression/jpeg.d.ts.map +1 -1
  11. package/dist-module/compression/jpeg.js +50 -5
  12. package/dist-module/compression/lzw.js +1 -1
  13. package/dist-module/compression/webimage.d.ts +1 -1
  14. package/dist-module/compression/webimage.d.ts.map +1 -1
  15. package/dist-module/compression/webimage.js +1 -1
  16. package/dist-module/dataslice.d.ts.map +1 -1
  17. package/dist-module/dataslice.js +2 -2
  18. package/dist-module/dataview64.d.ts +2 -2
  19. package/dist-module/dataview64.d.ts.map +1 -1
  20. package/dist-module/dataview64.js +4 -4
  21. package/dist-module/geotiff.d.ts +161 -45
  22. package/dist-module/geotiff.d.ts.map +1 -1
  23. package/dist-module/geotiff.js +111 -20
  24. package/dist-module/geotiffimage.d.ts +76 -110
  25. package/dist-module/geotiffimage.d.ts.map +1 -1
  26. package/dist-module/geotiffimage.js +98 -70
  27. package/dist-module/geotiffwriter.js +2 -2
  28. package/dist-module/globals.d.ts +48 -40
  29. package/dist-module/globals.d.ts.map +1 -1
  30. package/dist-module/globals.js +14 -10
  31. package/dist-module/imagefiledirectory.d.ts +2 -2
  32. package/dist-module/imagefiledirectory.d.ts.map +1 -1
  33. package/dist-module/imagefiledirectory.js +23 -12
  34. package/dist-module/logging.js +7 -7
  35. package/dist-module/pool.d.ts +2 -3
  36. package/dist-module/pool.d.ts.map +1 -1
  37. package/dist-module/pool.js +18 -16
  38. package/dist-module/predictor.js +1 -1
  39. package/dist-module/resample.d.ts +18 -18
  40. package/dist-module/resample.d.ts.map +1 -1
  41. package/dist-module/resample.js +12 -12
  42. package/dist-module/source/basesource.d.ts +7 -7
  43. package/dist-module/source/basesource.d.ts.map +1 -1
  44. package/dist-module/source/basesource.js +7 -7
  45. package/dist-module/source/blockedsource.d.ts +10 -10
  46. package/dist-module/source/blockedsource.d.ts.map +1 -1
  47. package/dist-module/source/blockedsource.js +12 -9
  48. package/dist-module/source/client/base.d.ts +8 -10
  49. package/dist-module/source/client/base.d.ts.map +1 -1
  50. package/dist-module/source/client/base.js +4 -3
  51. package/dist-module/source/client/fetch.d.ts +2 -7
  52. package/dist-module/source/client/fetch.d.ts.map +1 -1
  53. package/dist-module/source/client/fetch.js +7 -2
  54. package/dist-module/source/client/http.d.ts +4 -1
  55. package/dist-module/source/client/http.d.ts.map +1 -1
  56. package/dist-module/source/client/http.js +4 -4
  57. package/dist-module/source/client/xhr.d.ts +4 -1
  58. package/dist-module/source/client/xhr.d.ts.map +1 -1
  59. package/dist-module/source/client/xhr.js +1 -1
  60. package/dist-module/source/file.js +4 -4
  61. package/dist-module/source/filereader.js +1 -1
  62. package/dist-module/source/httputils.d.ts +14 -6
  63. package/dist-module/source/httputils.d.ts.map +1 -1
  64. package/dist-module/source/httputils.js +13 -12
  65. package/dist-module/source/remote.d.ts +31 -22
  66. package/dist-module/source/remote.d.ts.map +1 -1
  67. package/dist-module/source/remote.js +37 -13
  68. package/dist-module/utils.d.ts +7 -1
  69. package/dist-module/utils.d.ts.map +1 -1
  70. package/dist-module/utils.js +6 -0
  71. package/dist-module/worker/create.js +1 -1
  72. package/dist-node/compression/basedecoder.d.ts +4 -0
  73. package/dist-node/compression/basedecoder.d.ts.map +1 -1
  74. package/dist-node/compression/basedecoder.js +6 -0
  75. package/dist-node/compression/basedecoder.js.map +1 -1
  76. package/dist-node/compression/index.d.ts +4 -4
  77. package/dist-node/compression/index.d.ts.map +1 -1
  78. package/dist-node/compression/index.js +4 -4
  79. package/dist-node/compression/jpeg.d.ts +6 -1
  80. package/dist-node/compression/jpeg.d.ts.map +1 -1
  81. package/dist-node/compression/jpeg.js +50 -5
  82. package/dist-node/compression/jpeg.js.map +1 -1
  83. package/dist-node/compression/lzw.js +1 -1
  84. package/dist-node/compression/lzw.js.map +1 -1
  85. package/dist-node/compression/webimage.js +1 -1
  86. package/dist-node/compression/webimage.js.map +1 -1
  87. package/dist-node/dataslice.js +2 -2
  88. package/dist-node/dataslice.js.map +1 -1
  89. package/dist-node/dataview64.d.ts +2 -2
  90. package/dist-node/dataview64.d.ts.map +1 -1
  91. package/dist-node/dataview64.js +4 -4
  92. package/dist-node/dataview64.js.map +1 -1
  93. package/dist-node/geotiff.d.ts +161 -45
  94. package/dist-node/geotiff.d.ts.map +1 -1
  95. package/dist-node/geotiff.js +110 -20
  96. package/dist-node/geotiff.js.map +1 -1
  97. package/dist-node/geotiffimage.d.ts +77 -111
  98. package/dist-node/geotiffimage.d.ts.map +1 -1
  99. package/dist-node/geotiffimage.js +98 -70
  100. package/dist-node/geotiffimage.js.map +1 -1
  101. package/dist-node/geotiffwriter.js +2 -2
  102. package/dist-node/geotiffwriter.js.map +1 -1
  103. package/dist-node/globals.d.ts +48 -40
  104. package/dist-node/globals.d.ts.map +1 -1
  105. package/dist-node/globals.js +14 -10
  106. package/dist-node/globals.js.map +1 -1
  107. package/dist-node/imagefiledirectory.d.ts +2 -2
  108. package/dist-node/imagefiledirectory.d.ts.map +1 -1
  109. package/dist-node/imagefiledirectory.js +23 -12
  110. package/dist-node/imagefiledirectory.js.map +1 -1
  111. package/dist-node/logging.js +7 -7
  112. package/dist-node/logging.js.map +1 -1
  113. package/dist-node/pool.d.ts +2 -3
  114. package/dist-node/pool.d.ts.map +1 -1
  115. package/dist-node/pool.js +18 -16
  116. package/dist-node/pool.js.map +1 -1
  117. package/dist-node/predictor.js +1 -1
  118. package/dist-node/predictor.js.map +1 -1
  119. package/dist-node/resample.d.ts +18 -18
  120. package/dist-node/resample.d.ts.map +1 -1
  121. package/dist-node/resample.js +12 -12
  122. package/dist-node/source/basesource.d.ts +7 -7
  123. package/dist-node/source/basesource.d.ts.map +1 -1
  124. package/dist-node/source/basesource.js +7 -7
  125. package/dist-node/source/basesource.js.map +1 -1
  126. package/dist-node/source/blockedsource.d.ts +10 -10
  127. package/dist-node/source/blockedsource.d.ts.map +1 -1
  128. package/dist-node/source/blockedsource.js +12 -9
  129. package/dist-node/source/blockedsource.js.map +1 -1
  130. package/dist-node/source/client/base.d.ts +8 -10
  131. package/dist-node/source/client/base.d.ts.map +1 -1
  132. package/dist-node/source/client/base.js +4 -3
  133. package/dist-node/source/client/base.js.map +1 -1
  134. package/dist-node/source/client/fetch.d.ts +2 -6
  135. package/dist-node/source/client/fetch.d.ts.map +1 -1
  136. package/dist-node/source/client/fetch.js +7 -2
  137. package/dist-node/source/client/fetch.js.map +1 -1
  138. package/dist-node/source/client/http.d.ts +4 -1
  139. package/dist-node/source/client/http.d.ts.map +1 -1
  140. package/dist-node/source/client/http.js +4 -4
  141. package/dist-node/source/client/http.js.map +1 -1
  142. package/dist-node/source/client/xhr.d.ts +4 -1
  143. package/dist-node/source/client/xhr.d.ts.map +1 -1
  144. package/dist-node/source/client/xhr.js +1 -1
  145. package/dist-node/source/client/xhr.js.map +1 -1
  146. package/dist-node/source/file.js +4 -4
  147. package/dist-node/source/file.js.map +1 -1
  148. package/dist-node/source/filereader.js +1 -1
  149. package/dist-node/source/filereader.js.map +1 -1
  150. package/dist-node/source/httputils.d.ts +14 -6
  151. package/dist-node/source/httputils.d.ts.map +1 -1
  152. package/dist-node/source/httputils.js +13 -12
  153. package/dist-node/source/httputils.js.map +1 -1
  154. package/dist-node/source/remote.d.ts +31 -22
  155. package/dist-node/source/remote.d.ts.map +1 -1
  156. package/dist-node/source/remote.js +37 -13
  157. package/dist-node/source/remote.js.map +1 -1
  158. package/dist-node/utils.d.ts +7 -1
  159. package/dist-node/utils.d.ts.map +1 -1
  160. package/dist-node/utils.js +6 -0
  161. package/dist-node/utils.js.map +1 -1
  162. package/dist-node/worker/create.js +1 -1
  163. package/dist-node/worker/create.js.map +1 -1
  164. package/package.json +3 -54
@@ -1,23 +1,23 @@
1
1
  /**
2
2
  * Creates a new GeoTIFF from a remote URL.
3
3
  * @param {string} url The URL to access the image from
4
- * @param {object} [options] Additional options to pass to the source.
4
+ * @param {RemoteSourceOptions} [options] Additional options to pass to the source.
5
5
  * See {@link makeRemoteSource} for details.
6
6
  * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
7
7
  * to be aborted
8
8
  * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
9
9
  */
10
- export function fromUrl(url: string, options?: object, signal?: AbortSignal): Promise<GeoTIFF>;
10
+ export function fromUrl(url: string, options?: RemoteSourceOptions, signal?: AbortSignal): Promise<GeoTIFF>;
11
11
  /**
12
12
  * Creates a new GeoTIFF from a custom {@link BaseClient}.
13
13
  * @param {BaseClient} client The client.
14
- * @param {object} [options] Additional options to pass to the source.
14
+ * @param {RemoteSourceOptions} [options] Additional options to pass to the source.
15
15
  * See {@link makeRemoteSource} for details.
16
16
  * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
17
17
  * to be aborted
18
18
  * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
19
19
  */
20
- export function fromCustomClient(client: BaseClient, options?: object, signal?: AbortSignal): Promise<GeoTIFF>;
20
+ export function fromCustomClient(client: BaseClient, options?: RemoteSourceOptions, signal?: AbortSignal): Promise<GeoTIFF>;
21
21
  /**
22
22
  * Construct a new GeoTIFF from an
23
23
  * [ArrayBuffer]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer}.
@@ -55,20 +55,21 @@ export function fromBlob(blob: Blob | File, signal?: AbortSignal): Promise<GeoTI
55
55
  * Construct a MultiGeoTIFF from the given URLs.
56
56
  * @param {string} mainUrl The URL for the main file.
57
57
  * @param {string[]} overviewUrls An array of URLs for the overview images.
58
- * @param {Object} [options] Additional options to pass to the source.
58
+ * @param {RemoteSourceOptions} [options] Additional options to pass to the source.
59
59
  * See [makeRemoteSource]{@link module:source.makeRemoteSource}
60
60
  * for details.
61
61
  * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
62
62
  * to be aborted
63
63
  * @returns {Promise<MultiGeoTIFF>} The resulting MultiGeoTIFF file.
64
64
  */
65
- export function fromUrls(mainUrl: string, overviewUrls?: string[], options?: any, signal?: AbortSignal): Promise<MultiGeoTIFF>;
65
+ export function fromUrls(mainUrl: string, overviewUrls?: string[], options?: RemoteSourceOptions, signal?: AbortSignal): Promise<MultiGeoTIFF>;
66
66
  /**
67
67
  * Main creating function for GeoTIFF files.
68
- * @param {(Array)} array of pixel values
69
- * @returns {metadata} metadata
68
+ * @param {Array} values of pixel values
69
+ * @param {Object} metadata
70
+ * @returns {ArrayBuffer}
70
71
  */
71
- export function writeArrayBuffer(values: any, metadata: any): any;
72
+ export function writeArrayBuffer(values: any[], metadata: any): ArrayBuffer;
72
73
  export { default as BaseDecoder } from "./compression/basedecoder.js";
73
74
  export default GeoTIFF;
74
75
  export type TypedArray = Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array;
@@ -94,6 +95,117 @@ export type TypedArrayArrayWithDimensions = TypedArray[] & Dimensions;
94
95
  * `(TypedArray | TypedArray[]) & { height: number; width: number}`
95
96
  */
96
97
  export type ReadRasterResult = TypedArrayWithDimensions | TypedArrayArrayWithDimensions;
98
+ export type ReadRastersOptions = {
99
+ /**
100
+ * the subset to read data from in pixels. Whole window if not specified.
101
+ */
102
+ window?: number[] | undefined;
103
+ /**
104
+ * the selection of samples to read from. Default is all samples.
105
+ * All samples if not specified.
106
+ */
107
+ samples?: number[] | undefined;
108
+ /**
109
+ * The optional decoder pool to use.
110
+ */
111
+ pool?: Pool | null | undefined;
112
+ /**
113
+ * The desired width of the output. When the width is not the
114
+ * same as the images, resampling will be performed.
115
+ */
116
+ width?: number | undefined;
117
+ /**
118
+ * The desired height of the output. When the width is not the
119
+ * same as the images, resampling will be performed.
120
+ */
121
+ height?: number | undefined;
122
+ /**
123
+ * The desired resampling method.
124
+ */
125
+ resampleMethod?: string | undefined;
126
+ /**
127
+ * An AbortSignal that may be signalled if the request is
128
+ * to be aborted
129
+ */
130
+ signal?: AbortSignal | undefined;
131
+ /**
132
+ * The value to use for parts of the image
133
+ * outside of the images extent. When multiple samples are requested and `interleave` is
134
+ * `false`, an array of fill values can be passed.
135
+ */
136
+ fillValue?: number | number[] | undefined;
137
+ /**
138
+ * whether the data shall be read
139
+ * in one single array or separate arrays.
140
+ */
141
+ interleave?: boolean | undefined;
142
+ };
143
+ export type ReadRGBOptions = {
144
+ /**
145
+ * the subset to read data from in pixels. Whole window if not specified.
146
+ */
147
+ window?: number[] | undefined;
148
+ /**
149
+ * The optional decoder pool to use.
150
+ */
151
+ pool?: Pool | null | undefined;
152
+ /**
153
+ * The desired width of the output. When the width is no the
154
+ * same as the images, resampling will be performed.
155
+ */
156
+ width?: number | undefined;
157
+ /**
158
+ * The desired height of the output. When the width is no the
159
+ * same as the images, resampling will be performed.
160
+ */
161
+ height?: number | undefined;
162
+ /**
163
+ * The desired resampling method.
164
+ */
165
+ resampleMethod?: string | undefined;
166
+ /**
167
+ * Enable reading alpha channel if present.
168
+ */
169
+ enableAlpha?: boolean | undefined;
170
+ /**
171
+ * An AbortSignal that may be signalled if the request is
172
+ * to be aborted
173
+ */
174
+ signal?: AbortSignal | undefined;
175
+ /**
176
+ * whether the data shall be read
177
+ * in one single array or separate arrays.
178
+ */
179
+ interleave?: boolean | undefined;
180
+ };
181
+ export type BlockedSourceOptions = {
182
+ /**
183
+ * Block size for a BlockedSource.
184
+ */
185
+ blockSize?: number | null | undefined;
186
+ /**
187
+ * The number of blocks to cache.
188
+ */
189
+ cacheSize?: number | undefined;
190
+ };
191
+ export type RemoteSourceOptions = {
192
+ /**
193
+ * Additional headers to add to each request
194
+ */
195
+ headers?: any;
196
+ /**
197
+ * Maximum number of ranges to request in a single HTTP request. 0 means no multi-range requests.
198
+ */
199
+ maxRanges?: number | undefined;
200
+ /**
201
+ * Whether to allow full file responses when requesting ranges
202
+ */
203
+ allowFullFile?: boolean | undefined;
204
+ /**
205
+ * When the Fetch API would be used, force using XMLHttpRequest instead.
206
+ */
207
+ forceXHR?: boolean | undefined;
208
+ };
97
209
  export type GeoTIFFOptions = {
98
210
  /**
99
211
  * whether or not decoded tiles shall be cached.
@@ -106,51 +218,37 @@ export type GeoTIFFOptions = {
106
218
  */
107
219
  /**
108
220
  * The abstraction for a whole GeoTIFF file.
109
- * @augments GeoTIFFBase
110
221
  */
111
222
  export class GeoTIFF extends GeoTIFFBase {
112
223
  /**
113
224
  * Parse a (Geo)TIFF file from the given source.
114
225
  *
115
- * @param {*} source The source of data to parse from.
226
+ * @param {BaseSource} source The source of data to parse from.
116
227
  * @param {GeoTIFFOptions} [options] Additional options.
117
228
  * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
118
229
  * to be aborted
119
230
  */
120
- static fromSource(source: any, options?: GeoTIFFOptions, signal?: AbortSignal): Promise<GeoTIFF>;
231
+ static fromSource(source: BaseSource, options?: GeoTIFFOptions, signal?: AbortSignal): Promise<GeoTIFF>;
121
232
  /**
122
233
  * @constructor
123
- * @param {*} source The datasource to read from.
234
+ * @param {BaseSource} source The datasource to read from.
124
235
  * @param {boolean} littleEndian Whether the image uses little endian.
125
236
  * @param {boolean} bigTiff Whether the image uses bigTIFF conventions.
126
237
  * @param {number} firstIFDOffset The numeric byte-offset from the start of the image
127
238
  * to the first IFD.
128
239
  * @param {GeoTIFFOptions} [options] further options.
129
240
  */
130
- constructor(source: any, littleEndian: boolean, bigTiff: boolean, firstIFDOffset: number, options?: GeoTIFFOptions);
131
- source: any;
241
+ constructor(source: BaseSource, littleEndian: boolean, bigTiff: boolean, firstIFDOffset: number, options?: GeoTIFFOptions);
242
+ source: BaseSource;
132
243
  parser: ImageFileDirectoryParser;
133
244
  littleEndian: boolean;
134
245
  bigTiff: boolean;
135
246
  firstIFDOffset: number;
136
247
  cache: boolean;
137
248
  ifdRequests: any[];
138
- ghostValues: {} | null;
249
+ ghostValues: any;
139
250
  getSlice(offset: any, size: any): Promise<DataSlice>;
140
251
  requestIFD(index: any): Promise<any>;
141
- /**
142
- * Get the n-th internal subfile of an image. By default, the first is returned.
143
- *
144
- * @param {number} [index=0] the index of the image to return.
145
- * @returns {Promise<GeoTIFFImage>} the image at the given index
146
- */
147
- getImage(index?: number): Promise<GeoTIFFImage>;
148
- /**
149
- * Returns the count of the internal subfiles.
150
- *
151
- * @returns {Promise<number>} the number of internal subfile images
152
- */
153
- getImageCount(): Promise<number>;
154
252
  /**
155
253
  * Get the values of the COG ghost area as a parsed map.
156
254
  * See https://gdal.org/drivers/raster/cog.html#header-ghost-area for reference
@@ -162,7 +260,7 @@ export class GeoTIFF extends GeoTIFFBase {
162
260
  * N.B. After the GeoTIFF has been completely processed it needs
163
261
  * to be closed but only if it has been constructed from a file.
164
262
  */
165
- close(): any;
263
+ close(): false | Promise<void>;
166
264
  }
167
265
  import { BaseClient } from './source/client/base.js';
168
266
  /**
@@ -183,19 +281,6 @@ export class MultiGeoTIFF extends GeoTIFFBase {
183
281
  fileDirectoriesPerFileParsing: any;
184
282
  imageCount: number | null;
185
283
  parseFileDirectoriesPerFile(): Promise<import("./imagefiledirectory.js").ImageFileDirectory[]>;
186
- /**
187
- * Get the n-th internal subfile of an image. By default, the first is returned.
188
- *
189
- * @param {number} [index=0] the index of the image to return.
190
- * @returns {Promise<GeoTIFFImage>} the image at the given index
191
- */
192
- getImage(index?: number): Promise<GeoTIFFImage>;
193
- /**
194
- * Returns the count of the internal subfiles.
195
- *
196
- * @returns {Promise<number>} the number of internal subfile images
197
- */
198
- getImageCount(): Promise<number>;
199
284
  imageCounts: number[] | undefined;
200
285
  }
201
286
  import * as globals from './globals.js';
@@ -208,6 +293,22 @@ import Pool from './pool.js';
208
293
  import GeoTIFFImage from './geotiffimage.js';
209
294
  import { BaseResponse } from './source/client/base.js';
210
295
  declare class GeoTIFFBase {
296
+ /**
297
+ * @param {number} [_index=0] the index of the image to return.
298
+ * @returns {Promise<GeoTIFFImage>} the image at the given index
299
+ */
300
+ getImage(_index?: number): Promise<GeoTIFFImage>;
301
+ /**
302
+ * @returns {Promise<number>} the number of internal subfile images
303
+ */
304
+ getImageCount(): Promise<number>;
305
+ /**
306
+ * @typedef {Object} ReadRastersWindowOptions
307
+ * @property {number} [resX] desired Y resolution (world units per pixel)
308
+ * @property {number} [resY] desired X resolution (world units per pixel)
309
+ * @property {Array<number>} [bbox] the subset to read data from in
310
+ * geographical coordinates. Whole image if not specified.
311
+ */
211
312
  /**
212
313
  * (experimental) Reads raster data from the best fitting image. This function uses
213
314
  * the image with the lowest resolution that is still a higher resolution than the
@@ -217,11 +318,26 @@ declare class GeoTIFFBase {
217
318
  * Then, the [readRasters]{@link GeoTIFFImage#readRasters} method of the selected
218
319
  * image is called and the result returned.
219
320
  * @see GeoTIFFImage.readRasters
220
- * @param {import('./geotiffimage').ReadRasterOptions} [options={}] optional parameters
321
+ * @param {ReadRastersOptions & ReadRastersWindowOptions} options optional parameters
221
322
  * @returns {Promise<ReadRasterResult>} the decoded array(s), with `height` and `width`, as a promise
222
323
  */
223
- readRasters(options?: import("./geotiffimage").ReadRasterOptions): Promise<ReadRasterResult>;
324
+ readRasters(options?: ReadRastersOptions & {
325
+ /**
326
+ * desired Y resolution (world units per pixel)
327
+ */
328
+ resX?: number | undefined;
329
+ /**
330
+ * desired X resolution (world units per pixel)
331
+ */
332
+ resY?: number | undefined;
333
+ /**
334
+ * the subset to read data from in
335
+ * geographical coordinates. Whole image if not specified.
336
+ */
337
+ bbox?: number[] | undefined;
338
+ }): Promise<ReadRasterResult>;
224
339
  }
340
+ import type { BaseSource } from './source/basesource.js';
225
341
  import { ImageFileDirectoryParser } from './imagefiledirectory.js';
226
342
  import DataSlice from './dataslice.js';
227
343
  export { globals, registerTag, rgb, getDecoder, addDecoder, setLogger, Pool, GeoTIFFImage, BaseClient, BaseResponse };
@@ -1 +1 @@
1
- {"version":3,"file":"geotiff.d.ts","sourceRoot":"","sources":["../dist-module/geotiff.js"],"names":[],"mappings":"AA2eA;;;;;;;;GAQG;AACH,6BAPW,MAAM,YACN,MAAM,WAEN,WAAW,GAET,OAAO,CAAC,OAAO,CAAC,CAI5B;AACD;;;;;;;;GAQG;AACH,yCAPW,UAAU,YACV,MAAM,WAEN,WAAW,GAET,OAAO,CAAC,OAAO,CAAC,CAI5B;AACD;;;;;;;GAOG;AACH,6CALW,WAAW,WACX,WAAW,GAET,OAAO,CAAC,OAAO,CAAC,CAI5B;AACD;;;;;;;;;;;GAWG;AACH,+BALW,MAAM,WACN,WAAW,GAET,OAAO,CAAC,OAAO,CAAC,CAI5B;AACD;;;;;;;;;GASG;AACH,+BALW,IAAI,GAAC,IAAI,WACT,WAAW,GAET,OAAO,CAAC,OAAO,CAAC,CAI5B;AACD;;;;;;;;;;GAUG;AACH,kCATW,MAAM,iBACN,MAAM,EAAE,0BAIR,WAAW,GAET,OAAO,CAAC,YAAY,CAAC,CAMjC;AACD;;;;GAIG;AACH,kEAEC;;;yBAziBY,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY;yBAI1G;IAAE,MAAM,EAAC,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;;;;;;uCAMhC,UAAU,GAAG,UAAU;;;;;;4CAMvB,UAAU,EAAE,GAAG,UAAU;;;;;;+BAMzB,wBAAwB,GAAG,6BAA6B;;;;;;;AAuLrE;;;GAGG;AACH;;;GAGG;AACH;IAoII;;;;;;;OAOG;IACH,0BALW,GAAC,YACD,cAAc,WACd,WAAW,oBAoCrB;IA5KD;;;;;;;;OAQG;IACH,oBAPW,GAAC,gBACD,OAAO,WACP,OAAO,kBACP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AMC;IACD,qCAqCC;IAmCD;;;;OAIG;IACH,kBAFa,OAAO,KAAQ,CA6B3B;IA2CD;;;;OAIG;IACH,+BAKC;CACJ;2BAnfwC,yBAAyB;AAsflE;;;GAGG;AACH;IACI;;;;OAIG;IACH,sBAHW,OAAO,iBACP,OAAO,EAAE,EAUnB;IANG,kBAAwB;IACxB,yBAAkC;IAClC,sBAAkD;IAClD,sFAAkC;IAClC,mCAAyC;IACzC,0BAAsB;IAE1B,+FAKC;IAwCG,kCAA8C;CAIrD;yBAtjBwB,cAAc;4BAFmB,cAAc;qBAGnD,UAAU;2BACQ,wBAAwB;2BAAxB,wBAAwB;0BACrC,cAAc;iBAZvB,WAAW;yBAHH,mBAAmB;6BAQH,yBAAyB;AAgMlE;IACI;;;OAGG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,YAAY,CAAC,CAIjC;IACD;;OAEG;IACH,iBAFa,OAAO,CAAC,MAAM,CAAC,CAI3B;IACD;;;;;;OAMG;IACH;;;;;;;;;;;OAWG;IACH,sBAHW,kBAAkB;;;;;;;;;;;;;;KAA2B,GAC3C,OAAO,CAAC,gBAAgB,CAAC,CAiFrC;CACJ;gCAzS+B,wBAAwB;yCAPf,yBAAyB;sBAP5C,gBAAgB"}
@@ -98,7 +98,69 @@ Object.defineProperty(exports, "BaseDecoder", { enumerable: true, get: function
98
98
  * `(TypedArray | TypedArray[]) & { height: number; width: number}`
99
99
  * @typedef {TypedArrayWithDimensions | TypedArrayArrayWithDimensions} ReadRasterResult
100
100
  */
101
+ /**
102
+ * @typedef {Object} ReadRastersOptions
103
+ * @property {Array<number>} [window] the subset to read data from in pixels. Whole window if not specified.
104
+ * @property {Array<number>} [samples] the selection of samples to read from. Default is all samples.
105
+ * All samples if not specified.
106
+ * @property {Pool|null} [pool=null] The optional decoder pool to use.
107
+ * @property {number} [width] The desired width of the output. When the width is not the
108
+ * same as the images, resampling will be performed.
109
+ * @property {number} [height] The desired height of the output. When the width is not the
110
+ * same as the images, resampling will be performed.
111
+ * @property {string} [resampleMethod='nearest'] The desired resampling method.
112
+ * @property {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
113
+ * to be aborted
114
+ * @property {number|number[]} [fillValue] The value to use for parts of the image
115
+ * outside of the images extent. When multiple samples are requested and `interleave` is
116
+ * `false`, an array of fill values can be passed.
117
+ * @property {boolean|true|false} [interleave] whether the data shall be read
118
+ * in one single array or separate arrays.
119
+ */
120
+ /**
121
+ * @typedef {Object} ReadRGBOptions
122
+ * @property {Array<number>} [window] the subset to read data from in pixels. Whole window if not specified.
123
+ * @property {Pool|null} [pool=null] The optional decoder pool to use.
124
+ * @property {number} [width] The desired width of the output. When the width is no the
125
+ * same as the images, resampling will be performed.
126
+ * @property {number} [height] The desired height of the output. When the width is no the
127
+ * same as the images, resampling will be performed.
128
+ * @property {string} [resampleMethod='nearest'] The desired resampling method.
129
+ * @property {boolean} [enableAlpha=false] Enable reading alpha channel if present.
130
+ * @property {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
131
+ * to be aborted
132
+ * @property {boolean|true|false} [interleave] whether the data shall be read
133
+ * in one single array or separate arrays.
134
+ */
135
+ /**
136
+ * @typedef {Object} BlockedSourceOptions
137
+ * @property {number|null} [blockSize=null] Block size for a BlockedSource.
138
+ * @property {number} [cacheSize=100] The number of blocks to cache.
139
+ */
140
+ /**
141
+ * @typedef {Object} RemoteSourceOptions
142
+ * @property {Object} [headers={}] Additional headers to add to each request
143
+ * @property {number} [maxRanges=0] Maximum number of ranges to request in a single HTTP request. 0 means no multi-range requests.
144
+ * @property {boolean} [allowFullFile=false] Whether to allow full file responses when requesting ranges
145
+ * @property {boolean} [forceXHR=false] When the Fetch API would be used, force using XMLHttpRequest instead.
146
+ */
147
+ /**
148
+ * @overload
149
+ * @param {DataSlice} dataSlice
150
+ * @param {0x0002} fieldType
151
+ * @param {number} count
152
+ * @param {number} offset
153
+ * @returns {string}
154
+ */
155
+ /**
156
+ * @param {DataSlice} dataSlice
157
+ * @param {import('./globals.js').FieldType} fieldType
158
+ * @param {number} count
159
+ * @param {number} offset
160
+ * @returns {TypedArray|Array<number>|string}
161
+ */
101
162
  function getValues(dataSlice, fieldType, count, offset) {
163
+ /** @type {TypedArray|Array|null} */
102
164
  let values = null;
103
165
  let readMethod = null;
104
166
  const fieldTypeLength = (0, globals_js_1.getFieldTypeSize)(fieldType);
@@ -156,7 +218,10 @@ function getValues(dataSlice, fieldType, count, offset) {
156
218
  readMethod = dataSlice.readFloat64;
157
219
  break;
158
220
  default:
159
- throw new RangeError(`Invalid field type: ${fieldType}`);
221
+ // will throw below
222
+ }
223
+ if (values === null || readMethod === null) {
224
+ throw new RangeError(`Invalid field type: ${fieldType}`);
160
225
  }
161
226
  // normal fields
162
227
  if (!(fieldType === globals_js_1.fieldTypes.RATIONAL || fieldType === globals_js_1.fieldTypes.SRATIONAL)) {
@@ -171,7 +236,7 @@ function getValues(dataSlice, fieldType, count, offset) {
171
236
  }
172
237
  }
173
238
  if (fieldType === globals_js_1.fieldTypes.ASCII) {
174
- return new TextDecoder('utf-8').decode(values);
239
+ return new TextDecoder('utf-8').decode(/** @type {Uint8Array} */ (values));
175
240
  }
176
241
  return values;
177
242
  }
@@ -186,6 +251,26 @@ class GeoTIFFImageIndexError extends Error {
186
251
  }
187
252
  }
188
253
  class GeoTIFFBase {
254
+ /**
255
+ * @param {number} [_index=0] the index of the image to return.
256
+ * @returns {Promise<GeoTIFFImage>} the image at the given index
257
+ */
258
+ async getImage(_index = 0) {
259
+ throw new Error('Not implemented');
260
+ }
261
+ /**
262
+ * @returns {Promise<number>} the number of internal subfile images
263
+ */
264
+ async getImageCount() {
265
+ throw new Error('Not implemented');
266
+ }
267
+ /**
268
+ * @typedef {Object} ReadRastersWindowOptions
269
+ * @property {number} [resX] desired Y resolution (world units per pixel)
270
+ * @property {number} [resY] desired X resolution (world units per pixel)
271
+ * @property {Array<number>} [bbox] the subset to read data from in
272
+ * geographical coordinates. Whole image if not specified.
273
+ */
189
274
  /**
190
275
  * (experimental) Reads raster data from the best fitting image. This function uses
191
276
  * the image with the lowest resolution that is still a higher resolution than the
@@ -195,7 +280,7 @@ class GeoTIFFBase {
195
280
  * Then, the [readRasters]{@link GeoTIFFImage#readRasters} method of the selected
196
281
  * image is called and the result returned.
197
282
  * @see GeoTIFFImage.readRasters
198
- * @param {import('./geotiffimage').ReadRasterOptions} [options={}] optional parameters
283
+ * @param {ReadRastersOptions & ReadRastersWindowOptions} options optional parameters
199
284
  * @returns {Promise<ReadRasterResult>} the decoded array(s), with `height` and `width`, as a promise
200
285
  */
201
286
  async readRasters(options = {}) {
@@ -285,12 +370,11 @@ class GeoTIFFBase {
285
370
  */
286
371
  /**
287
372
  * The abstraction for a whole GeoTIFF file.
288
- * @augments GeoTIFFBase
289
373
  */
290
374
  class GeoTIFF extends GeoTIFFBase {
291
375
  /**
292
376
  * @constructor
293
- * @param {*} source The datasource to read from.
377
+ * @param {BaseSource} source The datasource to read from.
294
378
  * @param {boolean} littleEndian Whether the image uses little endian.
295
379
  * @param {boolean} bigTiff Whether the image uses bigTIFF conventions.
296
380
  * @param {number} firstIFDOffset The numeric byte-offset from the start of the image
@@ -360,7 +444,7 @@ class GeoTIFF extends GeoTIFFBase {
360
444
  * @returns {Promise<GeoTIFFImage>} the image at the given index
361
445
  */
362
446
  async getImage(index = 0) {
363
- return new geotiffimage_js_1.default(await this.requestIFD(index), this.dataView, this.littleEndian, this.cache, this.source);
447
+ return new geotiffimage_js_1.default(await this.requestIFD(index), this.littleEndian, this.cache, this.source);
364
448
  }
365
449
  /**
366
450
  * Returns the count of the internal subfiles.
@@ -408,6 +492,7 @@ class GeoTIFF extends GeoTIFFBase {
408
492
  slice = await this.getSlice(offset, metadataSize);
409
493
  }
410
494
  const fullString = getValues(slice, globals_js_1.fieldTypes.ASCII, metadataSize, offset);
495
+ /** @type {Object} */
411
496
  this.ghostValues = {};
412
497
  fullString
413
498
  .split('\n')
@@ -422,7 +507,7 @@ class GeoTIFF extends GeoTIFFBase {
422
507
  /**
423
508
  * Parse a (Geo)TIFF file from the given source.
424
509
  *
425
- * @param {*} source The source of data to parse from.
510
+ * @param {BaseSource} source The source of data to parse from.
426
511
  * @param {GeoTIFFOptions} [options] Additional options.
427
512
  * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
428
513
  * to be aborted
@@ -507,7 +592,11 @@ class MultiGeoTIFF extends GeoTIFFBase {
507
592
  * @returns {Promise<GeoTIFFImage>} the image at the given index
508
593
  */
509
594
  async getImage(index = 0) {
595
+ // Initialize this.imageCounts if not yet done
510
596
  await this.getImageCount();
597
+ if (!this.imageCounts) {
598
+ throw new Error('Image counts not available');
599
+ }
511
600
  await this.parseFileDirectoriesPerFile();
512
601
  let visited = 0;
513
602
  let relativeIndex = 0;
@@ -515,7 +604,7 @@ class MultiGeoTIFF extends GeoTIFFBase {
515
604
  const imageFile = this.imageFiles[i];
516
605
  for (let ii = 0; ii < this.imageCounts[i]; ii++) {
517
606
  if (index === visited) {
518
- return new geotiffimage_js_1.default(await imageFile.requestIFD(relativeIndex), imageFile.dataView, imageFile.littleEndian, imageFile.cache, imageFile.source);
607
+ return new geotiffimage_js_1.default(await imageFile.requestIFD(relativeIndex), imageFile.littleEndian, imageFile.cache, imageFile.source);
519
608
  }
520
609
  visited++;
521
610
  relativeIndex++;
@@ -544,26 +633,26 @@ exports.MultiGeoTIFF = MultiGeoTIFF;
544
633
  /**
545
634
  * Creates a new GeoTIFF from a remote URL.
546
635
  * @param {string} url The URL to access the image from
547
- * @param {object} [options] Additional options to pass to the source.
636
+ * @param {RemoteSourceOptions} [options] Additional options to pass to the source.
548
637
  * See {@link makeRemoteSource} for details.
549
638
  * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
550
639
  * to be aborted
551
640
  * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
552
641
  */
553
642
  async function fromUrl(url, options = {}, signal) {
554
- return GeoTIFF.fromSource((0, remote_js_1.makeRemoteSource)(url, options), signal);
643
+ return GeoTIFF.fromSource((0, remote_js_1.makeRemoteSource)(url, options), undefined, signal);
555
644
  }
556
645
  /**
557
646
  * Creates a new GeoTIFF from a custom {@link BaseClient}.
558
647
  * @param {BaseClient} client The client.
559
- * @param {object} [options] Additional options to pass to the source.
648
+ * @param {RemoteSourceOptions} [options] Additional options to pass to the source.
560
649
  * See {@link makeRemoteSource} for details.
561
650
  * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
562
651
  * to be aborted
563
652
  * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
564
653
  */
565
654
  async function fromCustomClient(client, options = {}, signal) {
566
- return GeoTIFF.fromSource((0, remote_js_1.makeCustomSource)(client, options), signal);
655
+ return GeoTIFF.fromSource((0, remote_js_1.makeCustomSource)(client, options), undefined, signal);
567
656
  }
568
657
  /**
569
658
  * Construct a new GeoTIFF from an
@@ -574,7 +663,7 @@ async function fromCustomClient(client, options = {}, signal) {
574
663
  * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
575
664
  */
576
665
  async function fromArrayBuffer(arrayBuffer, signal) {
577
- return GeoTIFF.fromSource((0, arraybuffer_js_1.makeBufferSource)(arrayBuffer), signal);
666
+ return GeoTIFF.fromSource((0, arraybuffer_js_1.makeBufferSource)(arrayBuffer), undefined, signal);
578
667
  }
579
668
  /**
580
669
  * Construct a GeoTIFF from a local file path. This uses the node
@@ -589,7 +678,7 @@ async function fromArrayBuffer(arrayBuffer, signal) {
589
678
  * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
590
679
  */
591
680
  async function fromFile(path, signal) {
592
- return GeoTIFF.fromSource((0, file_js_1.makeFileSource)(path), signal);
681
+ return GeoTIFF.fromSource((0, file_js_1.makeFileSource)(path), undefined, signal);
593
682
  }
594
683
  /**
595
684
  * Construct a GeoTIFF from an HTML
@@ -602,13 +691,13 @@ async function fromFile(path, signal) {
602
691
  * @returns {Promise<GeoTIFF>} The resulting GeoTIFF file.
603
692
  */
604
693
  async function fromBlob(blob, signal) {
605
- return GeoTIFF.fromSource((0, filereader_js_1.makeFileReaderSource)(blob), signal);
694
+ return GeoTIFF.fromSource((0, filereader_js_1.makeFileReaderSource)(blob), undefined, signal);
606
695
  }
607
696
  /**
608
697
  * Construct a MultiGeoTIFF from the given URLs.
609
698
  * @param {string} mainUrl The URL for the main file.
610
699
  * @param {string[]} overviewUrls An array of URLs for the overview images.
611
- * @param {Object} [options] Additional options to pass to the source.
700
+ * @param {RemoteSourceOptions} [options] Additional options to pass to the source.
612
701
  * See [makeRemoteSource]{@link module:source.makeRemoteSource}
613
702
  * for details.
614
703
  * @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
@@ -616,14 +705,15 @@ async function fromBlob(blob, signal) {
616
705
  * @returns {Promise<MultiGeoTIFF>} The resulting MultiGeoTIFF file.
617
706
  */
618
707
  async function fromUrls(mainUrl, overviewUrls = [], options = {}, signal) {
619
- const mainFile = await GeoTIFF.fromSource((0, remote_js_1.makeRemoteSource)(mainUrl, options), signal);
620
- const overviewFiles = await Promise.all(overviewUrls.map((url) => GeoTIFF.fromSource((0, remote_js_1.makeRemoteSource)(url, options))));
708
+ const mainFile = await GeoTIFF.fromSource((0, remote_js_1.makeRemoteSource)(mainUrl, options), undefined, signal);
709
+ const overviewFiles = await Promise.all(overviewUrls.map((url) => GeoTIFF.fromSource((0, remote_js_1.makeRemoteSource)(url, options), undefined, signal)));
621
710
  return new MultiGeoTIFF(mainFile, overviewFiles);
622
711
  }
623
712
  /**
624
713
  * Main creating function for GeoTIFF files.
625
- * @param {(Array)} array of pixel values
626
- * @returns {metadata} metadata
714
+ * @param {Array} values of pixel values
715
+ * @param {Object} metadata
716
+ * @returns {ArrayBuffer}
627
717
  */
628
718
  function writeArrayBuffer(values, metadata) {
629
719
  return (0, geotiffwriter_js_1.writeGeotiff)(values, metadata);