geotiff 3.0.0 → 3.0.2
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.
- package/dist-browser/geotiff.js +3 -2
- package/dist-browser/geotiff.js.map +1 -1
- package/dist-module/compression/basedecoder.d.ts +4 -0
- package/dist-module/compression/basedecoder.d.ts.map +1 -1
- package/dist-module/compression/basedecoder.js +6 -0
- package/dist-module/compression/index.d.ts +4 -4
- package/dist-module/compression/index.d.ts.map +1 -1
- package/dist-module/compression/index.js +4 -4
- package/dist-module/compression/jpeg.d.ts +6 -1
- package/dist-module/compression/jpeg.d.ts.map +1 -1
- package/dist-module/compression/jpeg.js +50 -5
- package/dist-module/compression/lzw.js +1 -1
- package/dist-module/compression/webimage.d.ts +1 -1
- package/dist-module/compression/webimage.d.ts.map +1 -1
- package/dist-module/compression/webimage.js +1 -1
- package/dist-module/dataslice.d.ts.map +1 -1
- package/dist-module/dataslice.js +2 -2
- package/dist-module/dataview64.d.ts +2 -2
- package/dist-module/dataview64.d.ts.map +1 -1
- package/dist-module/dataview64.js +4 -4
- package/dist-module/geotiff.d.ts +171 -45
- package/dist-module/geotiff.d.ts.map +1 -1
- package/dist-module/geotiff.js +119 -20
- package/dist-module/geotiffimage.d.ts +79 -112
- package/dist-module/geotiffimage.d.ts.map +1 -1
- package/dist-module/geotiffimage.js +99 -71
- package/dist-module/geotiffwriter.js +2 -2
- package/dist-module/globals.d.ts +48 -40
- package/dist-module/globals.d.ts.map +1 -1
- package/dist-module/globals.js +14 -10
- package/dist-module/imagefiledirectory.d.ts +2 -2
- package/dist-module/imagefiledirectory.d.ts.map +1 -1
- package/dist-module/imagefiledirectory.js +23 -12
- package/dist-module/logging.js +7 -7
- package/dist-module/pool.js +1 -1
- package/dist-module/predictor.js +1 -1
- package/dist-module/resample.d.ts +18 -18
- package/dist-module/resample.d.ts.map +1 -1
- package/dist-module/resample.js +12 -12
- package/dist-module/source/basesource.d.ts +7 -7
- package/dist-module/source/basesource.d.ts.map +1 -1
- package/dist-module/source/basesource.js +7 -7
- package/dist-module/source/blockedsource.d.ts +10 -10
- package/dist-module/source/blockedsource.d.ts.map +1 -1
- package/dist-module/source/blockedsource.js +12 -9
- package/dist-module/source/client/base.d.ts +8 -10
- package/dist-module/source/client/base.d.ts.map +1 -1
- package/dist-module/source/client/base.js +4 -3
- package/dist-module/source/client/fetch.d.ts +2 -7
- package/dist-module/source/client/fetch.d.ts.map +1 -1
- package/dist-module/source/client/fetch.js +7 -2
- package/dist-module/source/client/http.d.ts +4 -1
- package/dist-module/source/client/http.d.ts.map +1 -1
- package/dist-module/source/client/http.js +4 -4
- package/dist-module/source/client/xhr.d.ts +4 -1
- package/dist-module/source/client/xhr.d.ts.map +1 -1
- package/dist-module/source/client/xhr.js +1 -1
- package/dist-module/source/file.js +4 -4
- package/dist-module/source/filereader.js +1 -1
- package/dist-module/source/httputils.d.ts +14 -6
- package/dist-module/source/httputils.d.ts.map +1 -1
- package/dist-module/source/httputils.js +13 -12
- package/dist-module/source/remote.d.ts +31 -22
- package/dist-module/source/remote.d.ts.map +1 -1
- package/dist-module/source/remote.js +37 -13
- package/dist-module/utils.d.ts +7 -1
- package/dist-module/utils.d.ts.map +1 -1
- package/dist-module/utils.js +6 -0
- package/dist-module/worker/create.js +1 -1
- package/dist-node/compression/basedecoder.d.ts +4 -0
- package/dist-node/compression/basedecoder.d.ts.map +1 -1
- package/dist-node/compression/basedecoder.js +6 -0
- package/dist-node/compression/basedecoder.js.map +1 -1
- package/dist-node/compression/index.d.ts +4 -4
- package/dist-node/compression/index.d.ts.map +1 -1
- package/dist-node/compression/index.js +4 -4
- package/dist-node/compression/jpeg.d.ts +6 -1
- package/dist-node/compression/jpeg.d.ts.map +1 -1
- package/dist-node/compression/jpeg.js +50 -5
- package/dist-node/compression/jpeg.js.map +1 -1
- package/dist-node/compression/lzw.js +1 -1
- package/dist-node/compression/lzw.js.map +1 -1
- package/dist-node/compression/webimage.js +1 -1
- package/dist-node/compression/webimage.js.map +1 -1
- package/dist-node/dataslice.js +2 -2
- package/dist-node/dataslice.js.map +1 -1
- package/dist-node/dataview64.d.ts +2 -2
- package/dist-node/dataview64.d.ts.map +1 -1
- package/dist-node/dataview64.js +4 -4
- package/dist-node/dataview64.js.map +1 -1
- package/dist-node/geotiff.d.ts +171 -45
- package/dist-node/geotiff.d.ts.map +1 -1
- package/dist-node/geotiff.js +118 -20
- package/dist-node/geotiff.js.map +1 -1
- package/dist-node/geotiffimage.d.ts +80 -113
- package/dist-node/geotiffimage.d.ts.map +1 -1
- package/dist-node/geotiffimage.js +99 -71
- package/dist-node/geotiffimage.js.map +1 -1
- package/dist-node/geotiffwriter.js +2 -2
- package/dist-node/geotiffwriter.js.map +1 -1
- package/dist-node/globals.d.ts +48 -40
- package/dist-node/globals.d.ts.map +1 -1
- package/dist-node/globals.js +14 -10
- package/dist-node/globals.js.map +1 -1
- package/dist-node/imagefiledirectory.d.ts +2 -2
- package/dist-node/imagefiledirectory.d.ts.map +1 -1
- package/dist-node/imagefiledirectory.js +23 -12
- package/dist-node/imagefiledirectory.js.map +1 -1
- package/dist-node/logging.js +7 -7
- package/dist-node/logging.js.map +1 -1
- package/dist-node/pool.js +1 -1
- package/dist-node/pool.js.map +1 -1
- package/dist-node/predictor.js +1 -1
- package/dist-node/predictor.js.map +1 -1
- package/dist-node/resample.d.ts +18 -18
- package/dist-node/resample.d.ts.map +1 -1
- package/dist-node/resample.js +12 -12
- package/dist-node/source/basesource.d.ts +7 -7
- package/dist-node/source/basesource.d.ts.map +1 -1
- package/dist-node/source/basesource.js +7 -7
- package/dist-node/source/basesource.js.map +1 -1
- package/dist-node/source/blockedsource.d.ts +10 -10
- package/dist-node/source/blockedsource.d.ts.map +1 -1
- package/dist-node/source/blockedsource.js +12 -9
- package/dist-node/source/blockedsource.js.map +1 -1
- package/dist-node/source/client/base.d.ts +8 -10
- package/dist-node/source/client/base.d.ts.map +1 -1
- package/dist-node/source/client/base.js +4 -3
- package/dist-node/source/client/base.js.map +1 -1
- package/dist-node/source/client/fetch.d.ts +2 -6
- package/dist-node/source/client/fetch.d.ts.map +1 -1
- package/dist-node/source/client/fetch.js +7 -2
- package/dist-node/source/client/fetch.js.map +1 -1
- package/dist-node/source/client/http.d.ts +4 -1
- package/dist-node/source/client/http.d.ts.map +1 -1
- package/dist-node/source/client/http.js +4 -4
- package/dist-node/source/client/http.js.map +1 -1
- package/dist-node/source/client/xhr.d.ts +4 -1
- package/dist-node/source/client/xhr.d.ts.map +1 -1
- package/dist-node/source/client/xhr.js +1 -1
- package/dist-node/source/client/xhr.js.map +1 -1
- package/dist-node/source/file.js +4 -4
- package/dist-node/source/file.js.map +1 -1
- package/dist-node/source/filereader.js +1 -1
- package/dist-node/source/filereader.js.map +1 -1
- package/dist-node/source/httputils.d.ts +14 -6
- package/dist-node/source/httputils.d.ts.map +1 -1
- package/dist-node/source/httputils.js +13 -12
- package/dist-node/source/httputils.js.map +1 -1
- package/dist-node/source/remote.d.ts +31 -22
- package/dist-node/source/remote.d.ts.map +1 -1
- package/dist-node/source/remote.js +37 -13
- package/dist-node/source/remote.js.map +1 -1
- package/dist-node/utils.d.ts +7 -1
- package/dist-node/utils.d.ts.map +1 -1
- package/dist-node/utils.js +6 -0
- package/dist-node/utils.js.map +1 -1
- package/dist-node/worker/create.js +1 -1
- package/dist-node/worker/create.js.map +1 -1
- package/package.json +3 -54
|
@@ -1,87 +1,33 @@
|
|
|
1
1
|
export default GeoTIFFImage;
|
|
2
|
-
export type ReadRasterOptions = {
|
|
3
|
-
/**
|
|
4
|
-
* window] the subset to read data from in pixels.
|
|
5
|
-
*/
|
|
6
|
-
window?: number[] | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* image] the subset to read data from in
|
|
9
|
-
* geographical coordinates.
|
|
10
|
-
*/
|
|
11
|
-
bbox?: number[] | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* samples] the selection of samples to read from. Default is all samples.
|
|
14
|
-
*/
|
|
15
|
-
samples?: number[] | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* whether the data shall be read
|
|
18
|
-
* in one single array or separate
|
|
19
|
-
* arrays.
|
|
20
|
-
*/
|
|
21
|
-
interleave?: boolean | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* The optional decoder pool to use.
|
|
24
|
-
*/
|
|
25
|
-
pool?: Pool;
|
|
26
|
-
/**
|
|
27
|
-
* The desired width of the output. When the width is not the
|
|
28
|
-
* same as the images, resampling will be performed.
|
|
29
|
-
*/
|
|
30
|
-
width?: number | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* The desired height of the output. When the width is not the
|
|
33
|
-
* same as the images, resampling will be performed.
|
|
34
|
-
*/
|
|
35
|
-
height?: number | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* The desired resampling method.
|
|
38
|
-
*/
|
|
39
|
-
resampleMethod?: string | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* An AbortSignal that may be signalled if the request is
|
|
42
|
-
* to be aborted
|
|
43
|
-
*/
|
|
44
|
-
signal?: AbortSignal | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* The value to use for parts of the image
|
|
47
|
-
* outside of the images extent. When multiple
|
|
48
|
-
* samples are requested, an array of fill values
|
|
49
|
-
* can be passed.
|
|
50
|
-
*/
|
|
51
|
-
fillValue?: number | number[] | undefined;
|
|
52
|
-
};
|
|
53
|
-
export type TypedArray = import("./geotiff.js").TypedArray;
|
|
54
|
-
export type ReadRasterResult = import("./geotiff.js").ReadRasterResult;
|
|
55
2
|
/**
|
|
56
3
|
* GeoTIFF sub-file image.
|
|
57
4
|
*/
|
|
58
5
|
declare class GeoTIFFImage {
|
|
59
6
|
/**
|
|
60
7
|
* @constructor
|
|
61
|
-
* @param {import("./imagefiledirectory
|
|
62
|
-
* @param {DataView} dataView The DataView for the underlying file.
|
|
8
|
+
* @param {import("./imagefiledirectory").ImageFileDirectory} fileDirectory The parsed file directory
|
|
63
9
|
* @param {Boolean} littleEndian Whether the file is encoded in little or big endian
|
|
64
10
|
* @param {Boolean} cache Whether or not decoded tiles shall be cached
|
|
65
|
-
* @param {import('./source/basesource').BaseSource} source The datasource to read from
|
|
11
|
+
* @param {import('./source/basesource.js').BaseSource} source The datasource to read from
|
|
66
12
|
*/
|
|
67
|
-
constructor(fileDirectory: import("./imagefiledirectory
|
|
68
|
-
fileDirectory: import("./imagefiledirectory
|
|
69
|
-
dataView: DataView<ArrayBufferLike>;
|
|
13
|
+
constructor(fileDirectory: import("./imagefiledirectory").ImageFileDirectory, littleEndian: boolean, cache: boolean, source: import("./source/basesource.js").BaseSource);
|
|
14
|
+
fileDirectory: import("./imagefiledirectory").ImageFileDirectory;
|
|
70
15
|
littleEndian: boolean;
|
|
71
16
|
tiles: {} | null;
|
|
72
17
|
isTiled: boolean;
|
|
73
|
-
|
|
74
|
-
|
|
18
|
+
/** @type {1 | 2} */
|
|
19
|
+
planarConfiguration: 1 | 2;
|
|
20
|
+
source: import("./source/basesource.js").BaseSource;
|
|
75
21
|
/**
|
|
76
22
|
* Returns the associated parsed file directory.
|
|
77
|
-
* @returns {import("./imagefiledirectory
|
|
23
|
+
* @returns {import("./imagefiledirectory").ImageFileDirectory} the parsed file directory
|
|
78
24
|
*/
|
|
79
|
-
getFileDirectory(): import("./imagefiledirectory
|
|
25
|
+
getFileDirectory(): import("./imagefiledirectory").ImageFileDirectory;
|
|
80
26
|
/**
|
|
81
27
|
* Returns the associated parsed geo keys.
|
|
82
|
-
* @returns {Record<import('./globals.js').GeoKeyName,
|
|
28
|
+
* @returns {Partial<Record<import('./globals.js').GeoKeyName, *>>|null} the parsed geo keys
|
|
83
29
|
*/
|
|
84
|
-
getGeoKeys(): Record<import("./globals.js").GeoKeyName, any
|
|
30
|
+
getGeoKeys(): Partial<Record<import("./globals.js").GeoKeyName, any>> | null;
|
|
85
31
|
/**
|
|
86
32
|
* Returns the width of the image.
|
|
87
33
|
* @returns {Number} the width of the image
|
|
@@ -125,12 +71,12 @@ declare class GeoTIFFImage {
|
|
|
125
71
|
* @param {Number} x the strip or tile x-offset
|
|
126
72
|
* @param {Number} y the tile y-offset (0 for stripped images)
|
|
127
73
|
* @param {Number} sample the sample to get for separated samples
|
|
128
|
-
* @param {
|
|
74
|
+
* @param {DecoderWorker|import("./geotiff").BaseDecoder} poolOrDecoder the decoder or decoder pool
|
|
129
75
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
130
76
|
* to be aborted
|
|
131
77
|
* @returns {Promise.<{x: number, y: number, sample: number, data: ArrayBuffer}>} the decoded strip or tile
|
|
132
78
|
*/
|
|
133
|
-
getTileOrStrip(x: number, y: number, sample: number, poolOrDecoder:
|
|
79
|
+
getTileOrStrip(x: number, y: number, sample: number, poolOrDecoder: DecoderWorker | import("./geotiff").BaseDecoder, signal?: AbortSignal): Promise<{
|
|
134
80
|
x: number;
|
|
135
81
|
y: number;
|
|
136
82
|
sample: number;
|
|
@@ -142,59 +88,76 @@ declare class GeoTIFFImage {
|
|
|
142
88
|
* @param {Array} imageWindow The image window in pixel coordinates
|
|
143
89
|
* @param {Array} samples The selected samples (0-based indices)
|
|
144
90
|
* @param {TypedArray|TypedArray[]} valueArrays The array(s) to write into
|
|
145
|
-
* @param {
|
|
146
|
-
* @param {import("./geotiff").
|
|
147
|
-
* @param {number} width the width of window to be read into
|
|
148
|
-
* @param {number} height the height of window to be read into
|
|
149
|
-
* @param {
|
|
91
|
+
* @param {boolean|undefined} interleave Whether or not to write in an interleaved manner
|
|
92
|
+
* @param {DecoderWorker|import("./geotiff").BaseDecoder} poolOrDecoder the decoder or decoder pool
|
|
93
|
+
* @param {number} [width] the width of window to be read into
|
|
94
|
+
* @param {number} [height] the height of window to be read into
|
|
95
|
+
* @param {string} [resampleMethod] the resampling method to be used when interpolating
|
|
150
96
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
151
97
|
* to be aborted
|
|
152
98
|
* @returns {Promise<ReadRasterResult>}
|
|
153
99
|
*/
|
|
154
100
|
private _readRaster;
|
|
155
101
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
102
|
+
* @overload
|
|
103
|
+
* @param {ReadRastersOptions & {interleave: true}} options optional parameters
|
|
104
|
+
* @returns {Promise<import("./geotiff").TypedArrayWithDimensions>} the decoded arrays as a promise
|
|
105
|
+
*/
|
|
106
|
+
readRasters(options: ReadRastersOptions & {
|
|
107
|
+
interleave: true;
|
|
108
|
+
}): Promise<import("./geotiff").TypedArrayWithDimensions>;
|
|
109
|
+
/**
|
|
110
|
+
* @overload
|
|
111
|
+
* @param {ReadRastersOptions & {interleave: false}} options optional parameters
|
|
112
|
+
* @returns {Promise<import("./geotiff").TypedArrayArrayWithDimensions>} the decoded arrays as a promise
|
|
113
|
+
*/
|
|
114
|
+
readRasters(options: ReadRastersOptions & {
|
|
115
|
+
interleave: false;
|
|
116
|
+
}): Promise<import("./geotiff").TypedArrayArrayWithDimensions>;
|
|
117
|
+
/**
|
|
118
|
+
* @overload
|
|
119
|
+
* @param {ReadRastersOptions & {interleave: boolean}} options optional parameters
|
|
162
120
|
* @returns {Promise<ReadRasterResult>} the decoded arrays as a promise
|
|
163
121
|
*/
|
|
164
|
-
readRasters(
|
|
122
|
+
readRasters(options: ReadRastersOptions & {
|
|
123
|
+
interleave: boolean;
|
|
124
|
+
}): Promise<ReadRasterResult>;
|
|
165
125
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
* @
|
|
173
|
-
* @param {
|
|
174
|
-
* @
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
* @
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
126
|
+
* @overload
|
|
127
|
+
* @param {ReadRastersOptions} [options={}] optional parameters
|
|
128
|
+
* @returns {Promise<import("./geotiff").TypedArrayArrayWithDimensions>} the decoded arrays as a promise
|
|
129
|
+
*/
|
|
130
|
+
readRasters(options?: ReadRastersOptions | undefined): Promise<import("./geotiff").TypedArrayArrayWithDimensions>;
|
|
131
|
+
/**
|
|
132
|
+
* @overload
|
|
133
|
+
* @param {ReadRGBOptions & {interleave: true}} options optional parameters
|
|
134
|
+
* @returns {Promise<import("./geotiff").TypedArrayWithDimensions>} the RGB array as a Promise
|
|
135
|
+
*/
|
|
136
|
+
readRGB(options: ReadRGBOptions & {
|
|
137
|
+
interleave: true;
|
|
138
|
+
}): Promise<import("./geotiff").TypedArrayWithDimensions>;
|
|
139
|
+
/**
|
|
140
|
+
* @overload
|
|
141
|
+
* @param {ReadRGBOptions & {interleave: false}} options optional parameters
|
|
142
|
+
* @returns {Promise<import("./geotiff").TypedArrayArrayWithDimensions>} the RGB array as a Promise
|
|
143
|
+
*/
|
|
144
|
+
readRGB(options: ReadRGBOptions & {
|
|
145
|
+
interleave: false;
|
|
146
|
+
}): Promise<import("./geotiff").TypedArrayArrayWithDimensions>;
|
|
147
|
+
/**
|
|
148
|
+
* @overload
|
|
149
|
+
* @param {ReadRGBOptions & {interleave: boolean}} options optional parameters
|
|
186
150
|
* @returns {Promise<ReadRasterResult>} the RGB array as a Promise
|
|
187
151
|
*/
|
|
188
|
-
readRGB(
|
|
189
|
-
|
|
190
|
-
interleave?: boolean | undefined;
|
|
191
|
-
pool?: import("./pool.js").default | undefined;
|
|
192
|
-
width?: number | undefined;
|
|
193
|
-
height?: number | undefined;
|
|
194
|
-
resampleMethod?: string | undefined;
|
|
195
|
-
enableAlpha?: boolean | undefined;
|
|
196
|
-
signal?: AbortSignal | undefined;
|
|
152
|
+
readRGB(options: ReadRGBOptions & {
|
|
153
|
+
interleave: boolean;
|
|
197
154
|
}): Promise<ReadRasterResult>;
|
|
155
|
+
/**
|
|
156
|
+
* @overload
|
|
157
|
+
* @param {ReadRGBOptions} [options={}] optional parameters
|
|
158
|
+
* @returns {Promise<import("./geotiff").TypedArrayArrayWithDimensions>} the RGB array as a Promise
|
|
159
|
+
*/
|
|
160
|
+
readRGB(options?: ReadRGBOptions | undefined): Promise<import("./geotiff").TypedArrayArrayWithDimensions>;
|
|
198
161
|
/**
|
|
199
162
|
* Returns an array of tiepoints.
|
|
200
163
|
* @returns {Promise<Object[]>}
|
|
@@ -206,10 +169,10 @@ declare class GeoTIFFImage {
|
|
|
206
169
|
* If sample is passed to null, dataset-level metadata will be returned.
|
|
207
170
|
* Otherwise only metadata specific to the provided sample will be returned.
|
|
208
171
|
*
|
|
209
|
-
* @param {number} [sample=null] The sample index.
|
|
172
|
+
* @param {number|null} [sample=null] The sample index.
|
|
210
173
|
* @returns {Promise<Object>}
|
|
211
174
|
*/
|
|
212
|
-
getGDALMetadata(sample?: number): Promise<Object>;
|
|
175
|
+
getGDALMetadata(sample?: number | null): Promise<Object>;
|
|
213
176
|
/**
|
|
214
177
|
* Returns the GDAL nodata value
|
|
215
178
|
* @returns {number|null}
|
|
@@ -224,12 +187,12 @@ declare class GeoTIFFImage {
|
|
|
224
187
|
/**
|
|
225
188
|
* Returns the image resolution as a XYZ-vector. When the image has no affine
|
|
226
189
|
* transformation, then an exception is thrown.
|
|
227
|
-
* @param {GeoTIFFImage} [referenceImage=null] A reference image to calculate the resolution from
|
|
190
|
+
* @param {GeoTIFFImage|null} [referenceImage=null] A reference image to calculate the resolution from
|
|
228
191
|
* in cases when the current image does not have the
|
|
229
192
|
* required tags on its own.
|
|
230
193
|
* @returns {Array<number>} The resolution as a vector
|
|
231
194
|
*/
|
|
232
|
-
getResolution(referenceImage?: GeoTIFFImage): Array<number>;
|
|
195
|
+
getResolution(referenceImage?: GeoTIFFImage | null): Array<number>;
|
|
233
196
|
/**
|
|
234
197
|
* Returns whether or not the pixels of the image depict an area (or point).
|
|
235
198
|
* @returns {Boolean} Whether the pixels are a point
|
|
@@ -245,4 +208,8 @@ declare class GeoTIFFImage {
|
|
|
245
208
|
*/
|
|
246
209
|
getBoundingBox(tilegrid?: boolean): Array<number>;
|
|
247
210
|
}
|
|
211
|
+
import type { DecoderWorker } from "./geotiff";
|
|
212
|
+
import type { ReadRastersOptions } from "./geotiff";
|
|
213
|
+
import type { ReadRasterResult } from "./geotiff";
|
|
214
|
+
import type { ReadRGBOptions } from "./geotiff";
|
|
248
215
|
//# sourceMappingURL=geotiffimage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geotiffimage.d.ts","sourceRoot":"","sources":["../src/geotiffimage.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geotiffimage.d.ts","sourceRoot":"","sources":["../src/geotiffimage.js"],"names":[],"mappings":";AAuJA;;GAEG;AACH;IACE;;;;;;OAMG;IACH,2BALW,OAAO,sBAAsB,EAAE,kBAAkB,iDAGjD,OAAO,wBAAwB,EAAE,UAAU,EAerD;IAZC,iEAAkC;IAClC,sBAAgC;IAChC,iBAA8B;IAC9B,iBAAoD;IAKpD,oBAAoB;IACpB,qBADW,CAAC,GAAG,CAAC,CAC8B;IAE9C,oDAAoB;IAGtB;;;OAGG;IACH,oBAFa,OAAO,sBAAsB,EAAE,kBAAkB,CAI7D;IAED;;;OAGG;IACH,cAFa,OAAO,CAAC,MAAM,CAAC,OAAO,cAAc,EAAE,UAAU,EAAE,GAAC,CAAC,CAAC,GAAC,IAAI,CAItE;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,6BAGC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,wBAQC;IAED,wBAEC;IAED,+BAMC;IAED;;;;OAIG;IACH,2BAQC;IAED,kCAMC;IAED,6FAyCC;IAED,2CAGC;IAED,4CAEC;IAED,mMAIC;IAED;;;;;;;;;OASG;IACH,oEALW,aAAa,GAAC,OAAO,WAAW,EAAE,WAAW,WAC7C,WAAW,GAET,OAAO,CAAE;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAC,CAAC,CAqE/E;IAED;;;;;;;;;;;;;;OAcG;IACH,oBA6HC;;;;;;IAGE,qBACQ,kBAAkB,GAAG;QAAC,UAAU,EAAE,IAAI,CAAA;KAAC,GACrC,OAAO,CAAC,OAAO,WAAW,EAAE,wBAAwB,CAAC,CACjE;;;;;;IAGE,qBACQ,kBAAkB,GAAG;QAAC,UAAU,EAAE,KAAK,CAAA;KAAC,GACtC,OAAO,CAAC,OAAO,WAAW,EAAE,6BAA6B,CAAC,CACtE;;;;;;IAGE,qBACQ,kBAAkB,GAAG;QAAC,UAAU,EAAE,OAAO,CAAA;KAAC,GACxC,OAAO,CAAC,gBAAgB,CAAC,CACrC;;;;;;IAGE,uDAEU,OAAO,CAAC,OAAO,WAAW,EAAE,6BAA6B,CAAC,CACtE;;;;;;IA+EE,iBACQ,cAAc,GAAG;QAAC,UAAU,EAAE,IAAI,CAAA;KAAC,GACjC,OAAO,CAAC,OAAO,WAAW,EAAE,wBAAwB,CAAC,CACjE;;;;;;IAGE,iBACQ,cAAc,GAAG;QAAC,UAAU,EAAE,KAAK,CAAA;KAAC,GAClC,OAAO,CAAC,OAAO,WAAW,EAAE,6BAA6B,CAAC,CACtE;;;;;;IAGE,iBACQ,cAAc,GAAG;QAAC,UAAU,EAAE,OAAO,CAAA;KAAC,GACpC,OAAO,CAAC,gBAAgB,CAAC,CACrC;;;;;;IAGE,+CAEU,OAAO,CAAC,OAAO,WAAW,EAAE,6BAA6B,CAAC,CACtE;IA2HD;;;OAGG;IACH,gBAFa,OAAO,CAAC,MAAM,EAAE,CAAC,CAoB7B;IAED;;;;;;;;OAQG;IACH,yBAHW,MAAM,GAAC,IAAI,GACT,OAAO,CAAC,MAAM,CAAC,CAsB3B;IAED;;;OAGG;IACH,iBAFa,MAAM,GAAC,IAAI,CAQvB;IAED;;;;OAIG;IACH,aAFa,KAAK,CAAC,MAAM,CAAC,CAoBzB;IAED;;;;;;;OAOG;IACH,+BALW,YAAY,GAAC,IAAI,GAGf,KAAK,CAAC,MAAM,CAAC,CAuCzB;IAED;;;OAGG;IACH,uBAEC;IAED;;;;;;;OAOG;IACH,0BAJW,OAAO,GAEL,KAAK,CAAC,MAAM,CAAC,CAgDzB;CACF;mCA/9B4C,WAAW;wCAElB,WAAW;sCADb,WAAW;oCAEb,WAAW"}
|
|
@@ -6,30 +6,10 @@ import { photometricInterpretations, ExtraSamplesValues } from './globals.js';
|
|
|
6
6
|
import { fromWhiteIsZero, fromBlackIsZero, fromPalette, fromCMYK, fromYCbCr, fromCIELab } from './rgb.js';
|
|
7
7
|
import { getDecoder, getDecoderParameters } from './compression/index.js';
|
|
8
8
|
import { resample, resampleInterleaved } from './resample.js';
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* geographical coordinates.
|
|
14
|
-
* @property {Array<number>} [samples=all samples] the selection of samples to read from. Default is all samples.
|
|
15
|
-
* @property {boolean} [interleave=false] whether the data shall be read
|
|
16
|
-
* in one single array or separate
|
|
17
|
-
* arrays.
|
|
18
|
-
* @property {Pool} [pool=null] The optional decoder pool to use.
|
|
19
|
-
* @property {number} [width] The desired width of the output. When the width is not the
|
|
20
|
-
* same as the images, resampling will be performed.
|
|
21
|
-
* @property {number} [height] The desired height of the output. When the width is not the
|
|
22
|
-
* same as the images, resampling will be performed.
|
|
23
|
-
* @property {string} [resampleMethod='nearest'] The desired resampling method.
|
|
24
|
-
* @property {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
25
|
-
* to be aborted
|
|
26
|
-
* @property {number|number[]} [fillValue] The value to use for parts of the image
|
|
27
|
-
* outside of the images extent. When multiple
|
|
28
|
-
* samples are requested, an array of fill values
|
|
29
|
-
* can be passed.
|
|
30
|
-
*/
|
|
31
|
-
/** @typedef {import("./geotiff.js").TypedArray} TypedArray */
|
|
32
|
-
/** @typedef {import("./geotiff.js").ReadRasterResult} ReadRasterResult */
|
|
9
|
+
/** @import {DecoderWorker, TypedArray} from "./geotiff" */
|
|
10
|
+
/** @import {ReadRasterResult} from "./geotiff" */
|
|
11
|
+
/** @import {ReadRastersOptions} from "./geotiff" */
|
|
12
|
+
/** @import {ReadRGBOptions} from "./geotiff" */
|
|
33
13
|
function sum(array, start, end) {
|
|
34
14
|
let s = 0;
|
|
35
15
|
for (let i = start; i < end; ++i) {
|
|
@@ -170,35 +150,34 @@ function normalizeArray(inBuffer, format, planarConfiguration, samplesPerPixel,
|
|
|
170
150
|
class GeoTIFFImage {
|
|
171
151
|
/**
|
|
172
152
|
* @constructor
|
|
173
|
-
* @param {import("./imagefiledirectory
|
|
174
|
-
* @param {DataView} dataView The DataView for the underlying file.
|
|
153
|
+
* @param {import("./imagefiledirectory").ImageFileDirectory} fileDirectory The parsed file directory
|
|
175
154
|
* @param {Boolean} littleEndian Whether the file is encoded in little or big endian
|
|
176
155
|
* @param {Boolean} cache Whether or not decoded tiles shall be cached
|
|
177
|
-
* @param {import('./source/basesource').BaseSource} source The datasource to read from
|
|
156
|
+
* @param {import('./source/basesource.js').BaseSource} source The datasource to read from
|
|
178
157
|
*/
|
|
179
|
-
constructor(fileDirectory,
|
|
158
|
+
constructor(fileDirectory, littleEndian, cache, source) {
|
|
180
159
|
this.fileDirectory = fileDirectory;
|
|
181
|
-
this.dataView = dataView;
|
|
182
160
|
this.littleEndian = littleEndian;
|
|
183
161
|
this.tiles = cache ? {} : null;
|
|
184
162
|
this.isTiled = !fileDirectory.hasTag('StripOffsets');
|
|
185
|
-
const planarConfiguration = fileDirectory.getValue('PlanarConfiguration');
|
|
186
|
-
|
|
187
|
-
if (this.planarConfiguration !== 1 && this.planarConfiguration !== 2) {
|
|
163
|
+
const planarConfiguration = fileDirectory.getValue('PlanarConfiguration') ?? 1;
|
|
164
|
+
if (planarConfiguration !== 1 && planarConfiguration !== 2) {
|
|
188
165
|
throw new Error('Invalid planar configuration.');
|
|
189
166
|
}
|
|
167
|
+
/** @type {1 | 2} */
|
|
168
|
+
this.planarConfiguration = planarConfiguration;
|
|
190
169
|
this.source = source;
|
|
191
170
|
}
|
|
192
171
|
/**
|
|
193
172
|
* Returns the associated parsed file directory.
|
|
194
|
-
* @returns {import("./imagefiledirectory
|
|
173
|
+
* @returns {import("./imagefiledirectory").ImageFileDirectory} the parsed file directory
|
|
195
174
|
*/
|
|
196
175
|
getFileDirectory() {
|
|
197
176
|
return this.fileDirectory;
|
|
198
177
|
}
|
|
199
178
|
/**
|
|
200
179
|
* Returns the associated parsed geo keys.
|
|
201
|
-
* @returns {Record<import('./globals.js').GeoKeyName,
|
|
180
|
+
* @returns {Partial<Record<import('./globals.js').GeoKeyName, *>>|null} the parsed geo keys
|
|
202
181
|
*/
|
|
203
182
|
getGeoKeys() {
|
|
204
183
|
return this.fileDirectory.parseGeoKeyDirectory();
|
|
@@ -339,7 +318,7 @@ class GeoTIFFImage {
|
|
|
339
318
|
* @param {Number} x the strip or tile x-offset
|
|
340
319
|
* @param {Number} y the tile y-offset (0 for stripped images)
|
|
341
320
|
* @param {Number} sample the sample to get for separated samples
|
|
342
|
-
* @param {
|
|
321
|
+
* @param {DecoderWorker|import("./geotiff").BaseDecoder} poolOrDecoder the decoder or decoder pool
|
|
343
322
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
344
323
|
* to be aborted
|
|
345
324
|
* @returns {Promise.<{x: number, y: number, sample: number, data: ArrayBuffer}>} the decoded strip or tile
|
|
@@ -355,6 +334,9 @@ class GeoTIFFImage {
|
|
|
355
334
|
else if (this.planarConfiguration === 2) {
|
|
356
335
|
index = (sample * numTilesPerRow * numTilesPerCol) + (y * numTilesPerRow) + x;
|
|
357
336
|
}
|
|
337
|
+
if (index === undefined) {
|
|
338
|
+
throw new Error('Could not determine tile or strip index.');
|
|
339
|
+
}
|
|
358
340
|
let offset;
|
|
359
341
|
let byteCount;
|
|
360
342
|
if (this.isTiled) {
|
|
@@ -404,11 +386,11 @@ class GeoTIFFImage {
|
|
|
404
386
|
* @param {Array} imageWindow The image window in pixel coordinates
|
|
405
387
|
* @param {Array} samples The selected samples (0-based indices)
|
|
406
388
|
* @param {TypedArray|TypedArray[]} valueArrays The array(s) to write into
|
|
407
|
-
* @param {
|
|
408
|
-
* @param {import("./geotiff").
|
|
409
|
-
* @param {number} width the width of window to be read into
|
|
410
|
-
* @param {number} height the height of window to be read into
|
|
411
|
-
* @param {
|
|
389
|
+
* @param {boolean|undefined} interleave Whether or not to write in an interleaved manner
|
|
390
|
+
* @param {DecoderWorker|import("./geotiff").BaseDecoder} poolOrDecoder the decoder or decoder pool
|
|
391
|
+
* @param {number} [width] the width of window to be read into
|
|
392
|
+
* @param {number} [height] the height of window to be read into
|
|
393
|
+
* @param {string} [resampleMethod] the resampling method to be used when interpolating
|
|
412
394
|
* @param {AbortSignal} [signal] An AbortSignal that may be signalled if the request is
|
|
413
395
|
* to be aborted
|
|
414
396
|
* @returns {Promise<ReadRasterResult>}
|
|
@@ -450,6 +432,9 @@ class GeoTIFFImage {
|
|
|
450
432
|
bytesPerPixel = this.getSampleByteSize(sample);
|
|
451
433
|
getPromise = this.getTileOrStrip(xTile, yTile, sample, poolOrDecoder, signal);
|
|
452
434
|
}
|
|
435
|
+
if (!getPromise) {
|
|
436
|
+
throw new Error('Could not get tile or strip data.');
|
|
437
|
+
}
|
|
453
438
|
const promise = getPromise.then((tile) => {
|
|
454
439
|
const buffer = tile.data;
|
|
455
440
|
const dataView = new DataView(buffer);
|
|
@@ -488,29 +473,57 @@ class GeoTIFFImage {
|
|
|
488
473
|
|| (height && (imageWindow[3] - imageWindow[1]) !== height)) {
|
|
489
474
|
let resampled;
|
|
490
475
|
if (interleave) {
|
|
491
|
-
resampled = resampleInterleaved(
|
|
476
|
+
resampled = resampleInterleaved(
|
|
477
|
+
/** @type {TypedArray} */ (valueArrays), imageWindow[2] - imageWindow[0], imageWindow[3] - imageWindow[1],
|
|
478
|
+
/** @type {number} */ (width), /** @type {number} */ (height), samples.length, resampleMethod);
|
|
492
479
|
}
|
|
493
480
|
else {
|
|
494
|
-
resampled = resample(
|
|
481
|
+
resampled = resample(
|
|
482
|
+
/** @type {TypedArray[]} */ (valueArrays), imageWindow[2] - imageWindow[0], imageWindow[3] - imageWindow[1],
|
|
483
|
+
/** @type {number} */ (width), /** @type {number} */ (height), resampleMethod);
|
|
495
484
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
485
|
+
const resampledWithDimensions = /** @type {ReadRasterResult} */ (resampled);
|
|
486
|
+
resampledWithDimensions.width = width ?? imageWindow[2] - imageWindow[0];
|
|
487
|
+
resampledWithDimensions.height = height ?? imageWindow[3] - imageWindow[1];
|
|
488
|
+
return resampledWithDimensions;
|
|
499
489
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
490
|
+
const valueArraysWithDimensions = /** @type {ReadRasterResult} */ (valueArrays);
|
|
491
|
+
valueArraysWithDimensions.width = width || imageWindow[2] - imageWindow[0];
|
|
492
|
+
valueArraysWithDimensions.height = height || imageWindow[3] - imageWindow[1];
|
|
493
|
+
return valueArraysWithDimensions;
|
|
503
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* @overload
|
|
497
|
+
* @param {ReadRastersOptions & {interleave: true}} options optional parameters
|
|
498
|
+
* @returns {Promise<import("./geotiff").TypedArrayWithDimensions>} the decoded arrays as a promise
|
|
499
|
+
*/
|
|
500
|
+
/**
|
|
501
|
+
* @overload
|
|
502
|
+
* @param {ReadRastersOptions & {interleave: false}} options optional parameters
|
|
503
|
+
* @returns {Promise<import("./geotiff").TypedArrayArrayWithDimensions>} the decoded arrays as a promise
|
|
504
|
+
*/
|
|
505
|
+
/**
|
|
506
|
+
* @overload
|
|
507
|
+
* @param {ReadRastersOptions & {interleave: boolean}} options optional parameters
|
|
508
|
+
* @returns {Promise<ReadRasterResult>} the decoded arrays as a promise
|
|
509
|
+
*/
|
|
510
|
+
/**
|
|
511
|
+
* @overload
|
|
512
|
+
* @param {ReadRastersOptions} [options={}] optional parameters
|
|
513
|
+
* @returns {Promise<import("./geotiff").TypedArrayArrayWithDimensions>} the decoded arrays as a promise
|
|
514
|
+
*/
|
|
504
515
|
/**
|
|
505
516
|
* Reads raster data from the image. This function reads all selected samples
|
|
506
517
|
* into separate arrays of the correct type for that sample or into a single
|
|
507
518
|
* combined array when `interleave` is set. When provided, only a subset
|
|
508
519
|
* of the raster is read for each sample.
|
|
509
520
|
*
|
|
510
|
-
* @param {
|
|
521
|
+
* @param {ReadRastersOptions} [options={}] optional parameters
|
|
511
522
|
* @returns {Promise<ReadRasterResult>} the decoded arrays as a promise
|
|
512
523
|
*/
|
|
513
|
-
async readRasters(
|
|
524
|
+
async readRasters(options = {}) {
|
|
525
|
+
const { window: wnd, samples = [], pool = null, width, height, resampleMethod, fillValue, signal, } = options;
|
|
526
|
+
const interleave = 'interleave' in options && options.interleave;
|
|
514
527
|
const imageWindow = wnd || [0, 0, this.getWidth(), this.getHeight()];
|
|
515
528
|
// check parameters
|
|
516
529
|
if (imageWindow[0] > imageWindow[2] || imageWindow[1] > imageWindow[3]) {
|
|
@@ -532,6 +545,7 @@ class GeoTIFFImage {
|
|
|
532
545
|
}
|
|
533
546
|
}
|
|
534
547
|
}
|
|
548
|
+
/** @type {TypedArray|TypedArray[]} */
|
|
535
549
|
let valueArrays;
|
|
536
550
|
if (interleave) {
|
|
537
551
|
const format = this.fileDirectory.hasTag('SampleFormat')
|
|
@@ -539,6 +553,9 @@ class GeoTIFFImage {
|
|
|
539
553
|
const bitsPerSample = Math.max.apply(null, this.fileDirectory.getValue('BitsPerSample'));
|
|
540
554
|
valueArrays = arrayForType(format, bitsPerSample, numPixels * samples.length);
|
|
541
555
|
if (fillValue) {
|
|
556
|
+
if (Array.isArray(fillValue)) {
|
|
557
|
+
throw new Error('When reading interleaved data, fillValue must be a single number.');
|
|
558
|
+
}
|
|
542
559
|
valueArrays.fill(fillValue);
|
|
543
560
|
}
|
|
544
561
|
}
|
|
@@ -563,6 +580,26 @@ class GeoTIFFImage {
|
|
|
563
580
|
const result = await this._readRaster(imageWindow, samples, valueArrays, interleave, poolOrDecoder, width, height, resampleMethod, signal);
|
|
564
581
|
return result;
|
|
565
582
|
}
|
|
583
|
+
/**
|
|
584
|
+
* @overload
|
|
585
|
+
* @param {ReadRGBOptions & {interleave: true}} options optional parameters
|
|
586
|
+
* @returns {Promise<import("./geotiff").TypedArrayWithDimensions>} the RGB array as a Promise
|
|
587
|
+
*/
|
|
588
|
+
/**
|
|
589
|
+
* @overload
|
|
590
|
+
* @param {ReadRGBOptions & {interleave: false}} options optional parameters
|
|
591
|
+
* @returns {Promise<import("./geotiff").TypedArrayArrayWithDimensions>} the RGB array as a Promise
|
|
592
|
+
*/
|
|
593
|
+
/**
|
|
594
|
+
* @overload
|
|
595
|
+
* @param {ReadRGBOptions & {interleave: boolean}} options optional parameters
|
|
596
|
+
* @returns {Promise<ReadRasterResult>} the RGB array as a Promise
|
|
597
|
+
*/
|
|
598
|
+
/**
|
|
599
|
+
* @overload
|
|
600
|
+
* @param {ReadRGBOptions} [options={}] optional parameters
|
|
601
|
+
* @returns {Promise<import("./geotiff").TypedArrayArrayWithDimensions>} the RGB array as a Promise
|
|
602
|
+
*/
|
|
566
603
|
/**
|
|
567
604
|
* Reads raster data from the image as RGB.
|
|
568
605
|
* Colorspaces other than RGB will be transformed to RGB, color maps expanded.
|
|
@@ -570,23 +607,12 @@ class GeoTIFFImage {
|
|
|
570
607
|
* grayscale image.
|
|
571
608
|
* When provided, only a subset of the raster is read for each sample.
|
|
572
609
|
*
|
|
573
|
-
* @param {
|
|
574
|
-
* @param {Array<number>} [options.window] the subset to read data from in pixels.
|
|
575
|
-
* @param {boolean} [options.interleave=true] whether the data shall be read
|
|
576
|
-
* in one single array or separate
|
|
577
|
-
* arrays.
|
|
578
|
-
* @param {import("./geotiff").Pool} [options.pool=null] The optional decoder pool to use.
|
|
579
|
-
* @param {number} [options.width] The desired width of the output. When the width is no the
|
|
580
|
-
* same as the images, resampling will be performed.
|
|
581
|
-
* @param {number} [options.height] The desired height of the output. When the width is no the
|
|
582
|
-
* same as the images, resampling will be performed.
|
|
583
|
-
* @param {string} [options.resampleMethod='nearest'] The desired resampling method.
|
|
584
|
-
* @param {boolean} [options.enableAlpha=false] Enable reading alpha channel if present.
|
|
585
|
-
* @param {AbortSignal} [options.signal] An AbortSignal that may be signalled if the request is
|
|
586
|
-
* to be aborted
|
|
610
|
+
* @param {ReadRGBOptions} [options] optional parameters
|
|
587
611
|
* @returns {Promise<ReadRasterResult>} the RGB array as a Promise
|
|
588
612
|
*/
|
|
589
|
-
async readRGB(
|
|
613
|
+
async readRGB(options = {}) {
|
|
614
|
+
const { window, pool = null, width, height, resampleMethod, enableAlpha = false, signal } = options;
|
|
615
|
+
const interleave = ('interleave' in options && options.interleave) ?? false;
|
|
590
616
|
const imageWindow = window || [0, 0, this.getWidth(), this.getHeight()];
|
|
591
617
|
// check parameters
|
|
592
618
|
if (imageWindow[0] > imageWindow[2] || imageWindow[1] > imageWindow[3]) {
|
|
@@ -631,6 +657,7 @@ class GeoTIFFImage {
|
|
|
631
657
|
}
|
|
632
658
|
const subOptions = {
|
|
633
659
|
window: imageWindow,
|
|
660
|
+
/** @type {true} */
|
|
634
661
|
interleave: true,
|
|
635
662
|
samples,
|
|
636
663
|
pool,
|
|
@@ -678,9 +705,10 @@ class GeoTIFFImage {
|
|
|
678
705
|
}
|
|
679
706
|
data = [red, green, blue];
|
|
680
707
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
708
|
+
const dataWithDimensions = /** @type {import("./geotiff").ReadRasterResult} */ (data);
|
|
709
|
+
dataWithDimensions.width = raster.width;
|
|
710
|
+
dataWithDimensions.height = raster.height;
|
|
711
|
+
return dataWithDimensions;
|
|
684
712
|
}
|
|
685
713
|
/**
|
|
686
714
|
* Returns an array of tiepoints.
|
|
@@ -710,7 +738,7 @@ class GeoTIFFImage {
|
|
|
710
738
|
* If sample is passed to null, dataset-level metadata will be returned.
|
|
711
739
|
* Otherwise only metadata specific to the provided sample will be returned.
|
|
712
740
|
*
|
|
713
|
-
* @param {number} [sample=null] The sample index.
|
|
741
|
+
* @param {number|null} [sample=null] The sample index.
|
|
714
742
|
* @returns {Promise<Object>}
|
|
715
743
|
*/
|
|
716
744
|
async getGDALMetadata(sample = null) {
|
|
@@ -770,7 +798,7 @@ class GeoTIFFImage {
|
|
|
770
798
|
/**
|
|
771
799
|
* Returns the image resolution as a XYZ-vector. When the image has no affine
|
|
772
800
|
* transformation, then an exception is thrown.
|
|
773
|
-
* @param {GeoTIFFImage} [referenceImage=null] A reference image to calculate the resolution from
|
|
801
|
+
* @param {GeoTIFFImage|null} [referenceImage=null] A reference image to calculate the resolution from
|
|
774
802
|
* in cases when the current image does not have the
|
|
775
803
|
* required tags on its own.
|
|
776
804
|
* @returns {Array<number>} The resolution as a vector
|
|
@@ -816,7 +844,7 @@ class GeoTIFFImage {
|
|
|
816
844
|
* @returns {Boolean} Whether the pixels are a point
|
|
817
845
|
*/
|
|
818
846
|
pixelIsArea() {
|
|
819
|
-
return this.
|
|
847
|
+
return this.getGeoKeys()?.GTRasterTypeGeoKey === 1;
|
|
820
848
|
}
|
|
821
849
|
/**
|
|
822
850
|
* Returns the image bounding box as an array of 4 values: min-x, min-y,
|
|
@@ -315,7 +315,7 @@ export function writeGeotiff(data, metadata) {
|
|
|
315
315
|
if (!metadata.BitsPerSample) {
|
|
316
316
|
let bitsPerSample = 8;
|
|
317
317
|
if (ArrayBuffer.isView(flattenedValues)) {
|
|
318
|
-
bitsPerSample = 8 * flattenedValues.BYTES_PER_ELEMENT;
|
|
318
|
+
bitsPerSample = 8 * Object.getPrototypeOf(flattenedValues).BYTES_PER_ELEMENT;
|
|
319
319
|
}
|
|
320
320
|
metadata.BitsPerSample = times(numBands, () => bitsPerSample);
|
|
321
321
|
}
|
|
@@ -340,7 +340,7 @@ export function writeGeotiff(data, metadata) {
|
|
|
340
340
|
// default for Float64
|
|
341
341
|
let elementSize = 8;
|
|
342
342
|
if (ArrayBuffer.isView(flattenedValues)) {
|
|
343
|
-
elementSize = flattenedValues.BYTES_PER_ELEMENT;
|
|
343
|
+
elementSize = Object.getPrototypeOf(flattenedValues).BYTES_PER_ELEMENT;
|
|
344
344
|
}
|
|
345
345
|
metadata.StripByteCounts = [numBands * elementSize * height * width];
|
|
346
346
|
}
|