maplibre-gl-raster 0.1.0
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/LICENSE +21 -0
- package/README.md +362 -0
- package/dist/LercDecode.es-CZm5toNk.js +442 -0
- package/dist/LercDecode.es-CZm5toNk.js.map +1 -0
- package/dist/RasterControl-B7XdXYSu.js +18838 -0
- package/dist/RasterControl-B7XdXYSu.js.map +1 -0
- package/dist/__vite-browser-external-BgMKmFg9.js +9 -0
- package/dist/__vite-browser-external-BgMKmFg9.js.map +1 -0
- package/dist/assets/LercDecode.es-Bvg6-wb5.js +442 -0
- package/dist/assets/LercDecode.es-Bvg6-wb5.js.map +1 -0
- package/dist/assets/__vite-browser-external-BgMKmFg9.js +9 -0
- package/dist/assets/__vite-browser-external-BgMKmFg9.js.map +1 -0
- package/dist/assets/chunk-FDOR9p9I.js +24 -0
- package/dist/assets/decode-BvR5vy7g.js +940 -0
- package/dist/assets/decode-BvR5vy7g.js.map +1 -0
- package/dist/assets/lerc-By2TvjAX.js +34 -0
- package/dist/assets/lerc-By2TvjAX.js.map +1 -0
- package/dist/assets/lzw-CQJJDca2.js +174 -0
- package/dist/assets/lzw-CQJJDca2.js.map +1 -0
- package/dist/assets/worker-C6cg9T3Y.js +51 -0
- package/dist/assets/worker-C6cg9T3Y.js.map +1 -0
- package/dist/assets/zstd-DBZv9xja.js +569 -0
- package/dist/assets/zstd-DBZv9xja.js.map +1 -0
- package/dist/chunk-FDOR9p9I.js +24 -0
- package/dist/decode-BMFOVF9X.js +1966 -0
- package/dist/decode-BMFOVF9X.js.map +1 -0
- package/dist/index.mjs +223 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lerc-B7WY-v3y.js +34 -0
- package/dist/lerc-B7WY-v3y.js.map +1 -0
- package/dist/lzw-YEsReV21.js +174 -0
- package/dist/lzw-YEsReV21.js.map +1 -0
- package/dist/maplibre-gl-raster.css +670 -0
- package/dist/react.mjs +145 -0
- package/dist/react.mjs.map +1 -0
- package/dist/types/index.d.ts +649 -0
- package/dist/types/react.d.ts +477 -0
- package/dist/zstd-DBZv9xja.js +569 -0
- package/dist/zstd-DBZv9xja.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,1966 @@
|
|
|
1
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.endian.js
|
|
2
|
+
/**
|
|
3
|
+
* Tiff format
|
|
4
|
+
*
|
|
5
|
+
* The header of a Tiff file contains the endianness of the file
|
|
6
|
+
*/
|
|
7
|
+
var TiffEndian;
|
|
8
|
+
(function(TiffEndian) {
|
|
9
|
+
TiffEndian[TiffEndian["Big"] = 19789] = "Big";
|
|
10
|
+
TiffEndian[TiffEndian["Little"] = 18761] = "Little";
|
|
11
|
+
})(TiffEndian || (TiffEndian = {}));
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.tag.id.js
|
|
14
|
+
/** Sub file type for tag 254 {@link TiffTag.SubFileType} */
|
|
15
|
+
var SubFileType;
|
|
16
|
+
(function(SubFileType) {
|
|
17
|
+
/** Reduced resolution version */
|
|
18
|
+
SubFileType[SubFileType["ReducedImage"] = 1] = "ReducedImage";
|
|
19
|
+
/** One page of many */
|
|
20
|
+
SubFileType[SubFileType["Page"] = 2] = "Page";
|
|
21
|
+
/** Transparency mask */
|
|
22
|
+
SubFileType[SubFileType["Mask"] = 4] = "Mask";
|
|
23
|
+
})(SubFileType || (SubFileType = {}));
|
|
24
|
+
var Orientation;
|
|
25
|
+
(function(Orientation) {
|
|
26
|
+
Orientation[Orientation["TopLeft"] = 1] = "TopLeft";
|
|
27
|
+
Orientation[Orientation["TopRight"] = 2] = "TopRight";
|
|
28
|
+
Orientation[Orientation["BottomRight"] = 3] = "BottomRight";
|
|
29
|
+
Orientation[Orientation["BottomLeft"] = 4] = "BottomLeft";
|
|
30
|
+
Orientation[Orientation["LeftTop"] = 5] = "LeftTop";
|
|
31
|
+
Orientation[Orientation["RightTOP"] = 6] = "RightTOP";
|
|
32
|
+
Orientation[Orientation["RightBottom"] = 7] = "RightBottom";
|
|
33
|
+
Orientation[Orientation["LeftBottom"] = 8] = "LeftBottom";
|
|
34
|
+
})(Orientation || (Orientation = {}));
|
|
35
|
+
var RasterTypeKey;
|
|
36
|
+
(function(RasterTypeKey) {
|
|
37
|
+
/**
|
|
38
|
+
* PixelIsArea (default) a pixel is treated as an area,
|
|
39
|
+
* the raster coordinate (0,0) is the top left corner of the top left pixel.
|
|
40
|
+
*/
|
|
41
|
+
RasterTypeKey[RasterTypeKey["PixelIsArea"] = 1] = "PixelIsArea";
|
|
42
|
+
/**
|
|
43
|
+
* PixelIsPoint treats pixels as point samples with empty space between the "pixel" samples.
|
|
44
|
+
* the raster coordinate (0,0) is the location of the top left raster pixel.
|
|
45
|
+
*/
|
|
46
|
+
RasterTypeKey[RasterTypeKey["PixelIsPoint"] = 2] = "PixelIsPoint";
|
|
47
|
+
})(RasterTypeKey || (RasterTypeKey = {}));
|
|
48
|
+
var ModelTypeCode;
|
|
49
|
+
(function(ModelTypeCode) {
|
|
50
|
+
ModelTypeCode[ModelTypeCode["Unknown"] = 0] = "Unknown";
|
|
51
|
+
/** Projection Coordinate System */
|
|
52
|
+
ModelTypeCode[ModelTypeCode["Projected"] = 1] = "Projected";
|
|
53
|
+
/** Geographic latitude-longitude System */
|
|
54
|
+
ModelTypeCode[ModelTypeCode["Geographic"] = 2] = "Geographic";
|
|
55
|
+
/** Geocentric (X,Y,Z) Coordinate System */
|
|
56
|
+
ModelTypeCode[ModelTypeCode["Geocentric"] = 3] = "Geocentric";
|
|
57
|
+
ModelTypeCode[ModelTypeCode["UserDefined"] = 32767] = "UserDefined";
|
|
58
|
+
})(ModelTypeCode || (ModelTypeCode = {}));
|
|
59
|
+
/** Sub file type for tag 255 {@link TiffTag.OldSubFileType} */
|
|
60
|
+
var OldSubFileType;
|
|
61
|
+
(function(OldSubFileType) {
|
|
62
|
+
/** Full resolution image data */
|
|
63
|
+
OldSubFileType[OldSubFileType["Image"] = 1] = "Image";
|
|
64
|
+
/** Reduced resolution version */
|
|
65
|
+
OldSubFileType[OldSubFileType["ReducedImage"] = 2] = "ReducedImage";
|
|
66
|
+
/** One page of many */
|
|
67
|
+
OldSubFileType[OldSubFileType["Page"] = 3] = "Page";
|
|
68
|
+
})(OldSubFileType || (OldSubFileType = {}));
|
|
69
|
+
/** Tiff compression types */
|
|
70
|
+
var Compression;
|
|
71
|
+
(function(Compression) {
|
|
72
|
+
Compression[Compression["None"] = 1] = "None";
|
|
73
|
+
Compression[Compression["Ccittrle"] = 2] = "Ccittrle";
|
|
74
|
+
Compression[Compression["CcittT4"] = 3] = "CcittT4";
|
|
75
|
+
Compression[Compression["CcittT6"] = 4] = "CcittT6";
|
|
76
|
+
Compression[Compression["Lzw"] = 5] = "Lzw";
|
|
77
|
+
Compression[Compression["Jpeg6"] = 6] = "Jpeg6";
|
|
78
|
+
Compression[Compression["Jpeg"] = 7] = "Jpeg";
|
|
79
|
+
Compression[Compression["DeflateOther"] = 8] = "DeflateOther";
|
|
80
|
+
Compression[Compression["T85"] = 9] = "T85";
|
|
81
|
+
Compression[Compression["T43"] = 10] = "T43";
|
|
82
|
+
Compression[Compression["Next"] = 32766] = "Next";
|
|
83
|
+
Compression[Compression["Ccittrlew"] = 32771] = "Ccittrlew";
|
|
84
|
+
Compression[Compression["PackBits"] = 32773] = "PackBits";
|
|
85
|
+
Compression[Compression["ThunderScan"] = 32809] = "ThunderScan";
|
|
86
|
+
Compression[Compression["It8ctpad"] = 32895] = "It8ctpad";
|
|
87
|
+
Compression[Compression["It8lw"] = 32896] = "It8lw";
|
|
88
|
+
Compression[Compression["It8mp"] = 32897] = "It8mp";
|
|
89
|
+
Compression[Compression["It8bl"] = 32898] = "It8bl";
|
|
90
|
+
Compression[Compression["PixarFilm"] = 32908] = "PixarFilm";
|
|
91
|
+
Compression[Compression["PixarLog"] = 32909] = "PixarLog";
|
|
92
|
+
Compression[Compression["Deflate"] = 32946] = "Deflate";
|
|
93
|
+
Compression[Compression["Dcs"] = 32947] = "Dcs";
|
|
94
|
+
Compression[Compression["Jbig"] = 34661] = "Jbig";
|
|
95
|
+
Compression[Compression["SgiLog"] = 34676] = "SgiLog";
|
|
96
|
+
Compression[Compression["SgiLog24"] = 34677] = "SgiLog24";
|
|
97
|
+
Compression[Compression["Jp2000"] = 34712] = "Jp2000";
|
|
98
|
+
Compression[Compression["Lerc"] = 34887] = "Lerc";
|
|
99
|
+
Compression[Compression["Lzma"] = 34925] = "Lzma";
|
|
100
|
+
Compression[Compression["Zstd"] = 5e4] = "Zstd";
|
|
101
|
+
Compression[Compression["Webp"] = 50001] = "Webp";
|
|
102
|
+
Compression[Compression["JpegXl"] = 50002] = "JpegXl";
|
|
103
|
+
Compression[Compression["JpegXlDng17"] = 52546] = "JpegXlDng17";
|
|
104
|
+
})(Compression || (Compression = {}));
|
|
105
|
+
var PlanarConfiguration;
|
|
106
|
+
(function(PlanarConfiguration) {
|
|
107
|
+
/** single image plane */
|
|
108
|
+
PlanarConfiguration[PlanarConfiguration["Contig"] = 1] = "Contig";
|
|
109
|
+
/** separate planes of data */
|
|
110
|
+
PlanarConfiguration[PlanarConfiguration["Separate"] = 2] = "Separate";
|
|
111
|
+
})(PlanarConfiguration || (PlanarConfiguration = {}));
|
|
112
|
+
var Predictor;
|
|
113
|
+
(function(Predictor) {
|
|
114
|
+
Predictor[Predictor["None"] = 1] = "None";
|
|
115
|
+
/** Horizontal differencing */
|
|
116
|
+
Predictor[Predictor["Horizontal"] = 2] = "Horizontal";
|
|
117
|
+
/** Floating point */
|
|
118
|
+
Predictor[Predictor["FloatingPoint"] = 3] = "FloatingPoint";
|
|
119
|
+
})(Predictor || (Predictor = {}));
|
|
120
|
+
var SampleFormat;
|
|
121
|
+
(function(SampleFormat) {
|
|
122
|
+
/** Unsigned integer data */
|
|
123
|
+
SampleFormat[SampleFormat["Uint"] = 1] = "Uint";
|
|
124
|
+
/** Signed integer data */
|
|
125
|
+
SampleFormat[SampleFormat["Int"] = 2] = "Int";
|
|
126
|
+
/** IEEE floating point data */
|
|
127
|
+
SampleFormat[SampleFormat["Float"] = 3] = "Float";
|
|
128
|
+
/** Untyped data */
|
|
129
|
+
SampleFormat[SampleFormat["Void"] = 4] = "Void";
|
|
130
|
+
/** Complex signed int */
|
|
131
|
+
SampleFormat[SampleFormat["ComplexInt"] = 5] = "ComplexInt";
|
|
132
|
+
/** Complex ieee floating */
|
|
133
|
+
SampleFormat[SampleFormat["ComplexFloat"] = 6] = "ComplexFloat";
|
|
134
|
+
})(SampleFormat || (SampleFormat = {}));
|
|
135
|
+
var Photometric;
|
|
136
|
+
(function(Photometric) {
|
|
137
|
+
/** min value is white */
|
|
138
|
+
Photometric[Photometric["MinIsWhite"] = 0] = "MinIsWhite";
|
|
139
|
+
/** min value is black */
|
|
140
|
+
Photometric[Photometric["MinIsBlack"] = 1] = "MinIsBlack";
|
|
141
|
+
/** RGB color model */
|
|
142
|
+
Photometric[Photometric["Rgb"] = 2] = "Rgb";
|
|
143
|
+
/** color map indexed */
|
|
144
|
+
Photometric[Photometric["Palette"] = 3] = "Palette";
|
|
145
|
+
/** $holdout mask */
|
|
146
|
+
Photometric[Photometric["Mask"] = 4] = "Mask";
|
|
147
|
+
/** !color separations */
|
|
148
|
+
Photometric[Photometric["Separated"] = 5] = "Separated";
|
|
149
|
+
/** !CCIR 601 */
|
|
150
|
+
Photometric[Photometric["Ycbcr"] = 6] = "Ycbcr";
|
|
151
|
+
/** !1976 CIE L*a*b* */
|
|
152
|
+
Photometric[Photometric["Cielab"] = 8] = "Cielab";
|
|
153
|
+
/** ICC L*a*b* [Adobe TIFF Technote 4] */
|
|
154
|
+
Photometric[Photometric["Icclab"] = 9] = "Icclab";
|
|
155
|
+
/** ITU L*a*b* */
|
|
156
|
+
Photometric[Photometric["Itulab"] = 10] = "Itulab";
|
|
157
|
+
/** color filter array */
|
|
158
|
+
Photometric[Photometric["Cfa"] = 32803] = "Cfa";
|
|
159
|
+
/** CIE Log2(L) */
|
|
160
|
+
Photometric[Photometric["Logl"] = 32844] = "Logl";
|
|
161
|
+
Photometric[Photometric["Logluv"] = 32845] = "Logluv";
|
|
162
|
+
})(Photometric || (Photometric = {}));
|
|
163
|
+
/**
|
|
164
|
+
* Tiff tags as defined by libtiff and libgeotiff
|
|
165
|
+
*
|
|
166
|
+
* - {@link https://gitlab.com/libtiff/libtiff}
|
|
167
|
+
* - {@link https://github.com/OSGeo/libgeotiff/}
|
|
168
|
+
*/
|
|
169
|
+
var TiffTag;
|
|
170
|
+
(function(TiffTag) {
|
|
171
|
+
/**
|
|
172
|
+
* Type of the sub file
|
|
173
|
+
*
|
|
174
|
+
* @see {@link SubFileType}
|
|
175
|
+
*/
|
|
176
|
+
TiffTag[TiffTag["SubFileType"] = 254] = "SubFileType";
|
|
177
|
+
/**
|
|
178
|
+
* Type of sub file
|
|
179
|
+
*
|
|
180
|
+
* @see {@link OldSubFileType}
|
|
181
|
+
*/
|
|
182
|
+
TiffTag[TiffTag["OldSubFileType"] = 255] = "OldSubFileType";
|
|
183
|
+
/** Width of image in pixels */
|
|
184
|
+
TiffTag[TiffTag["ImageWidth"] = 256] = "ImageWidth";
|
|
185
|
+
/** Height of image in pixels */
|
|
186
|
+
TiffTag[TiffTag["ImageHeight"] = 257] = "ImageHeight";
|
|
187
|
+
/**
|
|
188
|
+
* Number of bits per channel
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* [8,8,8] // 8 bit RGB
|
|
193
|
+
* [16] // 16bit
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
TiffTag[TiffTag["BitsPerSample"] = 258] = "BitsPerSample";
|
|
197
|
+
/**
|
|
198
|
+
*
|
|
199
|
+
* Data type of the image
|
|
200
|
+
*
|
|
201
|
+
* See {@link SampleFormat}
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* [1] // SampleFormat.Uint
|
|
206
|
+
* [1,1,1,1] // 4 band Uint
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
TiffTag[TiffTag["SampleFormat"] = 339] = "SampleFormat";
|
|
210
|
+
/**
|
|
211
|
+
* Compression Type
|
|
212
|
+
*
|
|
213
|
+
* @see {@link Compression}
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* 5 // Compression.Lzw
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
TiffTag[TiffTag["Compression"] = 259] = "Compression";
|
|
221
|
+
/**
|
|
222
|
+
* Photometric interpretation
|
|
223
|
+
*
|
|
224
|
+
* @see {@link Photometric}
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* 2 // Photometric.Rgb
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
TiffTag[TiffTag["Photometric"] = 262] = "Photometric";
|
|
232
|
+
/** Tile width in pixels */
|
|
233
|
+
TiffTag[TiffTag["TileWidth"] = 322] = "TileWidth";
|
|
234
|
+
/** Tile height in pixels */
|
|
235
|
+
TiffTag[TiffTag["TileHeight"] = 323] = "TileHeight";
|
|
236
|
+
/**
|
|
237
|
+
* Offsets to data tiles
|
|
238
|
+
* `0` means the tile has no data (sparse tiff)
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* [0, 3200, 1406] // three tiles, first tile does not exist
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
TiffTag[TiffTag["TileOffsets"] = 324] = "TileOffsets";
|
|
246
|
+
/**
|
|
247
|
+
* Byte counts for tiles
|
|
248
|
+
* `0 means the tile does not exist (sparse tiff)
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* [0, 3200, 1406] // three tiles, first tile does not exist
|
|
253
|
+
* ```
|
|
254
|
+
**/
|
|
255
|
+
TiffTag[TiffTag["TileByteCounts"] = 325] = "TileByteCounts";
|
|
256
|
+
/** JPEG table stream */
|
|
257
|
+
TiffTag[TiffTag["JpegTables"] = 347] = "JpegTables";
|
|
258
|
+
TiffTag[TiffTag["StripOffsets"] = 273] = "StripOffsets";
|
|
259
|
+
TiffTag[TiffTag["StripByteCounts"] = 279] = "StripByteCounts";
|
|
260
|
+
/**
|
|
261
|
+
* GDAL metadata
|
|
262
|
+
* Generally a xml document with lots of information about the tiff and how it was created
|
|
263
|
+
*/
|
|
264
|
+
TiffTag[TiffTag["GdalMetadata"] = 42112] = "GdalMetadata";
|
|
265
|
+
/**
|
|
266
|
+
* No data value encoded as a string
|
|
267
|
+
*
|
|
268
|
+
* @example "-9999"
|
|
269
|
+
*/
|
|
270
|
+
TiffTag[TiffTag["GdalNoData"] = 42113] = "GdalNoData";
|
|
271
|
+
/** GeoTiff Tags */
|
|
272
|
+
/**
|
|
273
|
+
* Pixel scale in meters
|
|
274
|
+
* in the format [scaleX, scaleY, scaleZ]
|
|
275
|
+
*
|
|
276
|
+
* Requires {@link ModelTiePoint} to be set and {@link ModelTransformation} not to be set
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* [100.0, 100.0, 0.0]
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
TiffTag[TiffTag["ModelPixelScale"] = 33550] = "ModelPixelScale";
|
|
284
|
+
/**
|
|
285
|
+
* Position of the tiff
|
|
286
|
+
*
|
|
287
|
+
* contains a list of tie points that contain
|
|
288
|
+
* [x,y,z] of position in the in the tiff, generally [0,0,0]
|
|
289
|
+
* [x,y,z] of the position in the projected
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* Mapping tiff point `[0,0,0]` to projected coordinates `[350807.4, 5316081.3, 0.0]`
|
|
293
|
+
* ```
|
|
294
|
+
* [0, 0, 0, 350807.4, 5316081.3, 0.0]
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
TiffTag[TiffTag["ModelTiePoint"] = 33922] = "ModelTiePoint";
|
|
298
|
+
/**
|
|
299
|
+
* Exact affine transformation between the tiff and the projected location
|
|
300
|
+
*
|
|
301
|
+
* this tag should not be defined when {@link ModelTiePoint} or {@link ModelPixelScale} are used
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
*```typescript
|
|
305
|
+
* [ 0, 100.0, 0, 400000.0,
|
|
306
|
+
* 100.0, 0, 0, 500000.0,
|
|
307
|
+
* 0, 0, 0, 0,
|
|
308
|
+
* 0, 0, 0, 1]
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
TiffTag[TiffTag["ModelTransformation"] = 34264] = "ModelTransformation";
|
|
312
|
+
/**
|
|
313
|
+
* List of GeoTiff tags
|
|
314
|
+
* {@link TiffTagGeo}
|
|
315
|
+
*
|
|
316
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_geokeydirectorytag}
|
|
317
|
+
*/
|
|
318
|
+
TiffTag[TiffTag["GeoKeyDirectory"] = 34735] = "GeoKeyDirectory";
|
|
319
|
+
/**
|
|
320
|
+
* Double Parameters for GeoTiff Tags
|
|
321
|
+
*
|
|
322
|
+
* {@link TiffTagGeo}
|
|
323
|
+
*/
|
|
324
|
+
TiffTag[TiffTag["GeoDoubleParams"] = 34736] = "GeoDoubleParams";
|
|
325
|
+
/**
|
|
326
|
+
* Ascii Parameters for GeoTiff Tags
|
|
327
|
+
*
|
|
328
|
+
* {@link TiffTagGeo}
|
|
329
|
+
*/
|
|
330
|
+
TiffTag[TiffTag["GeoAsciiParams"] = 34737] = "GeoAsciiParams";
|
|
331
|
+
/**
|
|
332
|
+
* Stores the LERC version and additional compression
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```typescript
|
|
336
|
+
* [4, 0] // version 4, no extra compression
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
TiffTag[TiffTag["LercParameters"] = 50674] = "LercParameters";
|
|
340
|
+
TiffTag[TiffTag["PlanarConfiguration"] = 284] = "PlanarConfiguration";
|
|
341
|
+
/** Untyped values */
|
|
342
|
+
TiffTag[TiffTag["CellLength"] = 265] = "CellLength";
|
|
343
|
+
TiffTag[TiffTag["CellWidth"] = 264] = "CellWidth";
|
|
344
|
+
TiffTag[TiffTag["ColorMap"] = 320] = "ColorMap";
|
|
345
|
+
TiffTag[TiffTag["Copyright"] = 33432] = "Copyright";
|
|
346
|
+
TiffTag[TiffTag["DateTime"] = 306] = "DateTime";
|
|
347
|
+
TiffTag[TiffTag["ExtraSamples"] = 338] = "ExtraSamples";
|
|
348
|
+
TiffTag[TiffTag["FillOrder"] = 266] = "FillOrder";
|
|
349
|
+
TiffTag[TiffTag["FreeByteCounts"] = 289] = "FreeByteCounts";
|
|
350
|
+
TiffTag[TiffTag["FreeOffsets"] = 288] = "FreeOffsets";
|
|
351
|
+
TiffTag[TiffTag["GrayResponseCurve"] = 291] = "GrayResponseCurve";
|
|
352
|
+
TiffTag[TiffTag["GrayResponseUnit"] = 290] = "GrayResponseUnit";
|
|
353
|
+
TiffTag[TiffTag["HostComputer"] = 316] = "HostComputer";
|
|
354
|
+
TiffTag[TiffTag["ImageDescription"] = 270] = "ImageDescription";
|
|
355
|
+
TiffTag[TiffTag["Make"] = 271] = "Make";
|
|
356
|
+
TiffTag[TiffTag["MaxSampleValue"] = 281] = "MaxSampleValue";
|
|
357
|
+
TiffTag[TiffTag["MinSampleValue"] = 280] = "MinSampleValue";
|
|
358
|
+
TiffTag[TiffTag["Model"] = 272] = "Model";
|
|
359
|
+
TiffTag[TiffTag["Orientation"] = 274] = "Orientation";
|
|
360
|
+
TiffTag[TiffTag["ResolutionUnit"] = 296] = "ResolutionUnit";
|
|
361
|
+
TiffTag[TiffTag["RowsPerStrip"] = 278] = "RowsPerStrip";
|
|
362
|
+
TiffTag[TiffTag["SamplesPerPixel"] = 277] = "SamplesPerPixel";
|
|
363
|
+
TiffTag[TiffTag["Software"] = 305] = "Software";
|
|
364
|
+
TiffTag[TiffTag["Threshholding"] = 263] = "Threshholding";
|
|
365
|
+
TiffTag[TiffTag["XResolution"] = 282] = "XResolution";
|
|
366
|
+
TiffTag[TiffTag["YResolution"] = 283] = "YResolution";
|
|
367
|
+
TiffTag[TiffTag["BadFaxLines"] = 326] = "BadFaxLines";
|
|
368
|
+
TiffTag[TiffTag["CleanFaxData"] = 327] = "CleanFaxData";
|
|
369
|
+
TiffTag[TiffTag["ClipPath"] = 343] = "ClipPath";
|
|
370
|
+
TiffTag[TiffTag["ConsecutiveBadFaxLines"] = 328] = "ConsecutiveBadFaxLines";
|
|
371
|
+
TiffTag[TiffTag["Decode"] = 433] = "Decode";
|
|
372
|
+
TiffTag[TiffTag["DefaultImageColor"] = 434] = "DefaultImageColor";
|
|
373
|
+
TiffTag[TiffTag["DocumentName"] = 269] = "DocumentName";
|
|
374
|
+
TiffTag[TiffTag["DotRange"] = 336] = "DotRange";
|
|
375
|
+
TiffTag[TiffTag["HalftoneHints"] = 321] = "HalftoneHints";
|
|
376
|
+
TiffTag[TiffTag["Indexed"] = 346] = "Indexed";
|
|
377
|
+
TiffTag[TiffTag["PageName"] = 285] = "PageName";
|
|
378
|
+
TiffTag[TiffTag["PageNumber"] = 297] = "PageNumber";
|
|
379
|
+
TiffTag[TiffTag["Predictor"] = 317] = "Predictor";
|
|
380
|
+
TiffTag[TiffTag["PrimaryChromaticities"] = 319] = "PrimaryChromaticities";
|
|
381
|
+
TiffTag[TiffTag["ReferenceBlackWhite"] = 532] = "ReferenceBlackWhite";
|
|
382
|
+
TiffTag[TiffTag["SMinSampleValue"] = 340] = "SMinSampleValue";
|
|
383
|
+
TiffTag[TiffTag["SMaxSampleValue"] = 341] = "SMaxSampleValue";
|
|
384
|
+
TiffTag[TiffTag["StripRowCounts"] = 559] = "StripRowCounts";
|
|
385
|
+
TiffTag[TiffTag["SubIFDs"] = 330] = "SubIFDs";
|
|
386
|
+
TiffTag[TiffTag["T4Options"] = 292] = "T4Options";
|
|
387
|
+
TiffTag[TiffTag["T6Options"] = 293] = "T6Options";
|
|
388
|
+
TiffTag[TiffTag["TransferFunction"] = 301] = "TransferFunction";
|
|
389
|
+
TiffTag[TiffTag["WhitePoint"] = 318] = "WhitePoint";
|
|
390
|
+
TiffTag[TiffTag["XClipPathUnits"] = 344] = "XClipPathUnits";
|
|
391
|
+
TiffTag[TiffTag["XPosition"] = 286] = "XPosition";
|
|
392
|
+
TiffTag[TiffTag["YCbCrCoefficients"] = 529] = "YCbCrCoefficients";
|
|
393
|
+
TiffTag[TiffTag["YCbCrPositioning"] = 531] = "YCbCrPositioning";
|
|
394
|
+
TiffTag[TiffTag["YCbCrSubSampling"] = 530] = "YCbCrSubSampling";
|
|
395
|
+
TiffTag[TiffTag["YClipPathUnits"] = 345] = "YClipPathUnits";
|
|
396
|
+
TiffTag[TiffTag["YPosition"] = 287] = "YPosition";
|
|
397
|
+
TiffTag[TiffTag["ApertureValue"] = 37378] = "ApertureValue";
|
|
398
|
+
TiffTag[TiffTag["ColorSpace"] = 40961] = "ColorSpace";
|
|
399
|
+
TiffTag[TiffTag["DateTimeDigitized"] = 36868] = "DateTimeDigitized";
|
|
400
|
+
TiffTag[TiffTag["DateTimeOriginal"] = 36867] = "DateTimeOriginal";
|
|
401
|
+
TiffTag[TiffTag["ExifIFD"] = 34665] = "ExifIFD";
|
|
402
|
+
TiffTag[TiffTag["ExifVersion"] = 36864] = "ExifVersion";
|
|
403
|
+
TiffTag[TiffTag["ExposureTime"] = 33434] = "ExposureTime";
|
|
404
|
+
TiffTag[TiffTag["FileSource"] = 41728] = "FileSource";
|
|
405
|
+
TiffTag[TiffTag["Flash"] = 37385] = "Flash";
|
|
406
|
+
TiffTag[TiffTag["FlashpixVersion"] = 40960] = "FlashpixVersion";
|
|
407
|
+
TiffTag[TiffTag["FNumber"] = 33437] = "FNumber";
|
|
408
|
+
TiffTag[TiffTag["ImageUniqueID"] = 42016] = "ImageUniqueID";
|
|
409
|
+
TiffTag[TiffTag["LightSource"] = 37384] = "LightSource";
|
|
410
|
+
TiffTag[TiffTag["MakerNote"] = 37500] = "MakerNote";
|
|
411
|
+
TiffTag[TiffTag["ShutterSpeedValue"] = 37377] = "ShutterSpeedValue";
|
|
412
|
+
TiffTag[TiffTag["UserComment"] = 37510] = "UserComment";
|
|
413
|
+
TiffTag[TiffTag["IPTC"] = 33723] = "IPTC";
|
|
414
|
+
TiffTag[TiffTag["ICCProfile"] = 34675] = "ICCProfile";
|
|
415
|
+
TiffTag[TiffTag["XMP"] = 700] = "XMP";
|
|
416
|
+
})(TiffTag || (TiffTag = {}));
|
|
417
|
+
/**
|
|
418
|
+
* Geotiff tags as defined by OGC GeoTiff 1.1
|
|
419
|
+
*
|
|
420
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_summary_of_geokey_ids_and_names}
|
|
421
|
+
*/
|
|
422
|
+
var TiffTagGeo;
|
|
423
|
+
(function(TiffTagGeo) {
|
|
424
|
+
/**
|
|
425
|
+
* This GeoKey defines the type of Model coordinate reference system used, to which the transformation from the raster space is made:
|
|
426
|
+
*
|
|
427
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_gtmodeltypegeokey}
|
|
428
|
+
*
|
|
429
|
+
* {@link ModelTypeCode}
|
|
430
|
+
*/
|
|
431
|
+
TiffTagGeo[TiffTagGeo["GTModelTypeGeoKey"] = 1024] = "GTModelTypeGeoKey";
|
|
432
|
+
/**
|
|
433
|
+
* There are currently only two options: `RasterPixelIsPoint` and `RasterPixelIsArea`
|
|
434
|
+
*
|
|
435
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_gtrastertypegeokey}
|
|
436
|
+
*
|
|
437
|
+
* {@link RasterTypeKey}
|
|
438
|
+
*/
|
|
439
|
+
TiffTagGeo[TiffTagGeo["GTRasterTypeGeoKey"] = 1025] = "GTRasterTypeGeoKey";
|
|
440
|
+
/**
|
|
441
|
+
* ASCII reference to published documentation on the overall configuration of the GeoTIFF file.
|
|
442
|
+
*
|
|
443
|
+
* @example "NZGD2000 / New Zealand Transverse Mercator 2000"
|
|
444
|
+
*/
|
|
445
|
+
TiffTagGeo[TiffTagGeo["GTCitationGeoKey"] = 1026] = "GTCitationGeoKey";
|
|
446
|
+
/**
|
|
447
|
+
* Renamed from GeographicTypeGeoKey in OGC GeoTiff
|
|
448
|
+
*/
|
|
449
|
+
TiffTagGeo[TiffTagGeo["GeodeticCRSGeoKey"] = 2048] = "GeodeticCRSGeoKey";
|
|
450
|
+
/**
|
|
451
|
+
* Renamed from GeogCitationGeoKey in OGC GeoTiff
|
|
452
|
+
*
|
|
453
|
+
* @example "NZTM"
|
|
454
|
+
*/
|
|
455
|
+
TiffTagGeo[TiffTagGeo["GeodeticCitationGeoKey"] = 2049] = "GeodeticCitationGeoKey";
|
|
456
|
+
/**
|
|
457
|
+
* Renamed from GeogGeodeticDatumGeoKey in OGC GeoTiff
|
|
458
|
+
*/
|
|
459
|
+
TiffTagGeo[TiffTagGeo["GeodeticDatumGeoKey"] = 2050] = "GeodeticDatumGeoKey";
|
|
460
|
+
/**
|
|
461
|
+
* Renamed from "GeogPrimeMeridianGeoKey" in OGC GeoTiff
|
|
462
|
+
*/
|
|
463
|
+
TiffTagGeo[TiffTagGeo["PrimeMeridianGeoKey"] = 2051] = "PrimeMeridianGeoKey";
|
|
464
|
+
/**
|
|
465
|
+
* Linear unit of measure
|
|
466
|
+
* @example 9001 // Metre
|
|
467
|
+
*/
|
|
468
|
+
TiffTagGeo[TiffTagGeo["GeogLinearUnitsGeoKey"] = 2052] = "GeogLinearUnitsGeoKey";
|
|
469
|
+
TiffTagGeo[TiffTagGeo["GeogLinearUnitSizeGeoKey"] = 2053] = "GeogLinearUnitSizeGeoKey";
|
|
470
|
+
/**
|
|
471
|
+
* Angular unit of measure
|
|
472
|
+
*
|
|
473
|
+
* @example 9102 // Degree
|
|
474
|
+
*/
|
|
475
|
+
TiffTagGeo[TiffTagGeo["GeogAngularUnitsGeoKey"] = 2054] = "GeogAngularUnitsGeoKey";
|
|
476
|
+
TiffTagGeo[TiffTagGeo["GeogAngularUnitSizeGeoKey"] = 2055] = "GeogAngularUnitSizeGeoKey";
|
|
477
|
+
/**
|
|
478
|
+
* Renamed from "GeogEllipsoidGeoKey" in OGC GeoTiff
|
|
479
|
+
*/
|
|
480
|
+
TiffTagGeo[TiffTagGeo["EllipsoidGeoKey"] = 2056] = "EllipsoidGeoKey";
|
|
481
|
+
/**
|
|
482
|
+
* Renamed from "GeogSemiMajorAxisGeoKey" in OGC GeoTiff
|
|
483
|
+
*/
|
|
484
|
+
TiffTagGeo[TiffTagGeo["EllipsoidSemiMajorAxisGeoKey"] = 2057] = "EllipsoidSemiMajorAxisGeoKey";
|
|
485
|
+
/**
|
|
486
|
+
* Renamed from "GeogSemiMinorAxisGeoKey" in OGC GeoTiff
|
|
487
|
+
*/
|
|
488
|
+
TiffTagGeo[TiffTagGeo["EllipsoidSemiMinorAxisGeoKey"] = 2058] = "EllipsoidSemiMinorAxisGeoKey";
|
|
489
|
+
/**
|
|
490
|
+
* Renamed from "GeogInvFlatteningGeoKey" in OGC GeoTiff
|
|
491
|
+
*/
|
|
492
|
+
TiffTagGeo[TiffTagGeo["EllipsoidInvFlatteningGeoKey"] = 2059] = "EllipsoidInvFlatteningGeoKey";
|
|
493
|
+
/**
|
|
494
|
+
* Renamed from "GeogPrimeMeridianLongGeoKey" in OGC GeoTiff
|
|
495
|
+
*/
|
|
496
|
+
TiffTagGeo[TiffTagGeo["PrimeMeridianLongitudeGeoKey"] = 2061] = "PrimeMeridianLongitudeGeoKey";
|
|
497
|
+
TiffTagGeo[TiffTagGeo["GeogTOWGS84GeoKey"] = 2062] = "GeogTOWGS84GeoKey";
|
|
498
|
+
TiffTagGeo[TiffTagGeo["GeogAzimuthUnitsGeoKey"] = 2060] = "GeogAzimuthUnitsGeoKey";
|
|
499
|
+
/**
|
|
500
|
+
* EPSG code of the tiff
|
|
501
|
+
*
|
|
502
|
+
* Renamed from "ProjectedCSTypeGeoKey" in OGC GeoTiff
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* 2193 // NZTM
|
|
507
|
+
* 3857 // WebMercatorQuad
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
TiffTagGeo[TiffTagGeo["ProjectedCRSGeoKey"] = 3072] = "ProjectedCRSGeoKey";
|
|
511
|
+
/**
|
|
512
|
+
* ASCII reference to published documentation on the Projected Coordinate System
|
|
513
|
+
*
|
|
514
|
+
* Renamed from "PCSCitationGeoKey" in OGC GeoTiff
|
|
515
|
+
*
|
|
516
|
+
* @example "UTM Zone 60 N with WGS 84"
|
|
517
|
+
*/
|
|
518
|
+
TiffTagGeo[TiffTagGeo["ProjectedCitationGeoKey"] = 3073] = "ProjectedCitationGeoKey";
|
|
519
|
+
/**
|
|
520
|
+
* Specifies a map projection from the GeoTIFF CRS register or to indicate that the map projection is user-defined.
|
|
521
|
+
*
|
|
522
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_map_projection_geokeys}
|
|
523
|
+
*
|
|
524
|
+
* @example 2193
|
|
525
|
+
*/
|
|
526
|
+
TiffTagGeo[TiffTagGeo["ProjectionGeoKey"] = 3074] = "ProjectionGeoKey";
|
|
527
|
+
TiffTagGeo[TiffTagGeo["ProjMethodGeoKey"] = 3075] = "ProjMethodGeoKey";
|
|
528
|
+
TiffTagGeo[TiffTagGeo["ProjLinearUnitsGeoKey"] = 3076] = "ProjLinearUnitsGeoKey";
|
|
529
|
+
TiffTagGeo[TiffTagGeo["ProjLinearUnitSizeGeoKey"] = 3077] = "ProjLinearUnitSizeGeoKey";
|
|
530
|
+
TiffTagGeo[TiffTagGeo["ProjStdParallel1GeoKey"] = 3078] = "ProjStdParallel1GeoKey";
|
|
531
|
+
TiffTagGeo[TiffTagGeo["ProjStdParallel2GeoKey"] = 3079] = "ProjStdParallel2GeoKey";
|
|
532
|
+
TiffTagGeo[TiffTagGeo["ProjNatOriginLongGeoKey"] = 3080] = "ProjNatOriginLongGeoKey";
|
|
533
|
+
TiffTagGeo[TiffTagGeo["ProjNatOriginLatGeoKey"] = 3081] = "ProjNatOriginLatGeoKey";
|
|
534
|
+
TiffTagGeo[TiffTagGeo["ProjFalseEastingGeoKey"] = 3082] = "ProjFalseEastingGeoKey";
|
|
535
|
+
TiffTagGeo[TiffTagGeo["ProjFalseNorthingGeoKey"] = 3083] = "ProjFalseNorthingGeoKey";
|
|
536
|
+
TiffTagGeo[TiffTagGeo["ProjFalseOriginLongGeoKey"] = 3084] = "ProjFalseOriginLongGeoKey";
|
|
537
|
+
TiffTagGeo[TiffTagGeo["ProjFalseOriginLatGeoKey"] = 3085] = "ProjFalseOriginLatGeoKey";
|
|
538
|
+
TiffTagGeo[TiffTagGeo["ProjFalseOriginEastingGeoKey"] = 3086] = "ProjFalseOriginEastingGeoKey";
|
|
539
|
+
TiffTagGeo[TiffTagGeo["ProjFalseOriginNorthingGeoKey"] = 3087] = "ProjFalseOriginNorthingGeoKey";
|
|
540
|
+
TiffTagGeo[TiffTagGeo["ProjCenterLongGeoKey"] = 3088] = "ProjCenterLongGeoKey";
|
|
541
|
+
TiffTagGeo[TiffTagGeo["ProjCenterLatGeoKey"] = 3089] = "ProjCenterLatGeoKey";
|
|
542
|
+
TiffTagGeo[TiffTagGeo["ProjCenterEastingGeoKey"] = 3090] = "ProjCenterEastingGeoKey";
|
|
543
|
+
TiffTagGeo[TiffTagGeo["ProjCenterNorthingGeoKey"] = 3091] = "ProjCenterNorthingGeoKey";
|
|
544
|
+
TiffTagGeo[TiffTagGeo["ProjScaleAtNatOriginGeoKey"] = 3092] = "ProjScaleAtNatOriginGeoKey";
|
|
545
|
+
TiffTagGeo[TiffTagGeo["ProjScaleAtCenterGeoKey"] = 3093] = "ProjScaleAtCenterGeoKey";
|
|
546
|
+
TiffTagGeo[TiffTagGeo["ProjAzimuthAngleGeoKey"] = 3094] = "ProjAzimuthAngleGeoKey";
|
|
547
|
+
TiffTagGeo[TiffTagGeo["ProjStraightVertPoleLongGeoKey"] = 3095] = "ProjStraightVertPoleLongGeoKey";
|
|
548
|
+
TiffTagGeo[TiffTagGeo["ProjRectifiedGridAngleGeoKey"] = 3096] = "ProjRectifiedGridAngleGeoKey";
|
|
549
|
+
/**
|
|
550
|
+
* This key is provided to specify the vertical coordinate reference system from the GeoTIFF CRS register or to indicate that the CRS is a user-defined vertical coordinate reference system. The value for VerticalGeoKey should follow the
|
|
551
|
+
*
|
|
552
|
+
* {@link https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_verticalgeokey}
|
|
553
|
+
*
|
|
554
|
+
* @example 4979
|
|
555
|
+
*/
|
|
556
|
+
TiffTagGeo[TiffTagGeo["VerticalGeoKey"] = 4096] = "VerticalGeoKey";
|
|
557
|
+
/**
|
|
558
|
+
*
|
|
559
|
+
* @example "Geographic 3D WGS 84, Ellipsoidal height"
|
|
560
|
+
*/
|
|
561
|
+
TiffTagGeo[TiffTagGeo["VerticalCitationGeoKey"] = 4097] = "VerticalCitationGeoKey";
|
|
562
|
+
/**
|
|
563
|
+
* vertical datum for a user-defined vertical coordinate reference system.
|
|
564
|
+
*/
|
|
565
|
+
TiffTagGeo[TiffTagGeo["VerticalDatumGeoKey"] = 4098] = "VerticalDatumGeoKey";
|
|
566
|
+
/**
|
|
567
|
+
* Linear Unit for vertical CRS
|
|
568
|
+
*
|
|
569
|
+
* @example 9001
|
|
570
|
+
*/
|
|
571
|
+
TiffTagGeo[TiffTagGeo["VerticalUnitsGeoKey"] = 4099] = "VerticalUnitsGeoKey";
|
|
572
|
+
})(TiffTagGeo || (TiffTagGeo = {}));
|
|
573
|
+
/**
|
|
574
|
+
* EPSG Angular Units. exist between [9100, 9199]
|
|
575
|
+
*
|
|
576
|
+
* Taken from libgeotiff
|
|
577
|
+
*/
|
|
578
|
+
var AngularUnit;
|
|
579
|
+
(function(AngularUnit) {
|
|
580
|
+
AngularUnit[AngularUnit["Radian"] = 9101] = "Radian";
|
|
581
|
+
AngularUnit[AngularUnit["Degree"] = 9102] = "Degree";
|
|
582
|
+
AngularUnit[AngularUnit["ArcMinute"] = 9103] = "ArcMinute";
|
|
583
|
+
AngularUnit[AngularUnit["ArcDegree"] = 9104] = "ArcDegree";
|
|
584
|
+
AngularUnit[AngularUnit["Grad"] = 9105] = "Grad";
|
|
585
|
+
AngularUnit[AngularUnit["Gon"] = 9106] = "Gon";
|
|
586
|
+
AngularUnit[AngularUnit["Dms"] = 9107] = "Dms";
|
|
587
|
+
})(AngularUnit || (AngularUnit = {}));
|
|
588
|
+
/**
|
|
589
|
+
* ESPG Liner units exist between [9000, 9099]
|
|
590
|
+
*
|
|
591
|
+
* Taken from libgeotiff
|
|
592
|
+
*/
|
|
593
|
+
var LinearUnit;
|
|
594
|
+
(function(LinearUnit) {
|
|
595
|
+
LinearUnit[LinearUnit["Metre"] = 9001] = "Metre";
|
|
596
|
+
LinearUnit[LinearUnit["Foot"] = 9002] = "Foot";
|
|
597
|
+
LinearUnit[LinearUnit["FootUsSurvey"] = 9003] = "FootUsSurvey";
|
|
598
|
+
LinearUnit[LinearUnit["FootModifiedAmerican"] = 9004] = "FootModifiedAmerican";
|
|
599
|
+
LinearUnit[LinearUnit["FootClarke"] = 9005] = "FootClarke";
|
|
600
|
+
LinearUnit[LinearUnit["FootIndian"] = 9006] = "FootIndian";
|
|
601
|
+
LinearUnit[LinearUnit["Link"] = 9007] = "Link";
|
|
602
|
+
LinearUnit[LinearUnit["LinkBenoit"] = 9008] = "LinkBenoit";
|
|
603
|
+
LinearUnit[LinearUnit["LinkSears"] = 9009] = "LinkSears";
|
|
604
|
+
LinearUnit[LinearUnit["ChainBenoit"] = 9010] = "ChainBenoit";
|
|
605
|
+
LinearUnit[LinearUnit["ChainSears"] = 9011] = "ChainSears";
|
|
606
|
+
LinearUnit[LinearUnit["YardSears"] = 9012] = "YardSears";
|
|
607
|
+
LinearUnit[LinearUnit["YardIndian"] = 9013] = "YardIndian";
|
|
608
|
+
LinearUnit[LinearUnit["Fathom"] = 9014] = "Fathom";
|
|
609
|
+
LinearUnit[LinearUnit["MileInternationalNautical"] = 9015] = "MileInternationalNautical";
|
|
610
|
+
})(LinearUnit || (LinearUnit = {}));
|
|
611
|
+
/**
|
|
612
|
+
* Convert tiff tag values when being read.
|
|
613
|
+
*/
|
|
614
|
+
var TiffTagConvertArray = {
|
|
615
|
+
[TiffTag.TileByteCounts]: true,
|
|
616
|
+
[TiffTag.TileOffsets]: true,
|
|
617
|
+
[TiffTag.StripOffsets]: true,
|
|
618
|
+
[TiffTag.StripByteCounts]: true,
|
|
619
|
+
[TiffTag.BitsPerSample]: true,
|
|
620
|
+
[TiffTag.SampleFormat]: true,
|
|
621
|
+
[TiffTag.GeoKeyDirectory]: true,
|
|
622
|
+
[TiffTag.GeoDoubleParams]: true
|
|
623
|
+
};
|
|
624
|
+
//#endregion
|
|
625
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.mime.js
|
|
626
|
+
/**
|
|
627
|
+
* MimeType conversion for common tif image compresson types
|
|
628
|
+
*/
|
|
629
|
+
var TiffMimeType;
|
|
630
|
+
(function(TiffMimeType) {
|
|
631
|
+
TiffMimeType["None"] = "application/octet-stream";
|
|
632
|
+
TiffMimeType["Jbig"] = "image/jbig";
|
|
633
|
+
TiffMimeType["Dcs"] = "image/x-kodak-dcs";
|
|
634
|
+
TiffMimeType["PackBits"] = "application/packbits";
|
|
635
|
+
TiffMimeType["Jpeg"] = "image/jpeg";
|
|
636
|
+
TiffMimeType["Jp2000"] = "image/jp2";
|
|
637
|
+
TiffMimeType["JpegXl"] = "image/jpegxl";
|
|
638
|
+
TiffMimeType["Webp"] = "image/webp";
|
|
639
|
+
TiffMimeType["Zstd"] = "application/zstd";
|
|
640
|
+
TiffMimeType["Lzw"] = "application/lzw";
|
|
641
|
+
TiffMimeType["Deflate"] = "application/deflate";
|
|
642
|
+
TiffMimeType["Lerc"] = "application/lerc";
|
|
643
|
+
TiffMimeType["Lzma"] = "application/x-lzma";
|
|
644
|
+
})(TiffMimeType || (TiffMimeType = {}));
|
|
645
|
+
var TiffCompressionMimeType = {
|
|
646
|
+
[Compression.None]: TiffMimeType.None,
|
|
647
|
+
[Compression.Lzw]: TiffMimeType.Lzw,
|
|
648
|
+
[Compression.Jpeg6]: TiffMimeType.Jpeg,
|
|
649
|
+
[Compression.Jpeg]: TiffMimeType.Jpeg,
|
|
650
|
+
[Compression.DeflateOther]: TiffMimeType.Deflate,
|
|
651
|
+
[Compression.Deflate]: TiffMimeType.Deflate,
|
|
652
|
+
[Compression.Lerc]: TiffMimeType.Lerc,
|
|
653
|
+
[Compression.Lzma]: TiffMimeType.Lzma,
|
|
654
|
+
[Compression.Jp2000]: TiffMimeType.Jp2000,
|
|
655
|
+
[Compression.Zstd]: TiffMimeType.Zstd,
|
|
656
|
+
[Compression.Webp]: TiffMimeType.Webp,
|
|
657
|
+
[Compression.JpegXl]: TiffMimeType.JpegXl,
|
|
658
|
+
[Compression.Ccittrle]: TiffMimeType.None,
|
|
659
|
+
[Compression.CcittT4]: TiffMimeType.None,
|
|
660
|
+
[Compression.CcittT6]: TiffMimeType.None,
|
|
661
|
+
[Compression.T85]: TiffMimeType.Jbig,
|
|
662
|
+
[Compression.T43]: TiffMimeType.Jbig,
|
|
663
|
+
[Compression.Next]: TiffMimeType.None,
|
|
664
|
+
[Compression.Ccittrlew]: TiffMimeType.None,
|
|
665
|
+
[Compression.PackBits]: TiffMimeType.PackBits,
|
|
666
|
+
[Compression.ThunderScan]: TiffMimeType.None,
|
|
667
|
+
[Compression.It8ctpad]: TiffMimeType.None,
|
|
668
|
+
[Compression.It8lw]: TiffMimeType.None,
|
|
669
|
+
[Compression.It8mp]: TiffMimeType.None,
|
|
670
|
+
[Compression.It8bl]: TiffMimeType.None,
|
|
671
|
+
[Compression.PixarFilm]: TiffMimeType.None,
|
|
672
|
+
[Compression.PixarLog]: TiffMimeType.None,
|
|
673
|
+
[Compression.Dcs]: TiffMimeType.Dcs,
|
|
674
|
+
[Compression.Jbig]: TiffMimeType.Jbig,
|
|
675
|
+
[Compression.SgiLog]: TiffMimeType.None,
|
|
676
|
+
[Compression.SgiLog24]: TiffMimeType.None,
|
|
677
|
+
[Compression.JpegXlDng17]: TiffMimeType.JpegXl
|
|
678
|
+
};
|
|
679
|
+
/**
|
|
680
|
+
* Lookup the related mimetype for a compression id
|
|
681
|
+
*
|
|
682
|
+
* @param c Compression id
|
|
683
|
+
* @returns mime type for compression
|
|
684
|
+
*/
|
|
685
|
+
function getCompressionMimeType(c) {
|
|
686
|
+
if (c == null) return null;
|
|
687
|
+
return TiffCompressionMimeType[c];
|
|
688
|
+
}
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.tag.value.js
|
|
691
|
+
var TiffTagValueType;
|
|
692
|
+
(function(TiffTagValueType) {
|
|
693
|
+
TiffTagValueType[TiffTagValueType["Uint8"] = 1] = "Uint8";
|
|
694
|
+
TiffTagValueType[TiffTagValueType["Ascii"] = 2] = "Ascii";
|
|
695
|
+
TiffTagValueType[TiffTagValueType["Uint16"] = 3] = "Uint16";
|
|
696
|
+
TiffTagValueType[TiffTagValueType["Uint32"] = 4] = "Uint32";
|
|
697
|
+
TiffTagValueType[TiffTagValueType["Rational"] = 5] = "Rational";
|
|
698
|
+
TiffTagValueType[TiffTagValueType["Int8"] = 6] = "Int8";
|
|
699
|
+
TiffTagValueType[TiffTagValueType["Undefined"] = 7] = "Undefined";
|
|
700
|
+
TiffTagValueType[TiffTagValueType["Int16"] = 8] = "Int16";
|
|
701
|
+
TiffTagValueType[TiffTagValueType["Int32"] = 9] = "Int32";
|
|
702
|
+
TiffTagValueType[TiffTagValueType["SignedRational"] = 10] = "SignedRational";
|
|
703
|
+
TiffTagValueType[TiffTagValueType["Float32"] = 11] = "Float32";
|
|
704
|
+
TiffTagValueType[TiffTagValueType["Float64"] = 12] = "Float64";
|
|
705
|
+
TiffTagValueType[TiffTagValueType["Ifd"] = 13] = "Ifd";
|
|
706
|
+
TiffTagValueType[TiffTagValueType["Uint64"] = 16] = "Uint64";
|
|
707
|
+
TiffTagValueType[TiffTagValueType["Int64"] = 17] = "Int64";
|
|
708
|
+
TiffTagValueType[TiffTagValueType["Ifd8"] = 18] = "Ifd8";
|
|
709
|
+
})(TiffTagValueType || (TiffTagValueType = {}));
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region node_modules/@cogeotiff/core/build/const/tiff.version.js
|
|
712
|
+
/**
|
|
713
|
+
* Tif version number that is stored at the start of a tif file
|
|
714
|
+
*/
|
|
715
|
+
var TiffVersion;
|
|
716
|
+
(function(TiffVersion) {
|
|
717
|
+
/**
|
|
718
|
+
* Big tif's,
|
|
719
|
+
* generally uses 64bit numbers for offsets
|
|
720
|
+
* @see http://bigtiff.org/
|
|
721
|
+
**/
|
|
722
|
+
TiffVersion[TiffVersion["BigTiff"] = 43] = "BigTiff";
|
|
723
|
+
/**
|
|
724
|
+
* Original tif
|
|
725
|
+
* Uses 32 bit or smaller numbers for offsets and counters
|
|
726
|
+
*/
|
|
727
|
+
TiffVersion[TiffVersion["Tiff"] = 42] = "Tiff";
|
|
728
|
+
})(TiffVersion || (TiffVersion = {}));
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region node_modules/@cogeotiff/core/build/read/tiff.value.reader.js
|
|
731
|
+
function getTiffTagSize(fieldType) {
|
|
732
|
+
switch (fieldType) {
|
|
733
|
+
case TiffTagValueType.Uint8:
|
|
734
|
+
case TiffTagValueType.Ascii:
|
|
735
|
+
case TiffTagValueType.Int8:
|
|
736
|
+
case TiffTagValueType.Undefined: return 1;
|
|
737
|
+
case TiffTagValueType.Uint16:
|
|
738
|
+
case TiffTagValueType.Int16: return 2;
|
|
739
|
+
case TiffTagValueType.Uint32:
|
|
740
|
+
case TiffTagValueType.Int32:
|
|
741
|
+
case TiffTagValueType.Float32:
|
|
742
|
+
case TiffTagValueType.Ifd: return 4;
|
|
743
|
+
case TiffTagValueType.Rational:
|
|
744
|
+
case TiffTagValueType.SignedRational:
|
|
745
|
+
case TiffTagValueType.Float64:
|
|
746
|
+
case TiffTagValueType.Uint64:
|
|
747
|
+
case TiffTagValueType.Int64:
|
|
748
|
+
case TiffTagValueType.Ifd8: return 8;
|
|
749
|
+
default: throw new Error(`Invalid fieldType ${String(fieldType)}`);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region node_modules/@cogeotiff/core/build/util/bytes.js
|
|
754
|
+
var ByteSizeFloat;
|
|
755
|
+
(function(ByteSizeFloat) {
|
|
756
|
+
ByteSizeFloat[ByteSizeFloat["Double"] = 8] = "Double";
|
|
757
|
+
ByteSizeFloat[ByteSizeFloat["Float32"] = 4] = "Float32";
|
|
758
|
+
})(ByteSizeFloat || (ByteSizeFloat = {}));
|
|
759
|
+
var ByteSize;
|
|
760
|
+
(function(ByteSize) {
|
|
761
|
+
ByteSize[ByteSize["UInt64"] = 8] = "UInt64";
|
|
762
|
+
ByteSize[ByteSize["UInt32"] = 4] = "UInt32";
|
|
763
|
+
ByteSize[ByteSize["UInt16"] = 2] = "UInt16";
|
|
764
|
+
ByteSize[ByteSize["UInt8"] = 1] = "UInt8";
|
|
765
|
+
})(ByteSize || (ByteSize = {}));
|
|
766
|
+
/** Shifting `<< 32` does not work in javascript */
|
|
767
|
+
var POW_32 = 2 ** 32;
|
|
768
|
+
/**
|
|
769
|
+
* Read a uint64 at the offset
|
|
770
|
+
*
|
|
771
|
+
* This is not precise for large numbers
|
|
772
|
+
* @see {DataView.getBigUint64}
|
|
773
|
+
* @param offset offset to read
|
|
774
|
+
*/
|
|
775
|
+
function getUint64(view, offset, isLittleEndian) {
|
|
776
|
+
const left = view.getUint32(offset, isLittleEndian);
|
|
777
|
+
const right = view.getUint32(offset + 4, isLittleEndian);
|
|
778
|
+
const combined = isLittleEndian ? left + POW_32 * right : POW_32 * left + right;
|
|
779
|
+
if (!Number.isSafeInteger(combined)) throw new Error(combined + " exceeds MAX_SAFE_INTEGER. Precision may is lost");
|
|
780
|
+
return combined;
|
|
781
|
+
}
|
|
782
|
+
function getUint(view, offset, bs, isLittleEndian) {
|
|
783
|
+
switch (bs) {
|
|
784
|
+
case ByteSize.UInt8: return view.getUint8(offset);
|
|
785
|
+
case ByteSize.UInt16: return view.getUint16(offset, isLittleEndian);
|
|
786
|
+
case ByteSize.UInt32: return view.getUint32(offset, isLittleEndian);
|
|
787
|
+
case ByteSize.UInt64: return getUint64(view, offset, isLittleEndian);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region node_modules/@cogeotiff/core/build/read/data.view.offset.js
|
|
792
|
+
/**
|
|
793
|
+
* Does a DataviewOffset include the absolute bytes of the source file
|
|
794
|
+
*
|
|
795
|
+
* @param view DataViewOffset to check
|
|
796
|
+
* @param targetOffset the absolute offset in the file
|
|
797
|
+
* @param count number of bytes to include
|
|
798
|
+
*/
|
|
799
|
+
function hasBytes(view, targetOffset, count) {
|
|
800
|
+
if (targetOffset < view.sourceOffset) return false;
|
|
801
|
+
if (view.sourceOffset + view.byteLength < targetOffset + count) return false;
|
|
802
|
+
return true;
|
|
803
|
+
}
|
|
804
|
+
//#endregion
|
|
805
|
+
//#region node_modules/@cogeotiff/core/build/read/endian.js
|
|
806
|
+
var buffer = /* @__PURE__ */ new ArrayBuffer(4);
|
|
807
|
+
var uint32 = new Uint32Array(buffer);
|
|
808
|
+
var uint8 = new Uint8Array(buffer);
|
|
809
|
+
uint32[0] = 1;
|
|
810
|
+
var isLittleEndian = uint8[0] === 1;
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region node_modules/@cogeotiff/core/build/read/tiff.tag.factory.js
|
|
813
|
+
function readTagValue(fieldType, bytes, offset, isLittleEndian) {
|
|
814
|
+
switch (fieldType) {
|
|
815
|
+
case TiffTagValueType.Ascii: return String.fromCharCode(bytes.getUint8(offset));
|
|
816
|
+
case TiffTagValueType.Undefined:
|
|
817
|
+
case TiffTagValueType.Uint8: return bytes.getUint8(offset);
|
|
818
|
+
case TiffTagValueType.Int8: return bytes.getInt8(offset);
|
|
819
|
+
case TiffTagValueType.Uint16: return bytes.getUint16(offset, isLittleEndian);
|
|
820
|
+
case TiffTagValueType.Int16: return bytes.getInt16(offset, isLittleEndian);
|
|
821
|
+
case TiffTagValueType.Uint32:
|
|
822
|
+
case TiffTagValueType.Ifd: return bytes.getUint32(offset, isLittleEndian);
|
|
823
|
+
case TiffTagValueType.Int32: return bytes.getInt32(offset, isLittleEndian);
|
|
824
|
+
case TiffTagValueType.Rational: return [bytes.getUint32(offset, isLittleEndian), bytes.getUint32(offset + 4, isLittleEndian)];
|
|
825
|
+
case TiffTagValueType.SignedRational: return [bytes.getInt32(offset, isLittleEndian), bytes.getInt32(offset + 4, isLittleEndian)];
|
|
826
|
+
case TiffTagValueType.Float64: return bytes.getFloat64(offset, isLittleEndian);
|
|
827
|
+
case TiffTagValueType.Float32: return bytes.getFloat32(offset, isLittleEndian);
|
|
828
|
+
case TiffTagValueType.Uint64: return getUint64(bytes, offset, isLittleEndian);
|
|
829
|
+
default: throw new Error(`Unknown read type "${fieldType}" "${TiffTagValueType[fieldType]}"`);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Convert a tiff tag value to a typed array if the local endian matches the tiff endian
|
|
834
|
+
*
|
|
835
|
+
* @param tiff
|
|
836
|
+
* @param bytes
|
|
837
|
+
* @param offset Offset in the data view to read from
|
|
838
|
+
* @param length Number of bytes to read
|
|
839
|
+
* @param type type of tiff tag
|
|
840
|
+
* @returns the value if the type is a typed array and the endianness matches otherwise null
|
|
841
|
+
*/
|
|
842
|
+
function readTypedValue(tiff, bytes, offset, length, type) {
|
|
843
|
+
switch (type) {
|
|
844
|
+
case TiffTagValueType.Uint8: return new Uint8Array(bytes.buffer.slice(bytes.byteOffset + offset, bytes.byteOffset + offset + length));
|
|
845
|
+
case TiffTagValueType.Uint16:
|
|
846
|
+
if (tiff.isLittleEndian !== isLittleEndian) return null;
|
|
847
|
+
return new Uint16Array(bytes.buffer.slice(bytes.byteOffset + offset, bytes.byteOffset + offset + length));
|
|
848
|
+
case TiffTagValueType.Uint32:
|
|
849
|
+
if (tiff.isLittleEndian !== isLittleEndian) return null;
|
|
850
|
+
return new Uint32Array(bytes.buffer.slice(bytes.byteOffset + offset, bytes.byteOffset + offset + length));
|
|
851
|
+
}
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
function readValue(tiff, tagId, bytes, offset, type, count) {
|
|
855
|
+
const typeSize = getTiffTagSize(type);
|
|
856
|
+
const dataLength = count * typeSize;
|
|
857
|
+
if (count === 1) {
|
|
858
|
+
const val = readTagValue(type, bytes, offset, tiff.isLittleEndian);
|
|
859
|
+
if (tagId && TiffTagConvertArray[tagId]) return [val];
|
|
860
|
+
return val;
|
|
861
|
+
}
|
|
862
|
+
switch (type) {
|
|
863
|
+
case TiffTagValueType.Ascii: return String.fromCharCode.apply(null, new Uint8Array(bytes.buffer, offset, dataLength - 1));
|
|
864
|
+
}
|
|
865
|
+
if (tagId === TiffTag.TileOffsets || tagId === TiffTag.TileByteCounts || tagId === TiffTag.StripOffsets || tagId === TiffTag.StripByteCounts) {
|
|
866
|
+
const typedOutput = readTypedValue(tiff, bytes, offset, dataLength, type);
|
|
867
|
+
if (typedOutput) return typedOutput;
|
|
868
|
+
}
|
|
869
|
+
const output = [];
|
|
870
|
+
for (let i = 0; i < dataLength; i += typeSize) output.push(readTagValue(type, bytes, offset + i, tiff.isLittleEndian));
|
|
871
|
+
return output;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Determine if all the data for the tiff tag is loaded in and use that to create the specific CogTiffTag
|
|
875
|
+
*
|
|
876
|
+
* @see {@link Tag}
|
|
877
|
+
*
|
|
878
|
+
* @param tiff
|
|
879
|
+
* @param view Bytes to read from
|
|
880
|
+
* @param offset Offset in the dataview to read a tag
|
|
881
|
+
*/
|
|
882
|
+
function createTag(tiff, view, offset) {
|
|
883
|
+
const tagId = view.getUint16(offset + 0, tiff.isLittleEndian);
|
|
884
|
+
const dataType = view.getUint16(offset + 2, tiff.isLittleEndian);
|
|
885
|
+
const dataCount = getUint(view, offset + 4, tiff.ifdConfig.pointer, tiff.isLittleEndian);
|
|
886
|
+
const dataLength = getTiffTagSize(dataType) * dataCount;
|
|
887
|
+
if (dataLength <= tiff.ifdConfig.pointer) {
|
|
888
|
+
const value = readValue(tiff, tagId, view, offset + 4 + tiff.ifdConfig.pointer, dataType, dataCount);
|
|
889
|
+
return {
|
|
890
|
+
type: "inline",
|
|
891
|
+
id: tagId,
|
|
892
|
+
name: TiffTag[tagId],
|
|
893
|
+
count: dataCount,
|
|
894
|
+
value,
|
|
895
|
+
dataType,
|
|
896
|
+
tagOffset: offset
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
const dataOffset = getUint(view, offset + 4 + tiff.ifdConfig.pointer, tiff.ifdConfig.pointer, tiff.isLittleEndian);
|
|
900
|
+
switch (tagId) {
|
|
901
|
+
case TiffTag.TileOffsets:
|
|
902
|
+
case TiffTag.TileByteCounts:
|
|
903
|
+
case TiffTag.StripByteCounts:
|
|
904
|
+
case TiffTag.StripOffsets:
|
|
905
|
+
const tag = {
|
|
906
|
+
type: "offset",
|
|
907
|
+
id: tagId,
|
|
908
|
+
name: TiffTag[tagId],
|
|
909
|
+
count: dataCount,
|
|
910
|
+
dataType,
|
|
911
|
+
dataOffset,
|
|
912
|
+
isLoaded: false,
|
|
913
|
+
value: [],
|
|
914
|
+
tagOffset: offset
|
|
915
|
+
};
|
|
916
|
+
if (hasBytes(view, dataOffset, dataLength)) {
|
|
917
|
+
const val = readTypedValue(tiff, view, dataOffset - view.sourceOffset, dataLength, dataType);
|
|
918
|
+
if (val) {
|
|
919
|
+
tag.value = val;
|
|
920
|
+
tag.isLoaded = true;
|
|
921
|
+
} else setBytes(tag, view);
|
|
922
|
+
}
|
|
923
|
+
return tag;
|
|
924
|
+
}
|
|
925
|
+
if (hasBytes(view, dataOffset, dataLength)) {
|
|
926
|
+
const value = readValue(tiff, tagId, view, dataOffset - view.sourceOffset, dataType, dataCount);
|
|
927
|
+
return {
|
|
928
|
+
type: "inline",
|
|
929
|
+
id: tagId,
|
|
930
|
+
name: TiffTag[tagId],
|
|
931
|
+
count: dataCount,
|
|
932
|
+
value,
|
|
933
|
+
dataType,
|
|
934
|
+
tagOffset: offset
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
return {
|
|
938
|
+
type: "lazy",
|
|
939
|
+
id: tagId,
|
|
940
|
+
name: TiffTag[tagId],
|
|
941
|
+
count: dataCount,
|
|
942
|
+
dataOffset,
|
|
943
|
+
dataType,
|
|
944
|
+
tagOffset: offset
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
/** Fetch the value from a {@link TagLazy} tag */
|
|
948
|
+
async function fetchLazy(tag, tiff, options) {
|
|
949
|
+
if (tag.value != null) return tag.value;
|
|
950
|
+
const dataLength = getTiffTagSize(tag.dataType) * tag.count;
|
|
951
|
+
const bytes = await tiff.source.fetch(tag.dataOffset, dataLength, options);
|
|
952
|
+
const view = new DataView(bytes);
|
|
953
|
+
tag.value = readValue(tiff, tag.id, view, 0, tag.dataType, tag.count);
|
|
954
|
+
return tag.value;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Fetch all the values from a {@link TagOffset}
|
|
958
|
+
*/
|
|
959
|
+
async function fetchAllOffsets(tiff, tag, options) {
|
|
960
|
+
const dataTypeSize = getTiffTagSize(tag.dataType);
|
|
961
|
+
if (tag.view == null) {
|
|
962
|
+
const bytes = await tiff.source.fetch(tag.dataOffset, dataTypeSize * tag.count, options);
|
|
963
|
+
tag.view = new DataView(bytes);
|
|
964
|
+
tag.view.sourceOffset = tag.dataOffset;
|
|
965
|
+
}
|
|
966
|
+
tag.value = readValue(tiff, tag.id, tag.view, 0, tag.dataType, tag.count);
|
|
967
|
+
tag.view = void 0;
|
|
968
|
+
tag.isLoaded = true;
|
|
969
|
+
return tag.value;
|
|
970
|
+
}
|
|
971
|
+
function setBytes(tag, view) {
|
|
972
|
+
const dataTypeSize = getTiffTagSize(tag.dataType);
|
|
973
|
+
const startBytes = view.byteOffset + tag.dataOffset - view.sourceOffset;
|
|
974
|
+
tag.view = new DataView(view.buffer.slice(startBytes, startBytes + dataTypeSize * tag.count));
|
|
975
|
+
tag.view.sourceOffset = tag.dataOffset;
|
|
976
|
+
}
|
|
977
|
+
/** Partially fetch the values of a {@link TagOffset} and return the value for the offset */
|
|
978
|
+
async function getValueAt(tiff, tag, index, options) {
|
|
979
|
+
if (index > tag.count || index < 0) throw new Error("TagOffset: out of bounds :" + index);
|
|
980
|
+
if (tag.value[index] != null) return tag.value[index];
|
|
981
|
+
const dataTypeSize = getTiffTagSize(tag.dataType);
|
|
982
|
+
if (tag.view == null) {
|
|
983
|
+
const bytes = await tiff.source.fetch(tag.dataOffset + index * dataTypeSize, dataTypeSize, options);
|
|
984
|
+
const value = readValue(tiff, void 0, new DataView(bytes), 0, tag.dataType, 1);
|
|
985
|
+
if (typeof value !== "number") throw new Error("Value is not a number");
|
|
986
|
+
tag.value[index] = value;
|
|
987
|
+
return value;
|
|
988
|
+
}
|
|
989
|
+
const value = readValue(tiff, void 0, tag.view, index * dataTypeSize, tag.dataType, 1);
|
|
990
|
+
if (typeof value !== "number") throw new Error("Value is not a number");
|
|
991
|
+
tag.value[index] = value;
|
|
992
|
+
return value;
|
|
993
|
+
}
|
|
994
|
+
function getValueAtSync(tiff, tag, index) {
|
|
995
|
+
if (index > tag.count || index < 0) throw new Error("TagOffset: out of bounds :" + index);
|
|
996
|
+
if (tag.value[index] != null) return tag.value[index];
|
|
997
|
+
if (tag.view == null) return null;
|
|
998
|
+
const dataTypeSize = getTiffTagSize(tag.dataType);
|
|
999
|
+
const value = readValue(tiff, void 0, tag.view, index * dataTypeSize, tag.dataType, 1);
|
|
1000
|
+
if (typeof value !== "number") throw new Error("Value is not a number");
|
|
1001
|
+
tag.value[index] = value;
|
|
1002
|
+
return value;
|
|
1003
|
+
}
|
|
1004
|
+
/** Tags that are commonly accessed for geotiffs */
|
|
1005
|
+
var ImportantTags = new Set([
|
|
1006
|
+
TiffTag.Compression,
|
|
1007
|
+
TiffTag.ImageHeight,
|
|
1008
|
+
TiffTag.ImageWidth,
|
|
1009
|
+
TiffTag.ModelPixelScale,
|
|
1010
|
+
TiffTag.ModelTiePoint,
|
|
1011
|
+
TiffTag.ModelTransformation,
|
|
1012
|
+
TiffTag.TileHeight,
|
|
1013
|
+
TiffTag.TileWidth
|
|
1014
|
+
]);
|
|
1015
|
+
var ImportantGeoTags = new Set([
|
|
1016
|
+
TiffTag.GeoKeyDirectory,
|
|
1017
|
+
TiffTag.GeoAsciiParams,
|
|
1018
|
+
TiffTag.GeoDoubleParams
|
|
1019
|
+
]);
|
|
1020
|
+
var TiffImage = class {
|
|
1021
|
+
/**
|
|
1022
|
+
* Id of the tif image, generally the image index inside the tif
|
|
1023
|
+
* where 0 is the root image, and every sub image is +1
|
|
1024
|
+
*
|
|
1025
|
+
* @example 0, 1, 2
|
|
1026
|
+
*/
|
|
1027
|
+
id;
|
|
1028
|
+
/** Reference to the TIFF that owns this image */
|
|
1029
|
+
tiff;
|
|
1030
|
+
/** Has loadGeoTiffTags been called */
|
|
1031
|
+
isGeoTagsLoaded = false;
|
|
1032
|
+
/** Sub tags stored in TiffTag.GeoKeyDirectory */
|
|
1033
|
+
tagsGeo = /* @__PURE__ */ new Map();
|
|
1034
|
+
/** All IFD tags that have been read for the image */
|
|
1035
|
+
tags;
|
|
1036
|
+
constructor(tiff, id, tags) {
|
|
1037
|
+
this.tiff = tiff;
|
|
1038
|
+
this.id = id;
|
|
1039
|
+
this.tags = tags;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Force loading of important tags if they have not already been loaded
|
|
1043
|
+
*
|
|
1044
|
+
* @param loadGeoTags Whether to load the GeoKeyDirectory and unpack it
|
|
1045
|
+
*/
|
|
1046
|
+
async init(loadGeoTags = true, options) {
|
|
1047
|
+
const requiredTags = [];
|
|
1048
|
+
ImportantTags.forEach((tag) => {
|
|
1049
|
+
requiredTags.push(this.fetch(tag, options));
|
|
1050
|
+
});
|
|
1051
|
+
if (loadGeoTags) ImportantGeoTags.forEach((tag) => {
|
|
1052
|
+
requiredTags.push(this.fetch(tag, options));
|
|
1053
|
+
});
|
|
1054
|
+
await Promise.all(requiredTags);
|
|
1055
|
+
if (loadGeoTags) await this.loadGeoTiffTags();
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Get the value of a TiffTag if it has been loaded, null otherwise.
|
|
1059
|
+
*
|
|
1060
|
+
* If the value is not loaded use {@link TiffImage.fetch} to load the value
|
|
1061
|
+
* Or use {@link TiffImage.has} to check if the tag exists
|
|
1062
|
+
*
|
|
1063
|
+
*
|
|
1064
|
+
* @returns value if loaded, null otherwise
|
|
1065
|
+
*/
|
|
1066
|
+
value(tag) {
|
|
1067
|
+
const sourceTag = this.tags.get(tag);
|
|
1068
|
+
if (sourceTag == null) return null;
|
|
1069
|
+
if (sourceTag.type === "offset" && sourceTag.isLoaded === false) return null;
|
|
1070
|
+
return sourceTag.value;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Does the tag exist
|
|
1074
|
+
*
|
|
1075
|
+
* @example
|
|
1076
|
+
* ```typescript
|
|
1077
|
+
* img.has(TiffTag.ImageWidth) // true
|
|
1078
|
+
* ```
|
|
1079
|
+
*
|
|
1080
|
+
* @param tag Tag to check
|
|
1081
|
+
* @returns true if the tag exists, false otherwise
|
|
1082
|
+
*/
|
|
1083
|
+
has(tag) {
|
|
1084
|
+
return this.tags.has(tag);
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Load a tag.
|
|
1088
|
+
*
|
|
1089
|
+
* If it is not currently loaded, fetch the required data for the tag.
|
|
1090
|
+
*
|
|
1091
|
+
* @example
|
|
1092
|
+
* ```typescript
|
|
1093
|
+
* await img.fetch(TiffTag.ImageWidth) // 512 (px)
|
|
1094
|
+
* ```
|
|
1095
|
+
*
|
|
1096
|
+
* @param tag tag to fetch
|
|
1097
|
+
*/
|
|
1098
|
+
async fetch(tag, options) {
|
|
1099
|
+
const sourceTag = this.tags.get(tag);
|
|
1100
|
+
if (sourceTag == null) return null;
|
|
1101
|
+
if (sourceTag.type === "inline") return sourceTag.value;
|
|
1102
|
+
if (sourceTag.type === "lazy") return fetchLazy(sourceTag, this.tiff, options);
|
|
1103
|
+
if (sourceTag.isLoaded) return sourceTag.value;
|
|
1104
|
+
if (sourceTag.type === "offset") return fetchAllOffsets(this.tiff, sourceTag, options);
|
|
1105
|
+
throw new Error("Cannot fetch:" + tag);
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Get the associated TiffTagGeo
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
* ```typescript
|
|
1112
|
+
* image.valueGeo(TiffTagGeo.GTRasterTypeGeoKey)
|
|
1113
|
+
* ```
|
|
1114
|
+
* @throws if {@link loadGeoTiffTags} has not been called
|
|
1115
|
+
*/
|
|
1116
|
+
valueGeo(tag) {
|
|
1117
|
+
if (this.isGeoTagsLoaded === false) throw new Error("loadGeoTiffTags() has not been called");
|
|
1118
|
+
return this.tagsGeo.get(tag);
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Load and parse the GDAL_NODATA Tifftag
|
|
1122
|
+
*
|
|
1123
|
+
* @throws if the tag is not loaded
|
|
1124
|
+
* @returns null if the tag does not exist
|
|
1125
|
+
*/
|
|
1126
|
+
get noData() {
|
|
1127
|
+
const tag = this.tags.get(TiffTag.GdalNoData);
|
|
1128
|
+
if (tag == null) return null;
|
|
1129
|
+
if (tag.value != null) return Number(tag.value);
|
|
1130
|
+
throw new Error("GdalNoData tag is not loaded");
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Load and unpack the GeoKeyDirectory
|
|
1134
|
+
*
|
|
1135
|
+
* @see {TiffTag.GeoKeyDirectory}
|
|
1136
|
+
*/
|
|
1137
|
+
async loadGeoTiffTags() {
|
|
1138
|
+
if (this.isGeoTagsLoaded) return;
|
|
1139
|
+
const sourceTag = this.tags.get(TiffTag.GeoKeyDirectory);
|
|
1140
|
+
if (sourceTag == null) {
|
|
1141
|
+
this.isGeoTagsLoaded = true;
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
if (sourceTag.type === "lazy" && sourceTag.value == null) await Promise.all([
|
|
1145
|
+
this.fetch(TiffTag.GeoKeyDirectory),
|
|
1146
|
+
this.fetch(TiffTag.GeoAsciiParams),
|
|
1147
|
+
this.fetch(TiffTag.GeoDoubleParams)
|
|
1148
|
+
]);
|
|
1149
|
+
this.isGeoTagsLoaded = true;
|
|
1150
|
+
if (sourceTag.value == null) return;
|
|
1151
|
+
const geoTags = sourceTag.value;
|
|
1152
|
+
if (typeof geoTags === "number") throw new Error("Invalid geo tags found");
|
|
1153
|
+
for (let i = 4; i <= geoTags[3] * 4; i += 4) {
|
|
1154
|
+
const key = geoTags[i];
|
|
1155
|
+
const locationTagId = geoTags[i + 1];
|
|
1156
|
+
const offset = geoTags[i + 3];
|
|
1157
|
+
if (locationTagId === 0) {
|
|
1158
|
+
this.tagsGeo.set(key, offset);
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
const tag = this.tags.get(locationTagId);
|
|
1162
|
+
if (tag == null || tag.value == null) continue;
|
|
1163
|
+
const count = geoTags[i + 2];
|
|
1164
|
+
if (typeof tag.value === "string") this.tagsGeo.set(key, tag.value.slice(offset, offset + count - 1).trim());
|
|
1165
|
+
else if (Array.isArray(tag.value)) if (count === 1) this.tagsGeo.set(key, tag.value[offset]);
|
|
1166
|
+
else this.tagsGeo.set(key, tag.value.slice(offset, offset + count));
|
|
1167
|
+
else throw new Error("Failed to extract GeoTiffTags");
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Get the origin point for the image
|
|
1172
|
+
*
|
|
1173
|
+
* @returns origin point of the image
|
|
1174
|
+
*/
|
|
1175
|
+
get origin() {
|
|
1176
|
+
const tiePoints = this.value(TiffTag.ModelTiePoint);
|
|
1177
|
+
if (tiePoints != null && tiePoints.length === 6) return [
|
|
1178
|
+
tiePoints[3],
|
|
1179
|
+
tiePoints[4],
|
|
1180
|
+
tiePoints[5]
|
|
1181
|
+
];
|
|
1182
|
+
const modelTransformation = this.value(TiffTag.ModelTransformation);
|
|
1183
|
+
if (modelTransformation != null) return [
|
|
1184
|
+
modelTransformation[3],
|
|
1185
|
+
modelTransformation[7],
|
|
1186
|
+
modelTransformation[11]
|
|
1187
|
+
];
|
|
1188
|
+
if (this.value(TiffTag.SubFileType) === SubFileType.ReducedImage && this.id !== 0) return this.tiff.images[0].origin;
|
|
1189
|
+
throw new Error("Image does not have a geo transformation.");
|
|
1190
|
+
}
|
|
1191
|
+
/** Is there enough geo information on this image to figure out where its actually located */
|
|
1192
|
+
get isGeoLocated() {
|
|
1193
|
+
if (this.value(TiffTag.ModelPixelScale) != null || this.value(TiffTag.ModelTransformation) != null) return true;
|
|
1194
|
+
if (this.isSubImage && this.id !== 0) return this.tiff.images[0].isGeoLocated;
|
|
1195
|
+
return false;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Get the resolution of the image
|
|
1199
|
+
*
|
|
1200
|
+
* @returns [x,y,z] pixel scale
|
|
1201
|
+
*/
|
|
1202
|
+
get resolution() {
|
|
1203
|
+
const modelPixelScale = this.value(TiffTag.ModelPixelScale);
|
|
1204
|
+
if (modelPixelScale != null) return [
|
|
1205
|
+
modelPixelScale[0],
|
|
1206
|
+
-modelPixelScale[1],
|
|
1207
|
+
modelPixelScale[2]
|
|
1208
|
+
];
|
|
1209
|
+
const modelTransformation = this.value(TiffTag.ModelTransformation);
|
|
1210
|
+
if (modelTransformation != null) return [
|
|
1211
|
+
modelTransformation[0],
|
|
1212
|
+
modelTransformation[5],
|
|
1213
|
+
modelTransformation[10]
|
|
1214
|
+
];
|
|
1215
|
+
if (this.isSubImage && this.id !== 0) {
|
|
1216
|
+
const firstImg = this.tiff.images[0];
|
|
1217
|
+
const [resX, resY, resZ] = firstImg.resolution;
|
|
1218
|
+
const firstImgSize = firstImg.size;
|
|
1219
|
+
const imgSize = this.size;
|
|
1220
|
+
return [
|
|
1221
|
+
resX * firstImgSize.width / imgSize.width,
|
|
1222
|
+
resY * firstImgSize.height / imgSize.height,
|
|
1223
|
+
resZ
|
|
1224
|
+
];
|
|
1225
|
+
}
|
|
1226
|
+
throw new Error("Image does not have a geo transformation.");
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Is this image a reduced size image
|
|
1230
|
+
* @see {@link TiffTag.SubFileType}
|
|
1231
|
+
* @returns true if SubFileType is Reduces image, false otherwise
|
|
1232
|
+
*/
|
|
1233
|
+
get isSubImage() {
|
|
1234
|
+
return this.value(TiffTag.SubFileType) === SubFileType.ReducedImage;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Bounding box of the image
|
|
1238
|
+
*
|
|
1239
|
+
* @returns [minX, minY, maxX, maxY] bounding box
|
|
1240
|
+
*/
|
|
1241
|
+
get bbox() {
|
|
1242
|
+
const size = this.size;
|
|
1243
|
+
const origin = this.origin;
|
|
1244
|
+
const resolution = this.resolution;
|
|
1245
|
+
if (origin == null || size == null || resolution == null) throw new Error("Unable to calculate bounding box");
|
|
1246
|
+
const x1 = origin[0];
|
|
1247
|
+
const y1 = origin[1];
|
|
1248
|
+
const x2 = x1 + resolution[0] * size.width;
|
|
1249
|
+
const y2 = y1 + resolution[1] * size.height;
|
|
1250
|
+
return [
|
|
1251
|
+
Math.min(x1, x2),
|
|
1252
|
+
Math.min(y1, y2),
|
|
1253
|
+
Math.max(x1, x2),
|
|
1254
|
+
Math.max(y1, y2)
|
|
1255
|
+
];
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Get the compression used by the tile
|
|
1259
|
+
*
|
|
1260
|
+
* @see {@link TiffCompressionMimeType}
|
|
1261
|
+
*
|
|
1262
|
+
* @returns Compression type eg webp
|
|
1263
|
+
*/
|
|
1264
|
+
get compression() {
|
|
1265
|
+
const compression = this.value(TiffTag.Compression);
|
|
1266
|
+
if (compression == null) return null;
|
|
1267
|
+
return TiffCompressionMimeType[compression];
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Attempt to read the EPSG Code from TiffGeoTags
|
|
1271
|
+
*
|
|
1272
|
+
* looks at TiffTagGeo.ProjectionGeoKey, TiffTagGeo.ProjectedCRSGeoKey and TiffTagGeo.GeodeticCRSGeoKey
|
|
1273
|
+
*
|
|
1274
|
+
* @returns EPSG Code if it exists and is not user defined.
|
|
1275
|
+
*/
|
|
1276
|
+
get epsg() {
|
|
1277
|
+
const proj = this.valueGeo(TiffTagGeo.ProjectionGeoKey);
|
|
1278
|
+
if (proj != null && proj !== 32767) return proj;
|
|
1279
|
+
let projection = null;
|
|
1280
|
+
switch (this.valueGeo(TiffTagGeo.GTModelTypeGeoKey)) {
|
|
1281
|
+
case ModelTypeCode.Unknown: return null;
|
|
1282
|
+
case ModelTypeCode.Projected:
|
|
1283
|
+
projection = this.valueGeo(TiffTagGeo.ProjectedCRSGeoKey);
|
|
1284
|
+
break;
|
|
1285
|
+
case ModelTypeCode.Geographic:
|
|
1286
|
+
projection = this.valueGeo(TiffTagGeo.GeodeticCRSGeoKey);
|
|
1287
|
+
break;
|
|
1288
|
+
case ModelTypeCode.Geocentric:
|
|
1289
|
+
projection = this.valueGeo(TiffTagGeo.GeodeticCRSGeoKey);
|
|
1290
|
+
break;
|
|
1291
|
+
case ModelTypeCode.UserDefined: return null;
|
|
1292
|
+
}
|
|
1293
|
+
if (projection === 32767) return null;
|
|
1294
|
+
return projection;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Get the size of the image
|
|
1298
|
+
*
|
|
1299
|
+
* @returns Size in pixels
|
|
1300
|
+
*/
|
|
1301
|
+
get size() {
|
|
1302
|
+
const width = this.value(TiffTag.ImageWidth);
|
|
1303
|
+
const height = this.value(TiffTag.ImageHeight);
|
|
1304
|
+
if (width == null || height == null) throw new Error("Tiff has no height or width");
|
|
1305
|
+
return {
|
|
1306
|
+
width,
|
|
1307
|
+
height
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Determine if this image is tiled
|
|
1312
|
+
*/
|
|
1313
|
+
isTiled() {
|
|
1314
|
+
return this.value(TiffTag.TileWidth) !== null;
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Get size of individual tiles
|
|
1318
|
+
*/
|
|
1319
|
+
get tileSize() {
|
|
1320
|
+
const width = this.value(TiffTag.TileWidth);
|
|
1321
|
+
const height = this.value(TiffTag.TileHeight);
|
|
1322
|
+
if (width == null || height == null) throw new Error("Tiff is not tiled");
|
|
1323
|
+
return {
|
|
1324
|
+
width,
|
|
1325
|
+
height
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Number of tiles used to create this image
|
|
1330
|
+
*/
|
|
1331
|
+
get tileCount() {
|
|
1332
|
+
const size = this.size;
|
|
1333
|
+
const tileSize = this.tileSize;
|
|
1334
|
+
return {
|
|
1335
|
+
x: Math.ceil(size.width / tileSize.width),
|
|
1336
|
+
y: Math.ceil(size.height / tileSize.height)
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Get the pointer to where the tiles start in the Tiff file
|
|
1341
|
+
*
|
|
1342
|
+
* @remarks Used to read tiled tiffs
|
|
1343
|
+
*
|
|
1344
|
+
* @returns file offset to where the tiffs are stored
|
|
1345
|
+
*/
|
|
1346
|
+
get tileOffset() {
|
|
1347
|
+
const tileOffset = this.tags.get(TiffTag.TileOffsets);
|
|
1348
|
+
if (tileOffset == null) throw new Error("No tile offsets found");
|
|
1349
|
+
return tileOffset;
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Get the number of strip's inside this tiff
|
|
1353
|
+
*
|
|
1354
|
+
* @remarks Used to read striped tiffs
|
|
1355
|
+
*
|
|
1356
|
+
* @returns number of strips present
|
|
1357
|
+
*/
|
|
1358
|
+
get stripCount() {
|
|
1359
|
+
return this.tags.get(TiffTag.StripByteCounts)?.count ?? 0;
|
|
1360
|
+
}
|
|
1361
|
+
getTileBounds(x, y) {
|
|
1362
|
+
const { size, tileSize } = this;
|
|
1363
|
+
const top = y * tileSize.height;
|
|
1364
|
+
const left = x * tileSize.width;
|
|
1365
|
+
return {
|
|
1366
|
+
x: left,
|
|
1367
|
+
y: top,
|
|
1368
|
+
width: left + tileSize.width >= size.width ? size.width - left : tileSize.width,
|
|
1369
|
+
height: top + tileSize.height >= size.height ? size.height - top : tileSize.height
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Read a strip into a ArrayBuffer
|
|
1374
|
+
*
|
|
1375
|
+
* Image has to be striped see {@link stripCount}
|
|
1376
|
+
*
|
|
1377
|
+
* @param index Strip index to read
|
|
1378
|
+
*/
|
|
1379
|
+
async getStrip(index, options) {
|
|
1380
|
+
if (this.isTiled()) throw new Error("Cannot read stripes, tiff is tiled: " + index);
|
|
1381
|
+
const byteCounts = this.tags.get(TiffTag.StripByteCounts);
|
|
1382
|
+
const offsets = this.tags.get(TiffTag.StripOffsets);
|
|
1383
|
+
if (index >= byteCounts.count) throw new Error("Cannot read strip, index out of bounds");
|
|
1384
|
+
const [byteCount, offset] = await Promise.all([getOffset(this.tiff, offsets, index, options), getOffset(this.tiff, byteCounts, index, options)]);
|
|
1385
|
+
return this.getBytes(byteCount, offset, options);
|
|
1386
|
+
}
|
|
1387
|
+
/** The jpeg header is stored in the IFD, read the JPEG header and adjust the byte array to include it */
|
|
1388
|
+
getJpegHeader(bytes) {
|
|
1389
|
+
const tables = this.value(TiffTag.JpegTables);
|
|
1390
|
+
if (tables == null) throw new Error("Unable to find Jpeg header");
|
|
1391
|
+
const tableData = tables.slice(0, tables.length - 2);
|
|
1392
|
+
const actualBytes = new Uint8Array(bytes.byteLength + tableData.length - 2);
|
|
1393
|
+
actualBytes.set(tableData, 0);
|
|
1394
|
+
actualBytes.set(new Uint8Array(bytes).slice(2), tableData.length);
|
|
1395
|
+
return actualBytes.buffer.slice(actualBytes.byteOffset, actualBytes.byteOffset + actualBytes.byteLength);
|
|
1396
|
+
}
|
|
1397
|
+
/** Read image bytes at the given offset */
|
|
1398
|
+
async getBytes(offset, byteCount, options) {
|
|
1399
|
+
if (byteCount === 0) return null;
|
|
1400
|
+
const bytes = await this.tiff.source.fetch(offset, byteCount, options);
|
|
1401
|
+
if (bytes.byteLength < byteCount) throw new Error(`Failed to fetch bytes from offset:${offset} wanted:${byteCount} got:${bytes.byteLength}`);
|
|
1402
|
+
let compression = this.value(TiffTag.Compression);
|
|
1403
|
+
if (compression == null) compression = Compression.None;
|
|
1404
|
+
const mimeType = getCompressionMimeType(compression) ?? TiffMimeType.None;
|
|
1405
|
+
if (compression === Compression.Jpeg) return {
|
|
1406
|
+
mimeType,
|
|
1407
|
+
bytes: this.getJpegHeader(bytes),
|
|
1408
|
+
compression
|
|
1409
|
+
};
|
|
1410
|
+
return {
|
|
1411
|
+
mimeType,
|
|
1412
|
+
bytes,
|
|
1413
|
+
compression
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Load a tile into a ArrayBuffer
|
|
1418
|
+
*
|
|
1419
|
+
* if the tile compression is JPEG, This will also apply the JPEG compression tables to the resulting ArrayBuffer see {@link getJpegHeader}
|
|
1420
|
+
*
|
|
1421
|
+
* @param x Tile x offset
|
|
1422
|
+
* @param y Tile y offset
|
|
1423
|
+
*/
|
|
1424
|
+
async getTile(x, y, options) {
|
|
1425
|
+
const size = this.size;
|
|
1426
|
+
const tiles = this.tileSize;
|
|
1427
|
+
if (tiles == null) throw new Error("Tiff is not tiled");
|
|
1428
|
+
const nyTiles = Math.ceil(size.height / tiles.height);
|
|
1429
|
+
const nxTiles = Math.ceil(size.width / tiles.width);
|
|
1430
|
+
if (x >= nxTiles || y >= nyTiles) throw new Error(`Tile index is outside of range x:${x} >= ${nxTiles} or y:${y} >= ${nyTiles}`);
|
|
1431
|
+
const idx = y * nxTiles + x;
|
|
1432
|
+
const totalTiles = nxTiles * nyTiles;
|
|
1433
|
+
if (idx >= totalTiles) throw new Error(`Tile index is outside of tile range: ${idx} >= ${totalTiles}`);
|
|
1434
|
+
const { offset, imageSize } = await this.getTileSize(idx, options);
|
|
1435
|
+
return this.getBytes(offset, imageSize, options);
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Does this tile exist in the tiff and does it actually have a value
|
|
1439
|
+
*
|
|
1440
|
+
* Sparse tiffs can have a lot of empty tiles, they set the tile size to `0 bytes` when the tile is empty
|
|
1441
|
+
* this checks the tile byte size to validate if it actually has any data.
|
|
1442
|
+
*
|
|
1443
|
+
* @param x Tile x offset
|
|
1444
|
+
* @param y Tile y offset
|
|
1445
|
+
*
|
|
1446
|
+
* @returns if the tile exists and has data
|
|
1447
|
+
*/
|
|
1448
|
+
async hasTile(x, y, options) {
|
|
1449
|
+
const tiles = this.tileSize;
|
|
1450
|
+
const size = this.size;
|
|
1451
|
+
if (tiles == null) throw new Error("Tiff is not tiled");
|
|
1452
|
+
const nyTiles = Math.ceil(size.height / tiles.height);
|
|
1453
|
+
const nxTiles = Math.ceil(size.width / tiles.width);
|
|
1454
|
+
if (x >= nxTiles || y >= nyTiles) return false;
|
|
1455
|
+
const idx = y * nxTiles + x;
|
|
1456
|
+
return (await this.getTileSize(idx, options)).offset > 0;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Load the offset and byteCount of a tile
|
|
1460
|
+
*
|
|
1461
|
+
* if the tiff is sparse, offset and byteCount will be zero if the tile is empty
|
|
1462
|
+
*
|
|
1463
|
+
* @param index index in the tile array
|
|
1464
|
+
* @returns Offset and byteCount for the tile
|
|
1465
|
+
*/
|
|
1466
|
+
async getTileSize(index, options) {
|
|
1467
|
+
const byteCounts = this.tags.get(TiffTag.TileByteCounts);
|
|
1468
|
+
const tileOffset = getOffsetSync(this.tiff, this.tileOffset, index);
|
|
1469
|
+
const tileSize = getOffsetSync(this.tiff, byteCounts, index);
|
|
1470
|
+
if (tileOffset != null && tileSize != null) return {
|
|
1471
|
+
offset: tileOffset,
|
|
1472
|
+
imageSize: tileSize
|
|
1473
|
+
};
|
|
1474
|
+
const leaderBytes = this.tiff.options?.tileLeaderByteSize;
|
|
1475
|
+
if (leaderBytes) {
|
|
1476
|
+
const offset = tileOffset ?? await getOffset(this.tiff, this.tileOffset, index, options);
|
|
1477
|
+
if (offset === 0) return {
|
|
1478
|
+
offset: 0,
|
|
1479
|
+
imageSize: 0
|
|
1480
|
+
};
|
|
1481
|
+
const bytes = await this.tiff.source.fetch(offset - leaderBytes, leaderBytes, options);
|
|
1482
|
+
return {
|
|
1483
|
+
offset,
|
|
1484
|
+
imageSize: getUint(new DataView(bytes), 0, leaderBytes, this.tiff.isLittleEndian)
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
if (byteCounts == null) throw new Error("No tile byte counts found");
|
|
1488
|
+
const [offset, imageSize] = await Promise.all([tileOffset ?? getOffset(this.tiff, this.tileOffset, index, options), tileSize ?? getOffset(this.tiff, byteCounts, index, options)]);
|
|
1489
|
+
return {
|
|
1490
|
+
offset,
|
|
1491
|
+
imageSize
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
function getOffset(tiff, x, index, options) {
|
|
1496
|
+
const val = getOffsetSync(tiff, x, index);
|
|
1497
|
+
if (val != null) return Promise.resolve(val);
|
|
1498
|
+
return getValueAt(tiff, x, index, options);
|
|
1499
|
+
}
|
|
1500
|
+
function getOffsetSync(tiff, x, index) {
|
|
1501
|
+
if (index < 0) throw new Error(`Tiff: ${tiff.source.url.href} out of bounds ${TiffTag[x.id]} index:${index} total:${x.count}`);
|
|
1502
|
+
if (index >= x.count) return 0;
|
|
1503
|
+
if (x.type === "inline") return x.value[index];
|
|
1504
|
+
if (x.isLoaded) return x.value[index];
|
|
1505
|
+
return getValueAtSync(tiff, x, index);
|
|
1506
|
+
}
|
|
1507
|
+
//#endregion
|
|
1508
|
+
//#region node_modules/@cogeotiff/core/build/read/tiff.gdal.js
|
|
1509
|
+
var GhostOption;
|
|
1510
|
+
(function(GhostOption) {
|
|
1511
|
+
GhostOption["GdalStructuralMetadataSize"] = "GDAL_STRUCTURAL_METADATA_SIZE";
|
|
1512
|
+
GhostOption["Layout"] = "LAYOUT";
|
|
1513
|
+
GhostOption["BlockOrder"] = "BLOCK_ORDER";
|
|
1514
|
+
GhostOption["BlockLeader"] = "BLOCK_LEADER";
|
|
1515
|
+
GhostOption["BlockTrailer"] = "BLOCK_TRAILER";
|
|
1516
|
+
GhostOption["KnownIncompatibleEdition"] = "KNOWN_INCOMPATIBLE_EDITION";
|
|
1517
|
+
GhostOption["MaskInterleavedWithImagery"] = "MASK_INTERLEAVED_WITH_IMAGERY";
|
|
1518
|
+
})(GhostOption || (GhostOption = {}));
|
|
1519
|
+
var GhostOptionTileOrder;
|
|
1520
|
+
(function(GhostOptionTileOrder) {
|
|
1521
|
+
GhostOptionTileOrder["RowMajor"] = "ROW_MAJOR";
|
|
1522
|
+
})(GhostOptionTileOrder || (GhostOptionTileOrder = {}));
|
|
1523
|
+
var GhostOptionTileLeader;
|
|
1524
|
+
(function(GhostOptionTileLeader) {
|
|
1525
|
+
GhostOptionTileLeader["uint32"] = "SIZE_AS_UINT4";
|
|
1526
|
+
})(GhostOptionTileLeader || (GhostOptionTileLeader = {}));
|
|
1527
|
+
/**
|
|
1528
|
+
* GDAL has made a ghost set of options for Tiff files
|
|
1529
|
+
* this class represents the optimizations that GDAL has applied
|
|
1530
|
+
*/
|
|
1531
|
+
var TiffGhostOptions = class {
|
|
1532
|
+
options = /* @__PURE__ */ new Map();
|
|
1533
|
+
/**
|
|
1534
|
+
* Has GDAL optimized this tiff
|
|
1535
|
+
*/
|
|
1536
|
+
get isCogOptimized() {
|
|
1537
|
+
if (this.isBroken) return false;
|
|
1538
|
+
return this.options.get(GhostOption.Layout) === "IFDS_BEFORE_DATA";
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Has GDAL determined this tiff is now broken
|
|
1542
|
+
*/
|
|
1543
|
+
get isBroken() {
|
|
1544
|
+
return this.options.get(GhostOption.KnownIncompatibleEdition) === "YES";
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Load the ghost options from a source
|
|
1548
|
+
* @param bytes the ghost header bytes
|
|
1549
|
+
*/
|
|
1550
|
+
process(bytes, offset, ghostSize) {
|
|
1551
|
+
let key = "";
|
|
1552
|
+
let value = "";
|
|
1553
|
+
let setValue = false;
|
|
1554
|
+
for (let i = 0; i < ghostSize; i++) {
|
|
1555
|
+
const charCode = bytes.getUint8(offset + i);
|
|
1556
|
+
if (charCode === 0) break;
|
|
1557
|
+
const char = String.fromCharCode(charCode);
|
|
1558
|
+
if (char === "\n") {
|
|
1559
|
+
this.options.set(key.trim(), value.trim());
|
|
1560
|
+
key = "";
|
|
1561
|
+
value = "";
|
|
1562
|
+
setValue = false;
|
|
1563
|
+
} else if (char === "=") setValue = true;
|
|
1564
|
+
else if (setValue) value += char;
|
|
1565
|
+
else key += char;
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* If the tile leader is set, how many bytes are allocated to the tile size
|
|
1570
|
+
*/
|
|
1571
|
+
get tileLeaderByteSize() {
|
|
1572
|
+
switch (this.options.get(GhostOption.BlockLeader)) {
|
|
1573
|
+
case GhostOptionTileLeader.uint32: return ByteSize.UInt32;
|
|
1574
|
+
default: return null;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
get isMaskInterleaved() {
|
|
1578
|
+
return this.options.get(GhostOption.MaskInterleavedWithImagery) === "YES";
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
//#endregion
|
|
1582
|
+
//#region node_modules/@cogeotiff/core/build/read/tiff.ifd.config.js
|
|
1583
|
+
var TagTiffConfig = {
|
|
1584
|
+
version: TiffVersion.Tiff,
|
|
1585
|
+
pointer: ByteSize.UInt32,
|
|
1586
|
+
offset: ByteSize.UInt16,
|
|
1587
|
+
/**
|
|
1588
|
+
* Each tag entry is specified as
|
|
1589
|
+
* UInt16:TagCode
|
|
1590
|
+
* UInt16:TagType
|
|
1591
|
+
* UInt32:TagCount
|
|
1592
|
+
* UInt32:Pointer To Value or value
|
|
1593
|
+
*/
|
|
1594
|
+
ifd: ByteSize.UInt16 + ByteSize.UInt16 + 2 * ByteSize.UInt32
|
|
1595
|
+
};
|
|
1596
|
+
var TagTiffBigConfig = {
|
|
1597
|
+
version: TiffVersion.BigTiff,
|
|
1598
|
+
/** Size of most pointers */
|
|
1599
|
+
pointer: ByteSize.UInt64,
|
|
1600
|
+
/** Size of offsets */
|
|
1601
|
+
offset: ByteSize.UInt64,
|
|
1602
|
+
/**
|
|
1603
|
+
* Each tag entry is specified as
|
|
1604
|
+
* UInt16:TagCode
|
|
1605
|
+
* UInt16:TagType
|
|
1606
|
+
* UInt64:TagCount
|
|
1607
|
+
* UInt64:Pointer To Value or value
|
|
1608
|
+
*/
|
|
1609
|
+
ifd: ByteSize.UInt16 + ByteSize.UInt16 + 2 * ByteSize.UInt64
|
|
1610
|
+
};
|
|
1611
|
+
TiffVersion.BigTiff, TiffVersion.Tiff;
|
|
1612
|
+
//#endregion
|
|
1613
|
+
//#region node_modules/@cogeotiff/core/build/util/util.hex.js
|
|
1614
|
+
/**
|
|
1615
|
+
* Convert a number to a formatted hex string
|
|
1616
|
+
*
|
|
1617
|
+
* @param num number to convert
|
|
1618
|
+
* @param padding number of 0's to pad the digit with
|
|
1619
|
+
* @param prefix should a `0x` be prefixed to the string
|
|
1620
|
+
*
|
|
1621
|
+
* @returns hex string eg 0x0015
|
|
1622
|
+
**/
|
|
1623
|
+
function toHex(num, padding = 4, prefix = true) {
|
|
1624
|
+
const hex = num.toString(16).padStart(padding, "0");
|
|
1625
|
+
if (prefix) return "0x" + hex;
|
|
1626
|
+
return hex;
|
|
1627
|
+
}
|
|
1628
|
+
//#endregion
|
|
1629
|
+
//#region node_modules/@cogeotiff/core/build/tiff.js
|
|
1630
|
+
var Tiff = class Tiff {
|
|
1631
|
+
/** Read 16KB blocks at a time */
|
|
1632
|
+
static DefaultReadSize = 16 * 1024;
|
|
1633
|
+
/** Read 16KB blocks at a time */
|
|
1634
|
+
defaultReadSize = Tiff.DefaultReadSize;
|
|
1635
|
+
/** Where this cog is fetching its data from */
|
|
1636
|
+
source;
|
|
1637
|
+
/** Big or small Tiff */
|
|
1638
|
+
version = TiffVersion.Tiff;
|
|
1639
|
+
/** List of images, o is the base image */
|
|
1640
|
+
images = [];
|
|
1641
|
+
/** Ghost header options */
|
|
1642
|
+
options;
|
|
1643
|
+
/** Configuration for the size of the IFD */
|
|
1644
|
+
ifdConfig = TagTiffConfig;
|
|
1645
|
+
/** Is the tiff being read is little Endian */
|
|
1646
|
+
isLittleEndian = false;
|
|
1647
|
+
/** Has init() been called */
|
|
1648
|
+
isInitialized = false;
|
|
1649
|
+
_initPromise;
|
|
1650
|
+
/** A Tiff constructed from a source will not be pre-initialized with {@link init}. */
|
|
1651
|
+
constructor(source, options = { defaultReadSize: Tiff.DefaultReadSize }) {
|
|
1652
|
+
this.source = source;
|
|
1653
|
+
this.defaultReadSize = options.defaultReadSize;
|
|
1654
|
+
}
|
|
1655
|
+
/** Create a tiff and initialize it by reading the tiff headers */
|
|
1656
|
+
static create(source, options = { defaultReadSize: Tiff.DefaultReadSize }) {
|
|
1657
|
+
return new Tiff(source, options).init(options);
|
|
1658
|
+
}
|
|
1659
|
+
/**
|
|
1660
|
+
* Initialize the tiff loading in the header and all image headers.
|
|
1661
|
+
*
|
|
1662
|
+
* This is only required if the Tiff was created with the constructor, if you
|
|
1663
|
+
* used {@link create} this will have already been called.
|
|
1664
|
+
*/
|
|
1665
|
+
init(options) {
|
|
1666
|
+
if (this.isInitialized) return Promise.resolve(this);
|
|
1667
|
+
if (this._initPromise) return this._initPromise;
|
|
1668
|
+
this._initPromise = this.readHeader(options);
|
|
1669
|
+
return this._initPromise;
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Find a image which has a resolution similar to the provided resolution
|
|
1673
|
+
*
|
|
1674
|
+
* @param resolution resolution to find
|
|
1675
|
+
*/
|
|
1676
|
+
getImageByResolution(resolution) {
|
|
1677
|
+
const firstImage = this.images[0];
|
|
1678
|
+
const firstImageSize = firstImage.size;
|
|
1679
|
+
const [refX] = firstImage.resolution;
|
|
1680
|
+
const resolutionBaseX = refX * firstImageSize.width;
|
|
1681
|
+
for (let i = this.images.length - 1; i > 0; i--) {
|
|
1682
|
+
const img = this.images[i];
|
|
1683
|
+
if (resolutionBaseX / img.size.width - resolution <= .01) return img;
|
|
1684
|
+
}
|
|
1685
|
+
return firstImage;
|
|
1686
|
+
}
|
|
1687
|
+
/** Read the Starting header and all Image headers from the source */
|
|
1688
|
+
async readHeader(options) {
|
|
1689
|
+
if (this.isInitialized) return this;
|
|
1690
|
+
const bytes = new DataView(await this.source.fetch(0, getMaxLength(this.source, 0, this.defaultReadSize), options));
|
|
1691
|
+
if (bytes.byteLength === 0) throw new Error("Unable to read empty tiff");
|
|
1692
|
+
bytes.sourceOffset = 0;
|
|
1693
|
+
let offset = 0;
|
|
1694
|
+
const endian = bytes.getUint16(offset, this.isLittleEndian);
|
|
1695
|
+
offset += 2;
|
|
1696
|
+
this.isLittleEndian = endian === TiffEndian.Little;
|
|
1697
|
+
this.version = bytes.getUint16(offset, this.isLittleEndian);
|
|
1698
|
+
offset += 2;
|
|
1699
|
+
let nextOffsetIfd;
|
|
1700
|
+
if (this.version === TiffVersion.BigTiff) {
|
|
1701
|
+
this.ifdConfig = TagTiffBigConfig;
|
|
1702
|
+
const pointerSize = bytes.getUint16(offset, this.isLittleEndian);
|
|
1703
|
+
offset += 2;
|
|
1704
|
+
if (pointerSize !== 8) throw new Error("Only 8byte pointers are supported");
|
|
1705
|
+
const zeros = bytes.getUint16(offset, this.isLittleEndian);
|
|
1706
|
+
offset += 2;
|
|
1707
|
+
if (zeros !== 0) throw new Error("Invalid big tiff header");
|
|
1708
|
+
nextOffsetIfd = getUint(bytes, offset, this.ifdConfig.pointer, this.isLittleEndian);
|
|
1709
|
+
offset += this.ifdConfig.pointer;
|
|
1710
|
+
} else if (this.version === TiffVersion.Tiff) {
|
|
1711
|
+
nextOffsetIfd = getUint(bytes, offset, this.ifdConfig.pointer, this.isLittleEndian);
|
|
1712
|
+
offset += this.ifdConfig.pointer;
|
|
1713
|
+
} else throw new Error(`Only tiff supported version:${String(this.version)}`);
|
|
1714
|
+
const ghostSize = nextOffsetIfd - offset;
|
|
1715
|
+
if (ghostSize > 0 && ghostSize < 16 * 1024) {
|
|
1716
|
+
this.options = new TiffGhostOptions();
|
|
1717
|
+
this.options.process(bytes, offset, ghostSize);
|
|
1718
|
+
}
|
|
1719
|
+
while (nextOffsetIfd !== 0) {
|
|
1720
|
+
let lastView = bytes;
|
|
1721
|
+
if (!hasBytes(lastView, nextOffsetIfd, 1024)) {
|
|
1722
|
+
const bytes = await this.source.fetch(nextOffsetIfd, getMaxLength(this.source, nextOffsetIfd, this.defaultReadSize), options);
|
|
1723
|
+
lastView = new DataView(bytes);
|
|
1724
|
+
lastView.sourceOffset = nextOffsetIfd;
|
|
1725
|
+
}
|
|
1726
|
+
nextOffsetIfd = this.readIfd(nextOffsetIfd, lastView);
|
|
1727
|
+
}
|
|
1728
|
+
await Promise.all(this.images.map((i) => i.init(true, options)));
|
|
1729
|
+
this.isInitialized = true;
|
|
1730
|
+
return this;
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Read a IFD at a the provided offset
|
|
1734
|
+
*
|
|
1735
|
+
* @param offset file offset to read the header from
|
|
1736
|
+
* @param view offset that contains the bytes for the header
|
|
1737
|
+
*/
|
|
1738
|
+
readIfd(offset, view) {
|
|
1739
|
+
const viewOffset = offset - view.sourceOffset;
|
|
1740
|
+
const tagCount = getUint(view, viewOffset, this.ifdConfig.offset, this.isLittleEndian);
|
|
1741
|
+
const tags = /* @__PURE__ */ new Map();
|
|
1742
|
+
if (!hasBytes(view, offset, tagCount * this.ifdConfig.ifd)) throw new Error("IFD out of range @ " + toHex(offset) + " IFD" + this.images.length);
|
|
1743
|
+
const ifdSize = this.ifdConfig.ifd;
|
|
1744
|
+
const startOffset = viewOffset + this.ifdConfig.offset;
|
|
1745
|
+
for (let i = 0; i < tagCount; i++) {
|
|
1746
|
+
const tag = createTag(this, view, startOffset + i * ifdSize);
|
|
1747
|
+
tags.set(tag.id, tag);
|
|
1748
|
+
}
|
|
1749
|
+
this.images.push(new TiffImage(this, this.images.length, tags));
|
|
1750
|
+
return getUint(view, startOffset + tagCount * ifdSize, this.ifdConfig.pointer, this.isLittleEndian);
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
function getMaxLength(source, offset, length) {
|
|
1754
|
+
const size = source.metadata?.size;
|
|
1755
|
+
if (size == null || size < 0) return length;
|
|
1756
|
+
if (offset + length > size) return size - offset;
|
|
1757
|
+
return length;
|
|
1758
|
+
}
|
|
1759
|
+
//#endregion
|
|
1760
|
+
//#region node_modules/@developmentseed/geotiff/dist/codecs/canvas.js
|
|
1761
|
+
async function decode$2(bytes, metadata) {
|
|
1762
|
+
const blob = new Blob([bytes]);
|
|
1763
|
+
const imageBitmap = await createImageBitmap(blob);
|
|
1764
|
+
const canvas = new OffscreenCanvas(imageBitmap.width, imageBitmap.height);
|
|
1765
|
+
const ctx = canvas.getContext("2d");
|
|
1766
|
+
ctx.drawImage(imageBitmap, 0, 0);
|
|
1767
|
+
imageBitmap.close();
|
|
1768
|
+
const { width, height } = canvas;
|
|
1769
|
+
const rgba = ctx.getImageData(0, 0, width, height).data;
|
|
1770
|
+
const samplesPerPixel = metadata.samplesPerPixel;
|
|
1771
|
+
if (samplesPerPixel === 4) return {
|
|
1772
|
+
layout: "pixel-interleaved",
|
|
1773
|
+
data: rgba
|
|
1774
|
+
};
|
|
1775
|
+
if (samplesPerPixel === 3) {
|
|
1776
|
+
const pixelCount = width * height;
|
|
1777
|
+
const rgb = new Uint8ClampedArray(pixelCount * 3);
|
|
1778
|
+
for (let i = 0, j = 0; i < rgb.length; i += 3, j += 4) {
|
|
1779
|
+
rgb[i] = rgba[j];
|
|
1780
|
+
rgb[i + 1] = rgba[j + 1];
|
|
1781
|
+
rgb[i + 2] = rgba[j + 2];
|
|
1782
|
+
}
|
|
1783
|
+
return {
|
|
1784
|
+
layout: "pixel-interleaved",
|
|
1785
|
+
data: rgb
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
throw new Error(`Unsupported SamplesPerPixel for JPEG: ${samplesPerPixel}`);
|
|
1789
|
+
}
|
|
1790
|
+
//#endregion
|
|
1791
|
+
//#region node_modules/@developmentseed/geotiff/dist/codecs/decompression-stream.js
|
|
1792
|
+
function assert(expression, msg = "") {
|
|
1793
|
+
if (!expression) throw new Error(msg);
|
|
1794
|
+
}
|
|
1795
|
+
async function decompressWithDecompressionStream(data, { format, signal }) {
|
|
1796
|
+
const response = data instanceof Response ? data : new Response(data);
|
|
1797
|
+
assert(response.body, "Response does not contain body.");
|
|
1798
|
+
try {
|
|
1799
|
+
return await new Response(response.body.pipeThrough(new DecompressionStream(format), { signal })).arrayBuffer();
|
|
1800
|
+
} catch {
|
|
1801
|
+
signal?.throwIfAborted();
|
|
1802
|
+
throw new Error(`Failed to decode ${format}`);
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
//#endregion
|
|
1806
|
+
//#region node_modules/@developmentseed/geotiff/dist/codecs/deflate.js
|
|
1807
|
+
async function decode$1(bytes) {
|
|
1808
|
+
return decompressWithDecompressionStream(bytes, { format: "deflate" });
|
|
1809
|
+
}
|
|
1810
|
+
//#endregion
|
|
1811
|
+
//#region node_modules/@developmentseed/geotiff/dist/codecs/predictor.js
|
|
1812
|
+
/**
|
|
1813
|
+
* Undo TIFF horizontal differencing (predictor 2) or floating-point
|
|
1814
|
+
* prediction (predictor 3) in-place on a decoded tile buffer.
|
|
1815
|
+
*
|
|
1816
|
+
* Mirrors the applyPredictor logic in geotiff.js.
|
|
1817
|
+
*/
|
|
1818
|
+
/** Undo horizontal differencing for integer samples (predictor 2). */
|
|
1819
|
+
function decodeRowAcc(row, stride) {
|
|
1820
|
+
const r = row;
|
|
1821
|
+
let offset = 0;
|
|
1822
|
+
let length = row.length - stride;
|
|
1823
|
+
do {
|
|
1824
|
+
for (let i = stride; i > 0; i--) {
|
|
1825
|
+
r[offset + stride] = (r[offset + stride] ?? 0) + (r[offset] ?? 0);
|
|
1826
|
+
offset++;
|
|
1827
|
+
}
|
|
1828
|
+
length -= stride;
|
|
1829
|
+
} while (length > 0);
|
|
1830
|
+
}
|
|
1831
|
+
/** Undo floating-point horizontal differencing (predictor 3). */
|
|
1832
|
+
function decodeRowFloatingPoint(row, stride, bytesPerSample) {
|
|
1833
|
+
let index = 0;
|
|
1834
|
+
let count = row.length;
|
|
1835
|
+
const wc = count / bytesPerSample;
|
|
1836
|
+
while (count > stride) {
|
|
1837
|
+
for (let i = stride; i > 0; i--) {
|
|
1838
|
+
row[index + stride] += row[index];
|
|
1839
|
+
index++;
|
|
1840
|
+
}
|
|
1841
|
+
count -= stride;
|
|
1842
|
+
}
|
|
1843
|
+
const copy = row.slice();
|
|
1844
|
+
for (let i = 0; i < wc; i++) for (let b = 0; b < bytesPerSample; b++) row[bytesPerSample * i + b] = copy[(bytesPerSample - b - 1) * wc + i];
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Apply TIFF predictor decoding to a raw decoded tile buffer in-place.
|
|
1848
|
+
*
|
|
1849
|
+
* @param block Decoded tile bytes.
|
|
1850
|
+
* @param predictor Predictor enum value.
|
|
1851
|
+
* @param width Tile width in pixels.
|
|
1852
|
+
* @param height Tile height in pixels.
|
|
1853
|
+
* @param bitsPerSample Bits per sample (all samples must be equal).
|
|
1854
|
+
* @param samplesPerPixel Number of bands.
|
|
1855
|
+
* @param planarConfiguration PlanarConfiguration enum value.
|
|
1856
|
+
*/
|
|
1857
|
+
function applyPredictor(block, predictor, width, height, bitsPerSample, samplesPerPixel, planarConfiguration) {
|
|
1858
|
+
if (predictor === Predictor.None) return block;
|
|
1859
|
+
const bytesPerSample = bitsPerSample / 8;
|
|
1860
|
+
const stride = planarConfiguration === PlanarConfiguration.Separate ? 1 : samplesPerPixel;
|
|
1861
|
+
for (let i = 0; i < height; i++) {
|
|
1862
|
+
const byteOffset = i * stride * width * bytesPerSample;
|
|
1863
|
+
if (byteOffset >= block.byteLength) break;
|
|
1864
|
+
if (predictor === Predictor.Horizontal) {
|
|
1865
|
+
let row;
|
|
1866
|
+
const length = stride * width;
|
|
1867
|
+
switch (bitsPerSample) {
|
|
1868
|
+
case 8:
|
|
1869
|
+
row = new Uint8Array(block, byteOffset, length);
|
|
1870
|
+
break;
|
|
1871
|
+
case 16:
|
|
1872
|
+
row = new Uint16Array(block, byteOffset, length);
|
|
1873
|
+
break;
|
|
1874
|
+
case 32:
|
|
1875
|
+
row = new Uint32Array(block, byteOffset, length);
|
|
1876
|
+
break;
|
|
1877
|
+
default: throw new Error(`Predictor 2 not supported for ${bitsPerSample} bits per sample.`);
|
|
1878
|
+
}
|
|
1879
|
+
decodeRowAcc(row, stride);
|
|
1880
|
+
} else if (predictor === Predictor.FloatingPoint) decodeRowFloatingPoint(new Uint8Array(block, byteOffset, stride * width * bytesPerSample), stride, bytesPerSample);
|
|
1881
|
+
}
|
|
1882
|
+
return block;
|
|
1883
|
+
}
|
|
1884
|
+
//#endregion
|
|
1885
|
+
//#region node_modules/@developmentseed/geotiff/dist/decode.js
|
|
1886
|
+
async function decodeUncompressed(bytes) {
|
|
1887
|
+
return bytes;
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* The global registry of decoders for each compression type.
|
|
1891
|
+
*
|
|
1892
|
+
* This maps a {@link Compression} value to a function that returns a promise of
|
|
1893
|
+
* a {@link Decoder}.
|
|
1894
|
+
*/
|
|
1895
|
+
var DECODER_REGISTRY = /* @__PURE__ */ new Map();
|
|
1896
|
+
DECODER_REGISTRY.set(Compression.None, () => Promise.resolve(decodeUncompressed));
|
|
1897
|
+
DECODER_REGISTRY.set(Compression.Deflate, () => Promise.resolve(decode$1));
|
|
1898
|
+
DECODER_REGISTRY.set(Compression.DeflateOther, () => Promise.resolve(decode$1));
|
|
1899
|
+
DECODER_REGISTRY.set(Compression.Lzw, () => import("./lzw-YEsReV21.js").then((m) => m.decode));
|
|
1900
|
+
DECODER_REGISTRY.set(Compression.Zstd, () => import("./zstd-DBZv9xja.js").then((m) => m.decode));
|
|
1901
|
+
DECODER_REGISTRY.set(Compression.Jpeg, () => Promise.resolve(decode$2));
|
|
1902
|
+
DECODER_REGISTRY.set(Compression.Jpeg6, () => Promise.resolve(decode$2));
|
|
1903
|
+
DECODER_REGISTRY.set(Compression.Webp, () => Promise.resolve(decode$2));
|
|
1904
|
+
DECODER_REGISTRY.set(Compression.Lerc, () => import("./lerc-B7WY-v3y.js").then((m) => m.decode));
|
|
1905
|
+
/**
|
|
1906
|
+
* Decode a tile's bytes according to its compression and image metadata.
|
|
1907
|
+
*/
|
|
1908
|
+
async function decode(bytes, compression, metadata) {
|
|
1909
|
+
const loader = DECODER_REGISTRY.get(compression);
|
|
1910
|
+
if (!loader) throw new Error(`Unsupported compression: ${compression}`);
|
|
1911
|
+
const result = await (await loader())(bytes, metadata);
|
|
1912
|
+
if (result instanceof ArrayBuffer) {
|
|
1913
|
+
const { predictor, width, height, bitsPerSample, samplesPerPixel, planarConfiguration } = metadata;
|
|
1914
|
+
return {
|
|
1915
|
+
layout: "pixel-interleaved",
|
|
1916
|
+
data: toTypedArray(applyPredictor(result, predictor, width, height, bitsPerSample, samplesPerPixel, planarConfiguration), metadata)
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
return result;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Unpack a 1-bit packed mask buffer (MSB-first) into a Uint8Array of 0/255.
|
|
1923
|
+
* Each input byte holds 8 pixels; bit 7 is the first pixel in that byte.
|
|
1924
|
+
*/
|
|
1925
|
+
function unpackBitPacked(buffer, pixelCount) {
|
|
1926
|
+
const packed = new Uint8Array(buffer);
|
|
1927
|
+
const out = new Uint8Array(pixelCount);
|
|
1928
|
+
for (let i = 0; i < pixelCount; i++) out[i] = packed[i >> 3] >> 7 - (i & 7) & 1 ? 255 : 0;
|
|
1929
|
+
return out;
|
|
1930
|
+
}
|
|
1931
|
+
/**
|
|
1932
|
+
* Convert a raw ArrayBuffer of pixel data into a typed array based on the
|
|
1933
|
+
* sample format and bits per sample. This is used for codecs that return raw
|
|
1934
|
+
* bytes.
|
|
1935
|
+
*/
|
|
1936
|
+
function toTypedArray(buffer, metadata) {
|
|
1937
|
+
const { sampleFormat, bitsPerSample } = metadata;
|
|
1938
|
+
switch (sampleFormat) {
|
|
1939
|
+
case SampleFormat.Uint:
|
|
1940
|
+
switch (bitsPerSample) {
|
|
1941
|
+
case 1: return unpackBitPacked(buffer, metadata.width * metadata.height * metadata.samplesPerPixel);
|
|
1942
|
+
case 8: return new Uint8Array(buffer);
|
|
1943
|
+
case 16: return new Uint16Array(buffer);
|
|
1944
|
+
case 32: return new Uint32Array(buffer);
|
|
1945
|
+
}
|
|
1946
|
+
break;
|
|
1947
|
+
case SampleFormat.Int:
|
|
1948
|
+
switch (bitsPerSample) {
|
|
1949
|
+
case 8: return new Int8Array(buffer);
|
|
1950
|
+
case 16: return new Int16Array(buffer);
|
|
1951
|
+
case 32: return new Int32Array(buffer);
|
|
1952
|
+
}
|
|
1953
|
+
break;
|
|
1954
|
+
case SampleFormat.Float:
|
|
1955
|
+
switch (bitsPerSample) {
|
|
1956
|
+
case 32: return new Float32Array(buffer);
|
|
1957
|
+
case 64: return new Float64Array(buffer);
|
|
1958
|
+
}
|
|
1959
|
+
break;
|
|
1960
|
+
}
|
|
1961
|
+
throw new Error(`Unsupported sample format/depth: SampleFormat=${sampleFormat}, BitsPerSample=${bitsPerSample}`);
|
|
1962
|
+
}
|
|
1963
|
+
//#endregion
|
|
1964
|
+
export { Photometric as a, RasterTypeKey as c, TiffTag as d, TiffTagGeo as f, Compression as i, SampleFormat as l, decode as n, PlanarConfiguration as o, Tiff as r, Predictor as s, DECODER_REGISTRY as t, SubFileType as u };
|
|
1965
|
+
|
|
1966
|
+
//# sourceMappingURL=decode-BMFOVF9X.js.map
|