@cogeotiff/core 8.1.1 → 9.0.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/CHANGELOG.md +24 -0
- package/README.md +45 -7
- package/build/__benchmark__/cog.read.benchmark.js +5 -5
- package/build/__benchmark__/cog.read.benchmark.js.map +1 -1
- package/build/__benchmark__/source.file.js +1 -1
- package/build/__benchmark__/source.file.js.map +1 -1
- package/build/__test__/cog.image.test.js +14 -9
- package/build/__test__/cog.image.test.js.map +1 -1
- package/build/__test__/cog.read.test.js +33 -17
- package/build/__test__/cog.read.test.js.map +1 -1
- package/build/__test__/example.js +2 -2
- package/build/__test__/example.js.map +1 -1
- package/build/const/index.d.ts +1 -1
- package/build/const/index.js +1 -1
- package/build/const/index.js.map +1 -1
- package/build/const/tiff.mime.d.ts +11 -5
- package/build/const/tiff.mime.js +27 -14
- package/build/const/tiff.mime.js.map +1 -1
- package/build/const/tiff.tag.id.d.ts +603 -41
- package/build/const/tiff.tag.id.js +479 -50
- package/build/const/tiff.tag.id.js.map +1 -1
- package/build/const/tiff.tag.value.js +1 -1
- package/build/const/tiff.tag.value.js.map +1 -1
- package/build/index.d.ts +6 -5
- package/build/index.js +6 -4
- package/build/index.js.map +1 -1
- package/build/read/tiff.gdal.d.ts +1 -1
- package/build/read/tiff.gdal.js +1 -1
- package/build/read/tiff.gdal.js.map +1 -1
- package/build/read/tiff.ifd.config.js +1 -1
- package/build/read/tiff.ifd.config.js.map +1 -1
- package/build/read/tiff.tag.d.ts +3 -0
- package/build/read/tiff.tag.factory.d.ts +5 -5
- package/build/read/tiff.tag.factory.js +22 -13
- package/build/read/tiff.tag.factory.js.map +1 -1
- package/build/read/tiff.value.reader.d.ts +1 -1
- package/build/read/tiff.value.reader.js.map +1 -1
- package/build/{cog.tiff.d.ts → tiff.d.ts} +12 -10
- package/build/{cog.tiff.image.d.ts → tiff.image.d.ts} +69 -27
- package/build/{cog.tiff.image.js → tiff.image.js} +125 -82
- package/build/tiff.image.js.map +1 -0
- package/build/{cog.tiff.js → tiff.js} +17 -10
- package/build/tiff.js.map +1 -0
- package/build/util/bytes.d.ts +4 -2
- package/build/util/bytes.js +5 -2
- package/build/util/bytes.js.map +1 -1
- package/package.json +2 -2
- package/src/__benchmark__/cog.read.benchmark.ts +6 -5
- package/src/__benchmark__/source.file.ts +2 -1
- package/src/__test__/cog.image.test.ts +17 -9
- package/src/__test__/cog.read.test.ts +41 -18
- package/src/__test__/example.ts +3 -2
- package/src/const/index.ts +1 -1
- package/src/const/tiff.mime.ts +28 -14
- package/src/const/tiff.tag.id.ts +758 -131
- package/src/const/tiff.tag.value.ts +16 -16
- package/src/index.ts +20 -5
- package/src/read/tiff.gdal.ts +1 -1
- package/src/read/tiff.ifd.config.ts +1 -1
- package/src/read/tiff.tag.factory.ts +33 -17
- package/src/read/tiff.tag.ts +3 -0
- package/src/read/tiff.value.reader.ts +1 -1
- package/src/{cog.tiff.image.ts → tiff.image.ts} +137 -92
- package/src/{cog.tiff.ts → tiff.ts} +18 -16
- package/src/util/bytes.ts +5 -1
- package/build/cog.tiff.image.js.map +0 -1
- package/build/cog.tiff.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TiffTag, TiffTagGeo } from './const/tiff.tag.id.js';
|
|
1
|
+
import { getCompressionMimeType, TiffCompressionMimeType, TiffMimeType } from './const/tiff.mime.js';
|
|
2
|
+
import { Compression, SubFileType, TiffTag, TiffTagGeo } from './const/tiff.tag.id.js';
|
|
4
3
|
import { fetchAllOffsets, fetchLazy, getValueAt } from './read/tiff.tag.factory.js';
|
|
4
|
+
import { getUint } from './util/bytes.js';
|
|
5
5
|
/** Invalid EPSG code */
|
|
6
6
|
export const InvalidProjectionCode = 32767;
|
|
7
7
|
/** Tags that are commonly accessed for geotiffs */
|
|
@@ -19,15 +19,8 @@ export const ImportantTags = new Set([
|
|
|
19
19
|
TiffTag.GeoDoubleParams,
|
|
20
20
|
TiffTag.TileOffsets,
|
|
21
21
|
]);
|
|
22
|
-
export class
|
|
22
|
+
export class TiffImage {
|
|
23
23
|
constructor(tiff, id, tags) {
|
|
24
|
-
/** All IFD tags that have been read for the image */
|
|
25
|
-
Object.defineProperty(this, "tags", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: void 0
|
|
30
|
-
});
|
|
31
24
|
/**
|
|
32
25
|
* Id of the tif image, generally the image index inside the tif
|
|
33
26
|
* where 0 is the root image, and every sub image is +1
|
|
@@ -61,6 +54,13 @@ export class CogTiffImage {
|
|
|
61
54
|
writable: true,
|
|
62
55
|
value: new Map()
|
|
63
56
|
});
|
|
57
|
+
/** All IFD tags that have been read for the image */
|
|
58
|
+
Object.defineProperty(this, "tags", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
value: void 0
|
|
63
|
+
});
|
|
64
64
|
this.tiff = tiff;
|
|
65
65
|
this.id = id;
|
|
66
66
|
this.tags = tags;
|
|
@@ -91,9 +91,12 @@ export class CogTiffImage {
|
|
|
91
91
|
await this.loadGeoTiffTags();
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
|
-
* Get the value of a TiffTag if it has been loaded, null otherwise
|
|
94
|
+
* Get the value of a TiffTag if it has been loaded, null otherwise.
|
|
95
|
+
*
|
|
96
|
+
* If the value is not loaded use {@link TiffImage.fetch} to load the value
|
|
97
|
+
* Or use {@link TiffImage.has} to check if the tag exists
|
|
98
|
+
*
|
|
95
99
|
*
|
|
96
|
-
* if the value is not loaded @see {CogTiffImage.fetch}
|
|
97
100
|
* @returns value if loaded, null otherwise
|
|
98
101
|
*/
|
|
99
102
|
value(tag) {
|
|
@@ -102,8 +105,77 @@ export class CogTiffImage {
|
|
|
102
105
|
return null;
|
|
103
106
|
if (sourceTag.type === 'offset' && sourceTag.isLoaded === false)
|
|
104
107
|
return null;
|
|
108
|
+
// TODO would be good to type check this
|
|
105
109
|
return sourceTag.value;
|
|
106
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Does the tag exist
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* img.has(TiffTag.ImageWidth) // true
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @param tag Tag to check
|
|
120
|
+
* @returns true if the tag exists, false otherwise
|
|
121
|
+
*/
|
|
122
|
+
has(tag) {
|
|
123
|
+
return this.tags.has(tag);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Load a tag.
|
|
127
|
+
*
|
|
128
|
+
* If it is not currently loaded, fetch the required data for the tag.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* await img.fetch(TiffTag.ImageWidth) // 512 (px)
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @param tag tag to fetch
|
|
136
|
+
*/
|
|
137
|
+
async fetch(tag) {
|
|
138
|
+
const sourceTag = this.tags.get(tag);
|
|
139
|
+
if (sourceTag == null)
|
|
140
|
+
return null;
|
|
141
|
+
if (sourceTag.type === 'inline')
|
|
142
|
+
return sourceTag.value;
|
|
143
|
+
if (sourceTag.type === 'lazy')
|
|
144
|
+
return fetchLazy(sourceTag, this.tiff);
|
|
145
|
+
if (sourceTag.isLoaded)
|
|
146
|
+
return sourceTag.value;
|
|
147
|
+
if (sourceTag.type === 'offset')
|
|
148
|
+
return fetchAllOffsets(this.tiff, sourceTag);
|
|
149
|
+
throw new Error('Cannot fetch:' + tag);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get the associated TiffTagGeo
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* image.valueGeo(TiffTagGeo.GTRasterTypeGeoKey)
|
|
157
|
+
* ```
|
|
158
|
+
* @throws if {@link loadGeoTiffTags} has not been called
|
|
159
|
+
*/
|
|
160
|
+
valueGeo(tag) {
|
|
161
|
+
if (this.isGeoTagsLoaded === false)
|
|
162
|
+
throw new Error('loadGeoTiffTags() has not been called');
|
|
163
|
+
return this.tagsGeo.get(tag);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Load and parse the GDAL_NODATA Tifftag
|
|
167
|
+
*
|
|
168
|
+
* @throws if the tag is not loaded
|
|
169
|
+
* @returns null if the tag does not exist
|
|
170
|
+
*/
|
|
171
|
+
get noData() {
|
|
172
|
+
const tag = this.tags.get(TiffTag.GdalNoData);
|
|
173
|
+
if (tag == null)
|
|
174
|
+
return null;
|
|
175
|
+
if (tag.value)
|
|
176
|
+
return Number(tag.value);
|
|
177
|
+
throw new Error('GdalNoData tag is not loaded');
|
|
178
|
+
}
|
|
107
179
|
/**
|
|
108
180
|
* Load and unpack the GeoKeyDirectory
|
|
109
181
|
*
|
|
@@ -158,39 +230,6 @@ export class CogTiffImage {
|
|
|
158
230
|
}
|
|
159
231
|
}
|
|
160
232
|
}
|
|
161
|
-
/**
|
|
162
|
-
* Get the associated TiffTagGeo
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```typescript
|
|
166
|
-
* image.valueGeo(TiffTagGeo.GTRasterTypeGeoKey)
|
|
167
|
-
* ```
|
|
168
|
-
* @throws if {@link loadGeoTiffTags} has not been called
|
|
169
|
-
*/
|
|
170
|
-
valueGeo(tag) {
|
|
171
|
-
if (this.isGeoTagsLoaded === false)
|
|
172
|
-
throw new Error('loadGeoTiffTags() has not been called');
|
|
173
|
-
return this.tagsGeo.get(tag);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Load a tag, if it is not currently loaded, fetch the required data for the tag.
|
|
177
|
-
*
|
|
178
|
-
* @param tag tag to fetch
|
|
179
|
-
*/
|
|
180
|
-
async fetch(tag) {
|
|
181
|
-
const sourceTag = this.tags.get(tag);
|
|
182
|
-
if (sourceTag == null)
|
|
183
|
-
return null;
|
|
184
|
-
if (sourceTag.type === 'inline')
|
|
185
|
-
return sourceTag.value;
|
|
186
|
-
if (sourceTag.type === 'lazy')
|
|
187
|
-
return fetchLazy(sourceTag, this.tiff);
|
|
188
|
-
if (sourceTag.isLoaded)
|
|
189
|
-
return sourceTag.value;
|
|
190
|
-
if (sourceTag.type === 'offset')
|
|
191
|
-
return fetchAllOffsets(this.tiff, sourceTag);
|
|
192
|
-
throw new Error('Cannot fetch:' + tag);
|
|
193
|
-
}
|
|
194
233
|
/**
|
|
195
234
|
* Get the origin point for the image
|
|
196
235
|
*
|
|
@@ -206,7 +245,7 @@ export class CogTiffImage {
|
|
|
206
245
|
return [modelTransformation[3], modelTransformation[7], modelTransformation[11]];
|
|
207
246
|
}
|
|
208
247
|
// If this is a sub image, use the origin from the top level image
|
|
209
|
-
if (this.value(TiffTag.
|
|
248
|
+
if (this.value(TiffTag.SubFileType) === SubFileType.ReducedImage && this.id !== 0) {
|
|
210
249
|
return this.tiff.images[0].origin;
|
|
211
250
|
}
|
|
212
251
|
throw new Error('Image does not have a geo transformation.');
|
|
@@ -217,7 +256,7 @@ export class CogTiffImage {
|
|
|
217
256
|
if (isImageLocated)
|
|
218
257
|
return true;
|
|
219
258
|
// If this is a sub image, use the isGeoLocated from the top level image
|
|
220
|
-
if (this.
|
|
259
|
+
if (this.isSubImage && this.id !== 0)
|
|
221
260
|
return this.tiff.images[0].isGeoLocated;
|
|
222
261
|
return false;
|
|
223
262
|
}
|
|
@@ -236,7 +275,7 @@ export class CogTiffImage {
|
|
|
236
275
|
return [modelTransformation[0], modelTransformation[5], modelTransformation[10]];
|
|
237
276
|
}
|
|
238
277
|
// If this is a sub image, use the resolution from the top level image
|
|
239
|
-
if (this.
|
|
278
|
+
if (this.isSubImage && this.id !== 0) {
|
|
240
279
|
const firstImg = this.tiff.images[0];
|
|
241
280
|
const [resX, resY, resZ] = firstImg.resolution;
|
|
242
281
|
const firstImgSize = firstImg.size;
|
|
@@ -246,6 +285,14 @@ export class CogTiffImage {
|
|
|
246
285
|
}
|
|
247
286
|
throw new Error('Image does not have a geo transformation.');
|
|
248
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Is this image a reduced size image
|
|
290
|
+
* @see {@link TiffTag.SubFileType}
|
|
291
|
+
* @returns true if SubFileType is Reduces image, false otherwise
|
|
292
|
+
*/
|
|
293
|
+
get isSubImage() {
|
|
294
|
+
return this.value(TiffTag.SubFileType) === SubFileType.ReducedImage;
|
|
295
|
+
}
|
|
249
296
|
/**
|
|
250
297
|
* Bounding box of the image
|
|
251
298
|
*
|
|
@@ -267,23 +314,25 @@ export class CogTiffImage {
|
|
|
267
314
|
/**
|
|
268
315
|
* Get the compression used by the tile
|
|
269
316
|
*
|
|
270
|
-
* @see {@link
|
|
317
|
+
* @see {@link TiffCompressionMimeType}
|
|
271
318
|
*
|
|
272
319
|
* @returns Compression type eg webp
|
|
273
320
|
*/
|
|
274
321
|
get compression() {
|
|
275
322
|
const compression = this.value(TiffTag.Compression);
|
|
276
|
-
if (compression == null
|
|
323
|
+
if (compression == null)
|
|
277
324
|
return null;
|
|
278
|
-
return
|
|
325
|
+
return TiffCompressionMimeType[compression];
|
|
279
326
|
}
|
|
280
327
|
/**
|
|
281
328
|
* Attempt to read the EPSG Code from TiffGeoTags
|
|
282
329
|
*
|
|
330
|
+
* looks at both TiffTagGeo.ProjectionGeoKey and TiffTagGeo.ProjectedCRSGeoKey
|
|
331
|
+
*
|
|
283
332
|
* @returns EPSG Code if it exists
|
|
284
333
|
*/
|
|
285
334
|
get epsg() {
|
|
286
|
-
const projection = this.valueGeo(TiffTagGeo.
|
|
335
|
+
const projection = this.valueGeo(TiffTagGeo.ProjectionGeoKey) ?? this.valueGeo(TiffTagGeo.ProjectedCRSGeoKey);
|
|
287
336
|
if (projection === InvalidProjectionCode)
|
|
288
337
|
return null;
|
|
289
338
|
return projection;
|
|
@@ -294,10 +343,11 @@ export class CogTiffImage {
|
|
|
294
343
|
* @returns Size in pixels
|
|
295
344
|
*/
|
|
296
345
|
get size() {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
346
|
+
const width = this.value(TiffTag.ImageWidth);
|
|
347
|
+
const height = this.value(TiffTag.ImageWidth);
|
|
348
|
+
if (width == null || height == null)
|
|
349
|
+
throw new Error('Tiff has no height or width');
|
|
350
|
+
return { width, height };
|
|
301
351
|
}
|
|
302
352
|
/**
|
|
303
353
|
* Determine if this image is tiled
|
|
@@ -309,10 +359,11 @@ export class CogTiffImage {
|
|
|
309
359
|
* Get size of individual tiles
|
|
310
360
|
*/
|
|
311
361
|
get tileSize() {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
362
|
+
const width = this.value(TiffTag.TileWidth);
|
|
363
|
+
const height = this.value(TiffTag.TileHeight);
|
|
364
|
+
if (width == null || height == null)
|
|
365
|
+
throw new Error('Tiff is not tiled');
|
|
366
|
+
return { width, height };
|
|
316
367
|
}
|
|
317
368
|
/**
|
|
318
369
|
* Number of tiles used to create this image
|
|
@@ -345,10 +396,7 @@ export class CogTiffImage {
|
|
|
345
396
|
* @returns number of strips present
|
|
346
397
|
*/
|
|
347
398
|
get stripCount() {
|
|
348
|
-
|
|
349
|
-
if (tileOffset == null)
|
|
350
|
-
return 0;
|
|
351
|
-
return tileOffset.count;
|
|
399
|
+
return this.tags.get(TiffTag.StripByteCounts)?.count ?? 0;
|
|
352
400
|
}
|
|
353
401
|
// Clamp the bounds of the output image to the size of the image, as sometimes the edge tiles are not full tiles
|
|
354
402
|
getTileBounds(x, y) {
|
|
@@ -383,7 +431,7 @@ export class CogTiffImage {
|
|
|
383
431
|
getJpegHeader(bytes) {
|
|
384
432
|
// Both the JPEGTable and the Bytes with have the start of image and end of image markers
|
|
385
433
|
// StartOfImage 0xffd8 EndOfImage 0xffd9
|
|
386
|
-
const tables = this.value(TiffTag.
|
|
434
|
+
const tables = this.value(TiffTag.JpegTables);
|
|
387
435
|
if (tables == null)
|
|
388
436
|
throw new Error('Unable to find Jpeg header');
|
|
389
437
|
// Remove EndOfImage marker
|
|
@@ -395,18 +443,19 @@ export class CogTiffImage {
|
|
|
395
443
|
}
|
|
396
444
|
/** Read image bytes at the given offset */
|
|
397
445
|
async getBytes(offset, byteCount) {
|
|
398
|
-
const mimeType = this.compression;
|
|
399
|
-
if (mimeType == null)
|
|
400
|
-
throw new Error('Unsupported compression: ' + this.value(TiffTag.Compression));
|
|
401
446
|
if (byteCount === 0)
|
|
402
447
|
return null;
|
|
403
448
|
const bytes = await this.tiff.source.fetch(offset, byteCount);
|
|
404
449
|
if (bytes.byteLength < byteCount) {
|
|
405
450
|
throw new Error(`Failed to fetch bytes from offset:${offset} wanted:${byteCount} got:${bytes.byteLength}`);
|
|
406
451
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
452
|
+
let compression = this.value(TiffTag.Compression);
|
|
453
|
+
if (compression == null)
|
|
454
|
+
compression = Compression.None; // No compression found default ??
|
|
455
|
+
const mimeType = getCompressionMimeType(compression) ?? TiffMimeType.None;
|
|
456
|
+
if (compression === Compression.Jpeg)
|
|
457
|
+
return { mimeType, bytes: this.getJpegHeader(bytes), compression };
|
|
458
|
+
return { mimeType, bytes, compression };
|
|
410
459
|
}
|
|
411
460
|
/**
|
|
412
461
|
* Load a tile into a ArrayBuffer
|
|
@@ -417,13 +466,10 @@ export class CogTiffImage {
|
|
|
417
466
|
* @param y Tile y offset
|
|
418
467
|
*/
|
|
419
468
|
async getTile(x, y) {
|
|
420
|
-
const mimeType = this.compression;
|
|
421
469
|
const size = this.size;
|
|
422
470
|
const tiles = this.tileSize;
|
|
423
471
|
if (tiles == null)
|
|
424
472
|
throw new Error('Tiff is not tiled');
|
|
425
|
-
if (mimeType == null)
|
|
426
|
-
throw new Error('Unsupported compression: ' + this.value(TiffTag.Compression));
|
|
427
473
|
// TODO support GhostOptionTileOrder
|
|
428
474
|
const nyTiles = Math.ceil(size.height / tiles.height);
|
|
429
475
|
const nxTiles = Math.ceil(size.width / tiles.width);
|
|
@@ -473,7 +519,7 @@ export class CogTiffImage {
|
|
|
473
519
|
const leaderBytes = this.tiff.options?.tileLeaderByteSize;
|
|
474
520
|
if (leaderBytes) {
|
|
475
521
|
const offset = await getOffset(this.tiff, this.tileOffset, index);
|
|
476
|
-
// Sparse
|
|
522
|
+
// Sparse tiff no data found
|
|
477
523
|
if (offset === 0)
|
|
478
524
|
return { offset: 0, imageSize: 0 };
|
|
479
525
|
// This fetch will generally load in the bytes needed for the image too
|
|
@@ -494,11 +540,8 @@ export class CogTiffImage {
|
|
|
494
540
|
function getOffset(tiff, x, index) {
|
|
495
541
|
if (index > x.count || index < 0)
|
|
496
542
|
throw new Error('TagIndex: out of bounds ' + x.id + ' @ ' + index);
|
|
497
|
-
if (x.type === 'inline')
|
|
498
|
-
|
|
499
|
-
return x.value[index];
|
|
500
|
-
return x.value;
|
|
501
|
-
}
|
|
543
|
+
if (x.type === 'inline')
|
|
544
|
+
return x.value[index];
|
|
502
545
|
return getValueAt(tiff, x, index);
|
|
503
546
|
}
|
|
504
|
-
//# sourceMappingURL=
|
|
547
|
+
//# sourceMappingURL=tiff.image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiff.image.js","sourceRoot":"","sources":["../src/tiff.image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAA+B,MAAM,wBAAwB,CAAC;AACpH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGpF,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,wBAAwB;AACxB,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAY3C,mDAAmD;AACnD,MAAM,CAAC,MAAM,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,KAAK,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC;IACrG,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,CAAW,CAAC;IACzD,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { CogTiffImage } from './cog.tiff.image.js';
|
|
2
1
|
import { TiffEndian } from './const/tiff.endian.js';
|
|
3
2
|
import { TiffVersion } from './const/tiff.version.js';
|
|
4
3
|
import { hasBytes } from './read/data.view.offset.js';
|
|
5
|
-
import {
|
|
4
|
+
import { TiffGhostOptions } from './read/tiff.gdal.js';
|
|
6
5
|
import { TagTiffBigConfig, TagTiffConfig } from './read/tiff.ifd.config.js';
|
|
7
6
|
import { createTag } from './read/tiff.tag.factory.js';
|
|
7
|
+
import { TiffImage } from './tiff.image.js';
|
|
8
8
|
import { getUint } from './util/bytes.js';
|
|
9
9
|
import { toHex } from './util/util.hex.js';
|
|
10
|
-
export class
|
|
10
|
+
export class Tiff {
|
|
11
11
|
constructor(source) {
|
|
12
12
|
/** Read 16KB blocks at a time */
|
|
13
13
|
Object.defineProperty(this, "defaultReadSize", {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
configurable: true,
|
|
16
16
|
writable: true,
|
|
17
|
-
value:
|
|
17
|
+
value: Tiff.DefaultReadSize
|
|
18
18
|
});
|
|
19
19
|
/** Where this cog is fetching its data from */
|
|
20
20
|
Object.defineProperty(this, "source", {
|
|
@@ -73,12 +73,12 @@ export class CogTiff {
|
|
|
73
73
|
});
|
|
74
74
|
this.source = source;
|
|
75
75
|
}
|
|
76
|
-
/** Create a
|
|
76
|
+
/** Create a tiff and initialize it by reading the tiff headers */
|
|
77
77
|
static create(source) {
|
|
78
|
-
return new
|
|
78
|
+
return new Tiff(source).init();
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
* Initialize the
|
|
81
|
+
* Initialize the tiff loading in the header and all image headers
|
|
82
82
|
*/
|
|
83
83
|
init() {
|
|
84
84
|
if (this._initPromise)
|
|
@@ -146,7 +146,7 @@ export class CogTiff {
|
|
|
146
146
|
const ghostSize = nextOffsetIfd - offset;
|
|
147
147
|
// GDAL now stores metadata between the IFD inside a ghost storage area
|
|
148
148
|
if (ghostSize > 0 && ghostSize < 16 * 1024) {
|
|
149
|
-
this.options = new
|
|
149
|
+
this.options = new TiffGhostOptions();
|
|
150
150
|
this.options.process(bytes, offset, ghostSize);
|
|
151
151
|
}
|
|
152
152
|
while (nextOffsetIfd !== 0) {
|
|
@@ -185,10 +185,17 @@ export class CogTiff {
|
|
|
185
185
|
const tag = createTag(this, view, startOffset + i * ifdSize);
|
|
186
186
|
tags.set(tag.id, tag);
|
|
187
187
|
}
|
|
188
|
-
this.images.push(new
|
|
188
|
+
this.images.push(new TiffImage(this, this.images.length, tags));
|
|
189
189
|
return getUint(view, startOffset + tagCount * ifdSize, this.ifdConfig.pointer, this.isLittleEndian);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
+
/** Read 16KB blocks at a time */
|
|
193
|
+
Object.defineProperty(Tiff, "DefaultReadSize", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
configurable: true,
|
|
196
|
+
writable: true,
|
|
197
|
+
value: 16 * 1024
|
|
198
|
+
});
|
|
192
199
|
function getMaxLength(source, offset, length) {
|
|
193
200
|
// max length is unknown, roll the dice and hope the chunk exists
|
|
194
201
|
if (source.metadata?.size == null)
|
|
@@ -199,4 +206,4 @@ function getMaxLength(source, offset, length) {
|
|
|
199
206
|
return size - offset;
|
|
200
207
|
return length;
|
|
201
208
|
}
|
|
202
|
-
//# sourceMappingURL=
|
|
209
|
+
//# sourceMappingURL=tiff.js.map
|
|
@@ -0,0 +1 @@
|
|
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AE,WAAW,GAAG,QAAQ,GAAG,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IACtG,CAAC;;AAvJD,iCAAiC;AAC1B;;;;WAAkB,EAAE,GAAG,IAAI;EAAZ,CAAa;AAyJrC,SAAS,YAAY,CAAC,MAAc,EAAE,MAAc,EAAE,MAAc;IAClE,iEAAiE;IACjE,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,IAAI,IAAI;QAAE,OAAO,MAAM,CAAC;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAElC,oFAAoF;IACpF,IAAI,MAAM,GAAG,MAAM,GAAG,IAAI;QAAE,OAAO,IAAI,GAAG,MAAM,CAAC;IACjD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/build/util/bytes.d.ts
CHANGED
package/build/util/bytes.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export var ByteSizeFloat;
|
|
2
|
+
(function (ByteSizeFloat) {
|
|
3
|
+
ByteSizeFloat[ByteSizeFloat["Double"] = 8] = "Double";
|
|
4
|
+
ByteSizeFloat[ByteSizeFloat["Float32"] = 4] = "Float32";
|
|
5
|
+
})(ByteSizeFloat || (ByteSizeFloat = {}));
|
|
1
6
|
export var ByteSize;
|
|
2
7
|
(function (ByteSize) {
|
|
3
|
-
ByteSize[ByteSize["Double"] = 8] = "Double";
|
|
4
|
-
ByteSize[ByteSize["Float32"] = 4] = "Float32";
|
|
5
8
|
ByteSize[ByteSize["UInt64"] = 8] = "UInt64";
|
|
6
9
|
ByteSize[ByteSize["UInt32"] = 4] = "UInt32";
|
|
7
10
|
ByteSize[ByteSize["UInt16"] = 2] = "UInt16";
|
package/build/util/bytes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/util/bytes.ts"],"names":[],"mappings":"AAAA,MAAM,CAA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K,QAAQ,CAAC,MAAM;YAClB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAChD,KAAK,QAAQ,CAAC,MAAM;YAClB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAChD,KAAK,QAAQ,CAAC,MAAM;YAClB,OAAO,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogeotiff/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/blacha/cogeotiff.git",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "7e83b76e5089791667a81df7c77e6d361ad1ccb8"
|
|
27
27
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { readFile } from 'fs/promises';
|
|
2
|
-
|
|
3
|
-
import { SourceMemory } from './source.memory.js';
|
|
2
|
+
|
|
4
3
|
import { TiffTag } from '../index.js';
|
|
4
|
+
import { Tiff } from '../tiff.js';
|
|
5
|
+
import { SourceMemory } from './source.memory.js';
|
|
5
6
|
|
|
6
7
|
// console.log = console.trace;
|
|
7
8
|
/** Read a tile from every image inside of a tiff 300 tiles read */
|
|
@@ -9,10 +10,10 @@ async function main(): Promise<void> {
|
|
|
9
10
|
const buf = await readFile(process.argv[process.argv.length - 1]);
|
|
10
11
|
const source = new SourceMemory(buf);
|
|
11
12
|
for (let i = 0; i < 5_000; i++) {
|
|
12
|
-
performance.mark('
|
|
13
|
-
const tiff = new
|
|
13
|
+
performance.mark('tiff:init');
|
|
14
|
+
const tiff = new Tiff(source);
|
|
14
15
|
await tiff.init();
|
|
15
|
-
performance.mark('
|
|
16
|
+
performance.mark('tiff:init:done');
|
|
16
17
|
|
|
17
18
|
// 6 images
|
|
18
19
|
for (const img of tiff.images) await img.getTile(0, 0);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
1
|
import assert from 'node:assert';
|
|
3
2
|
import { beforeEach, describe, it } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
|
|
4
6
|
import { TestFileSource } from '../__benchmark__/source.file.js';
|
|
5
7
|
import { SourceMemory } from '../__benchmark__/source.memory.js';
|
|
6
|
-
import { ByteSize } from '../util/bytes.js';
|
|
7
|
-
import { CogTiff } from '../cog.tiff.js';
|
|
8
8
|
import { TiffMimeType } from '../const/tiff.mime.js';
|
|
9
|
+
import { Photometric, TiffTag } from '../const/tiff.tag.id.js';
|
|
10
|
+
import { Tiff } from '../tiff.js';
|
|
11
|
+
import { ByteSize } from '../util/bytes.js';
|
|
9
12
|
|
|
10
13
|
// 900913 properties.
|
|
11
14
|
const A = 6378137.0;
|
|
@@ -15,9 +18,9 @@ function getResolution(zoom: number): number {
|
|
|
15
18
|
return InitialResolution / 2 ** zoom;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
describe('
|
|
21
|
+
describe('TiffTiled', () => {
|
|
19
22
|
const cogSourceFile = new TestFileSource(new URL('../../data/rgba8_tiled.tiff', import.meta.url));
|
|
20
|
-
const cog = new
|
|
23
|
+
const cog = new Tiff(cogSourceFile);
|
|
21
24
|
|
|
22
25
|
beforeEach(() => cog.init());
|
|
23
26
|
|
|
@@ -85,7 +88,7 @@ describe('Cog.Big', () => {
|
|
|
85
88
|
it('should support reading from memory', async () => {
|
|
86
89
|
const fullSource = new TestFileSource(new URL('../../data/sparse.tiff', import.meta.url));
|
|
87
90
|
|
|
88
|
-
const cog = new
|
|
91
|
+
const cog = new Tiff(fullSource);
|
|
89
92
|
await cog.init();
|
|
90
93
|
|
|
91
94
|
const [firstImage] = cog.images;
|
|
@@ -99,7 +102,7 @@ describe('Cog.Big', () => {
|
|
|
99
102
|
it('should read using a memory source', async () => {
|
|
100
103
|
const bytes = await fs.readFile(new URL('../../data/sparse.tiff', import.meta.url));
|
|
101
104
|
const source = new SourceMemory(bytes.buffer);
|
|
102
|
-
const cog = new
|
|
105
|
+
const cog = new Tiff(source);
|
|
103
106
|
await cog.init();
|
|
104
107
|
|
|
105
108
|
const [firstImage] = cog.images;
|
|
@@ -113,7 +116,7 @@ describe('Cog.Big', () => {
|
|
|
113
116
|
|
|
114
117
|
describe('Cog.Sparse', () => {
|
|
115
118
|
const cogSourceFile = new TestFileSource(new URL('../../data/sparse.tiff', import.meta.url));
|
|
116
|
-
const cog = new
|
|
119
|
+
const cog = new Tiff(cogSourceFile);
|
|
117
120
|
|
|
118
121
|
it('should read metadata', async () => {
|
|
119
122
|
await cog.init();
|
|
@@ -131,6 +134,11 @@ describe('Cog.Sparse', () => {
|
|
|
131
134
|
const { tileCount } = img;
|
|
132
135
|
assert.deepEqual(tileCount, { x: 2, y: 2 });
|
|
133
136
|
|
|
137
|
+
assert.equal(img.value(TiffTag.SamplesPerPixel), 4); // 4 bands
|
|
138
|
+
assert.deepEqual(img.value(TiffTag.BitsPerSample), [8, 8, 8, 8]);
|
|
139
|
+
assert.equal(img.value(TiffTag.Photometric), Photometric.Rgb);
|
|
140
|
+
assert.equal(img.value(TiffTag.GdalNoData), null);
|
|
141
|
+
|
|
134
142
|
for (let x = 0; x < tileCount.x; x++) {
|
|
135
143
|
for (let y = 0; y < tileCount.y; y++) {
|
|
136
144
|
const hasTile = await img.hasTile(x, y);
|
|
@@ -162,7 +170,7 @@ describe('Cog.Sparse', () => {
|
|
|
162
170
|
|
|
163
171
|
describe('CogStrip', () => {
|
|
164
172
|
const cogSourceFile = new TestFileSource(new URL('../../data/rgba8_strip.tiff', import.meta.url));
|
|
165
|
-
const cog = new
|
|
173
|
+
const cog = new Tiff(cogSourceFile);
|
|
166
174
|
|
|
167
175
|
beforeEach(() => cog.init());
|
|
168
176
|
|