1
+ /** @module geotiff */
1
2
import GeoTIFFImage from './geotiffimage.js' ;
2
3
import DataView64 from './dataview64.js' ;
3
4
import DataSlice from './dataslice.js' ;
@@ -20,6 +21,11 @@ export { rgb };
20
21
export { getDecoder , addDecoder } ;
21
22
export { setLogger } ;
22
23
24
+ /**
25
+ * @typedef {Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array }
26
+ * TypedArray
27
+ */
28
+
23
29
function getFieldTypeLength ( fieldType ) {
24
30
switch ( fieldType ) {
25
31
case fieldTypes . BYTE : case fieldTypes . ASCII : case fieldTypes . SBYTE : case fieldTypes . UNDEFINED :
@@ -174,26 +180,7 @@ class GeoTIFFBase {
174
180
* Then, the [readRasters]{@link GeoTIFFImage#readRasters} method of the selected
175
181
* image is called and the result returned.
176
182
* @see GeoTIFFImage.readRasters
177
- * @param {Object } [options={}] optional parameters
178
- * @param {Array } [options.window=whole image] the subset to read data from.
179
- * @param {Array } [options.bbox=whole image] the subset to read data from in
180
- * geographical coordinates.
181
- * @param {Array } [options.samples=all samples] the selection of samples to read from.
182
- * @param {Boolean } [options.interleave=false] whether the data shall be read
183
- * in one single array or separate
184
- * arrays.
185
- * @param {Number } [options.pool=null] The optional decoder pool to use.
186
- * @param {Number } [options.width] The desired width of the output. When the width is not the
187
- * same as the images, resampling will be performed.
188
- * @param {Number } [options.height] The desired height of the output. When the width is not the
189
- * same as the images, resampling will be performed.
190
- * @param {String } [options.resampleMethod='nearest'] The desired resampling method.
191
- * @param {AbortSignal } [options.signal] An AbortSignal that may be signalled if the request is
192
- * to be aborted
193
- * @param {Number|Number[] } [options.fillValue] The value to use for parts of the image
194
- * outside of the images extent. When multiple
195
- * samples are requested, an array of fill values
196
- * can be passed.
183
+ * @param {import('./geotiffimage').ReadRasterOptions } [options={}] optional parameters
197
184
* @returns {Promise.<(TypedArray|TypedArray[])> } the decoded arrays as a promise
198
185
*/
199
186
async readRasters ( options = { } ) {
@@ -290,20 +277,24 @@ class GeoTIFFBase {
290
277
}
291
278
}
292
279
280
+ /**
281
+ * @typedef {Object } GeoTIFFOptions
282
+ * @property {boolean } [cache=false] whether or not decoded tiles shall be cached.
283
+ */
284
+
293
285
/**
294
286
* The abstraction for a whole GeoTIFF file.
295
287
* @augments GeoTIFFBase
296
288
*/
297
289
class GeoTIFF extends GeoTIFFBase {
298
290
/**
299
291
* @constructor
300
- * @param {Source } source The datasource to read from.
301
- * @param {Boolean } littleEndian Whether the image uses little endian.
302
- * @param {Boolean } bigTiff Whether the image uses bigTIFF conventions.
303
- * @param {Number } firstIFDOffset The numeric byte-offset from the start of the image
292
+ * @param {* } source The datasource to read from.
293
+ * @param {boolean } littleEndian Whether the image uses little endian.
294
+ * @param {boolean } bigTiff Whether the image uses bigTIFF conventions.
295
+ * @param {number } firstIFDOffset The numeric byte-offset from the start of the image
304
296
* to the first IFD.
305
- * @param {Object } [options] further options.
306
- * @param {Boolean } [options.cache=false] whether or not decoded tiles shall be cached.
297
+ * @param {GeoTIFFOptions } [options] further options.
307
298
*/
308
299
constructor ( source , littleEndian , bigTiff , firstIFDOffset , options = { } ) {
309
300
super ( ) ;
@@ -450,7 +441,7 @@ class GeoTIFF extends GeoTIFFBase {
450
441
/**
451
442
* Get the n-th internal subfile of an image. By default, the first is returned.
452
443
*
453
- * @param {Number } [index=0] the index of the image to return.
444
+ * @param {number } [index=0] the index of the image to return.
454
445
* @returns {Promise<GeoTIFFImage> } the image at the given index
455
446
*/
456
447
async getImage ( index = 0 ) {
@@ -464,7 +455,7 @@ class GeoTIFF extends GeoTIFFBase {
464
455
/**
465
456
* Returns the count of the internal subfiles.
466
457
*
467
- * @returns {Number } the number of internal subfile images
458
+ * @returns {number } the number of internal subfile images
468
459
*/
469
460
async getImageCount ( ) {
470
461
let index = 0 ;
@@ -521,8 +512,8 @@ class GeoTIFF extends GeoTIFFBase {
521
512
/**
522
513
* Parse a (Geo)TIFF file from the given source.
523
514
*
524
- * @param {source~Source } source The source of data to parse from.
525
- * @param {object } options Additional options.
515
+ * @param {* } source The source of data to parse from.
516
+ * @param {GeoTIFFOptions } [ options] Additional options.
526
517
* @param {AbortSignal } [signal] An AbortSignal that may be signalled if the request is
527
518
* to be aborted
528
519
*/
@@ -608,7 +599,7 @@ class MultiGeoTIFF extends GeoTIFFBase {
608
599
/**
609
600
* Get the n-th internal subfile of an image. By default, the first is returned.
610
601
*
611
- * @param {Number } [index=0] the index of the image to return.
602
+ * @param {number } [index=0] the index of the image to return.
612
603
* @returns {GeoTIFFImage } the image at the given index
613
604
*/
614
605
async getImage ( index = 0 ) {
@@ -638,7 +629,7 @@ class MultiGeoTIFF extends GeoTIFFBase {
638
629
/**
639
630
* Returns the count of the internal subfiles.
640
631
*
641
- * @returns {Number } the number of internal subfile images
632
+ * @returns {number } the number of internal subfile images
642
633
*/
643
634
async getImageCount ( ) {
644
635
if ( this . imageCount !== null ) {
@@ -673,7 +664,7 @@ export async function fromUrl(url, options = {}, signal) {
673
664
* @param {ArrayBuffer } arrayBuffer The data to read the file from.
674
665
* @param {AbortSignal } [signal] An AbortSignal that may be signalled if the request is
675
666
* to be aborted
676
- * @returns {Promise. <GeoTIFF> } The resulting GeoTIFF file.
667
+ * @returns {Promise<GeoTIFF> } The resulting GeoTIFF file.
677
668
*/
678
669
export async function fromArrayBuffer ( arrayBuffer , signal ) {
679
670
return GeoTIFF . fromSource ( makeBufferSource ( arrayBuffer ) , signal ) ;
@@ -703,7 +694,7 @@ export async function fromFile(path, signal) {
703
694
* @param {Blob|File } blob The Blob or File object to read from.
704
695
* @param {AbortSignal } [signal] An AbortSignal that may be signalled if the request is
705
696
* to be aborted
706
- * @returns {Promise. <GeoTIFF> } The resulting GeoTIFF file.
697
+ * @returns {Promise<GeoTIFF> } The resulting GeoTIFF file.
707
698
*/
708
699
export async function fromBlob ( blob , signal ) {
709
700
return GeoTIFF . fromSource ( makeFileReaderSource ( blob ) , signal ) ;
@@ -713,12 +704,12 @@ export async function fromBlob(blob, signal) {
713
704
* Construct a MultiGeoTIFF from the given URLs.
714
705
* @param {string } mainUrl The URL for the main file.
715
706
* @param {string[] } overviewUrls An array of URLs for the overview images.
716
- * @param {object } [options] Additional options to pass to the source.
707
+ * @param {Object } [options] Additional options to pass to the source.
717
708
* See [makeRemoteSource]{@link module:source.makeRemoteSource}
718
709
* for details.
719
710
* @param {AbortSignal } [signal] An AbortSignal that may be signalled if the request is
720
711
* to be aborted
721
- * @returns {Promise. <MultiGeoTIFF> } The resulting MultiGeoTIFF file.
712
+ * @returns {Promise<MultiGeoTIFF> } The resulting MultiGeoTIFF file.
722
713
*/
723
714
export async function fromUrls ( mainUrl , overviewUrls = [ ] , options = { } , signal ) {
724
715
const mainFile = await GeoTIFF . fromSource ( makeRemoteSource ( mainUrl , options ) , signal ) ;
0 commit comments