@developmentseed/geotiff 0.3.0-beta.3 → 0.3.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/README.md +64 -0
- package/dist/array.d.ts +12 -27
- package/dist/array.d.ts.map +1 -1
- package/dist/array.js.map +1 -1
- package/dist/codecs/lerc.d.ts +2 -2
- package/dist/codecs/lerc.d.ts.map +1 -1
- package/dist/codecs/lerc.js +23 -2
- package/dist/codecs/lerc.js.map +1 -1
- package/dist/codecs/lzw.d.ts.map +1 -1
- package/dist/codecs/lzw.js +2 -1
- package/dist/codecs/lzw.js.map +1 -1
- package/dist/codecs/predictor.d.ts +1 -2
- package/dist/codecs/predictor.d.ts.map +1 -1
- package/dist/codecs/predictor.js +1 -2
- package/dist/codecs/predictor.js.map +1 -1
- package/dist/codecs/utils.d.ts +2 -0
- package/dist/codecs/utils.d.ts.map +1 -0
- package/dist/codecs/utils.js +11 -0
- package/dist/codecs/utils.js.map +1 -0
- package/dist/codecs/zstd.d.ts +2 -0
- package/dist/codecs/zstd.d.ts.map +1 -0
- package/dist/codecs/zstd.js +7 -0
- package/dist/codecs/zstd.js.map +1 -0
- package/dist/decode.d.ts +32 -6
- package/dist/decode.d.ts.map +1 -1
- package/dist/decode.js +35 -15
- package/dist/decode.js.map +1 -1
- package/dist/fetch.d.ts +6 -2
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +178 -34
- package/dist/fetch.js.map +1 -1
- package/dist/gdal-metadata.d.ts +17 -0
- package/dist/gdal-metadata.d.ts.map +1 -0
- package/dist/gdal-metadata.js +59 -0
- package/dist/gdal-metadata.js.map +1 -0
- package/dist/geotiff.d.ts +91 -11
- package/dist/geotiff.d.ts.map +1 -1
- package/dist/geotiff.js +140 -43
- package/dist/geotiff.js.map +1 -1
- package/dist/ifd.d.ts +8 -8
- package/dist/ifd.d.ts.map +1 -1
- package/dist/ifd.js +21 -13
- package/dist/ifd.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/overview.d.ts +33 -3
- package/dist/overview.d.ts.map +1 -1
- package/dist/overview.js +35 -2
- package/dist/overview.js.map +1 -1
- package/dist/pool/pool.d.ts +71 -0
- package/dist/pool/pool.d.ts.map +1 -0
- package/dist/pool/pool.js +100 -0
- package/dist/pool/pool.js.map +1 -0
- package/dist/pool/worker.d.ts +23 -0
- package/dist/pool/worker.d.ts.map +1 -0
- package/dist/pool/worker.js +37 -0
- package/dist/pool/worker.js.map +1 -0
- package/dist/pool/wrapper.d.ts +37 -0
- package/dist/pool/wrapper.d.ts.map +1 -0
- package/dist/pool/wrapper.js +46 -0
- package/dist/pool/wrapper.js.map +1 -0
- package/dist/tile-matrix-set.d.ts.map +1 -1
- package/dist/tile-matrix-set.js +12 -12
- package/dist/tile-matrix-set.js.map +1 -1
- package/dist/transform.d.ts +7 -0
- package/dist/transform.d.ts.map +1 -1
- package/dist/transform.js +40 -1
- package/dist/transform.js.map +1 -1
- package/package.json +18 -12
- package/dist/api.d.ts +0 -34
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -84
- package/dist/api.js.map +0 -1
- package/dist/decode/api.d.ts +0 -28
- package/dist/decode/api.d.ts.map +0 -1
- package/dist/decode/api.js +0 -80
- package/dist/decode/api.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -4,8 +4,44 @@ Fast, high-level GeoTIFF reader written in TypeScript for the browser, wrapping
|
|
|
4
4
|
|
|
5
5
|
[cogeotiff-lib]: https://github.com/blacha/cogeotiff
|
|
6
6
|
|
|
7
|
+
- Easy access to COG tiles and reduced-resolution overviews.
|
|
8
|
+
- Automatic nodata mask handling.
|
|
9
|
+
- Image decoding off the main thread.
|
|
10
|
+
- Supported compressions:
|
|
11
|
+
- Deflate, LERC, LERC+Deflate, LERC+ZSTD, LZW, JPEG (browser-only), WebP (browser-only), ZSTD
|
|
12
|
+
- Support for user-defined decompression algorithms.
|
|
13
|
+
|
|
7
14
|
## Features
|
|
8
15
|
|
|
16
|
+
### Full TypeScript
|
|
17
|
+
|
|
18
|
+
The entire project — both public APIs and internal code — is strongly and exhaustively typed in TypeScript.
|
|
19
|
+
|
|
20
|
+
Image data fetches return a strongly typed object. With type narrowing we can infer whether data is pixel-interleaved, in a band-interleaved,
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { GeoTIFF } from "@developmentseed/geotiff";
|
|
24
|
+
|
|
25
|
+
const geotiff = await GeoTIFF.fromUrl(url);
|
|
26
|
+
const tile = await geotiff.fetchTile(10, 10);
|
|
27
|
+
const { array } = tile;
|
|
28
|
+
if ( array.layout === "pixel-interleaved" ) {
|
|
29
|
+
// array is narrowed to type RasterArrayPixelInterleaved
|
|
30
|
+
|
|
31
|
+
// TypedArray interleaved pixel data in a single array
|
|
32
|
+
const data = array.data; // RasterTypedArray
|
|
33
|
+
} else if ( array.layout === "band-separate" ) {
|
|
34
|
+
// array is narrowed to type RasterArrayBandSeparate
|
|
35
|
+
|
|
36
|
+
// TypedArray data per raster band
|
|
37
|
+
const bands = array.bands; // RasterTypedArray[]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### No unnecessary data copies
|
|
42
|
+
|
|
43
|
+
Image fetching APIs always return data in their original layout, ensuring data copies only happen with the user's explicit consent.
|
|
44
|
+
|
|
9
45
|
### Easy access to COG tiles
|
|
10
46
|
|
|
11
47
|
Use `GeoTIFF.fetchTile` to load `Tile` instances.
|
|
@@ -51,6 +87,15 @@ const overview = geotiff.overviews[0];
|
|
|
51
87
|
const tile = await overview.fetchTile(0, 0);
|
|
52
88
|
```
|
|
53
89
|
|
|
90
|
+
### Affine transformation handling
|
|
91
|
+
|
|
92
|
+
Integrates with [`@developmentseed/affine`] for easy handling of image transforms, associating pixel positions to spatial coordinates.
|
|
93
|
+
|
|
94
|
+
All loaded {@link RasterArray} instances contain an [`Affine`], tracking the relative image transform of that specific image window.
|
|
95
|
+
|
|
96
|
+
[`Affine`]: https://developmentseed.org/deck.gl-raster/api/affine/type-aliases/Affine/
|
|
97
|
+
[`@developmentseed/affine`]: https://developmentseed.org/deck.gl-raster/api/affine/
|
|
98
|
+
|
|
54
99
|
### Automatic Nodata Mask handling
|
|
55
100
|
|
|
56
101
|
With a library like `geotiff.js` or the underlying `@cogeotiff/core`, you have to do extra work to keep track of which of the internal images represent _data_ versus _masks_. We automatically handle nodata values and mask arrays.
|
|
@@ -67,6 +112,12 @@ For user-defined CRSes, we automatically parse the CRS into a PROJJSON object, w
|
|
|
67
112
|
|
|
68
113
|
If you have an image where the CRS fails to parse, please create an issue.
|
|
69
114
|
|
|
115
|
+
### Configurable Web Worker pool for image decoding
|
|
116
|
+
|
|
117
|
+
The `DecoderPool` allows for decoding image data off the main thread.
|
|
118
|
+
|
|
119
|
+
By default workers are created up to `navigator.hardwareConcurrency`, but you can customize how large the web worker pool is by passing options to the `DecoderPool` constructor.
|
|
120
|
+
|
|
70
121
|
### Dynamically load compressions as needed
|
|
71
122
|
|
|
72
123
|
Instead of bundling support for all compressions out of the box, dynamically load the decompressors as required.
|
|
@@ -75,6 +126,19 @@ Until you try to load an image compressed with, say, [LERC], you don't pay for t
|
|
|
75
126
|
|
|
76
127
|
[LERC]: https://github.com/Esri/lerc
|
|
77
128
|
|
|
129
|
+
You can also override the built-in decoders with your own by using `registry`. For example, to use a custom zstd decoder:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { Compression } from "@cogeotiff/core";
|
|
133
|
+
import { registry } from "@developmentseed/geotiff";
|
|
134
|
+
|
|
135
|
+
registry.set(Compression.Zstd, () =>
|
|
136
|
+
import("your-zstd-module").then((m) => m.decode),
|
|
137
|
+
);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
A decoder is a function that takes an `ArrayBuffer` and a `DecoderMetadata` object and returns a `Promise<ArrayBuffer>`. See [decode.ts](./src/decode.ts) for the full type definitions.
|
|
141
|
+
|
|
78
142
|
### Full user control over caching and chunking
|
|
79
143
|
|
|
80
144
|
There are a lot of great utilities in [`chunkd`](https://github.com/blacha/chunkd) that work out of the box here.
|
package/dist/array.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Affine } from "@developmentseed/affine";
|
|
2
2
|
import type { ProjJson } from "./crs.js";
|
|
3
|
+
import type { DecodedBandSeparate, DecodedPixelInterleaved, DecodedPixels } from "./decode.js";
|
|
3
4
|
/** Typed arrays supported for raster sample storage. */
|
|
4
5
|
export type RasterTypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
5
6
|
/** Common metadata shared by all raster layouts. */
|
|
6
|
-
type RasterArrayBase = {
|
|
7
|
+
export type RasterArrayBase = {
|
|
7
8
|
/** Number of bands (samples per pixel). */
|
|
8
9
|
count: number;
|
|
9
10
|
/** Height in pixels. */
|
|
@@ -12,7 +13,7 @@ type RasterArrayBase = {
|
|
|
12
13
|
width: number;
|
|
13
14
|
/**
|
|
14
15
|
* Optional validity mask. Length = height * width.
|
|
15
|
-
*
|
|
16
|
+
* Non-zero = valid pixel, 0 = nodata (transparent). null when no mask IFD is present.
|
|
16
17
|
*/
|
|
17
18
|
mask: Uint8Array | null;
|
|
18
19
|
/**
|
|
@@ -22,32 +23,17 @@ type RasterArrayBase = {
|
|
|
22
23
|
* y = d * col + e * row + f
|
|
23
24
|
*/
|
|
24
25
|
transform: Affine;
|
|
26
|
+
/** Coordinate reference system information. */
|
|
25
27
|
crs: number | ProjJson;
|
|
28
|
+
/** Nodata value from `GDAL_NODATA` TIFF tag. */
|
|
26
29
|
nodata: number | null;
|
|
27
30
|
};
|
|
28
31
|
/** Raster stored in one typed array per band (band-major / planar). */
|
|
29
|
-
export type
|
|
30
|
-
layout: "band-separate";
|
|
31
|
-
/**
|
|
32
|
-
* One typed array per band, each length = width * height.
|
|
33
|
-
*
|
|
34
|
-
* This is the preferred representation when uploading one texture per band.
|
|
35
|
-
*/
|
|
36
|
-
bands: RasterTypedArray[];
|
|
37
|
-
};
|
|
32
|
+
export type RasterArrayBandSeparate = RasterArrayBase & DecodedBandSeparate;
|
|
38
33
|
/** Raster stored in one pixel-interleaved typed array. */
|
|
39
|
-
export type
|
|
40
|
-
layout: "pixel-interleaved";
|
|
41
|
-
/**
|
|
42
|
-
* Pixel-interleaved raster data:
|
|
43
|
-
* [p00_band0, p00_band1, ..., p01_band0, ...]
|
|
44
|
-
*
|
|
45
|
-
* Length = width * height * count.
|
|
46
|
-
*/
|
|
47
|
-
data: RasterTypedArray;
|
|
48
|
-
};
|
|
34
|
+
export type RasterArrayPixelInterleaved = RasterArrayBase & DecodedPixelInterleaved;
|
|
49
35
|
/** Decoded raster data from a GeoTIFF region. */
|
|
50
|
-
export type RasterArray =
|
|
36
|
+
export type RasterArray = RasterArrayBase & DecodedPixels;
|
|
51
37
|
/** Options for packing band data to a 4-channel pixel-interleaved array. */
|
|
52
38
|
export type PackBandsToRGBAOptions = {
|
|
53
39
|
/**
|
|
@@ -59,17 +45,16 @@ export type PackBandsToRGBAOptions = {
|
|
|
59
45
|
fillValue?: number;
|
|
60
46
|
};
|
|
61
47
|
/** Convert any raster layout to a band-separate representation. */
|
|
62
|
-
export declare function toBandSeparate(array: RasterArray):
|
|
48
|
+
export declare function toBandSeparate(array: RasterArray): RasterArrayBandSeparate;
|
|
63
49
|
/** Convert any raster layout to a pixel-interleaved representation. */
|
|
64
|
-
export declare function toPixelInterleaved(array: RasterArray, order?: readonly number[]):
|
|
50
|
+
export declare function toPixelInterleaved(array: RasterArray, order?: readonly number[]): RasterArrayPixelInterleaved;
|
|
65
51
|
/** Reorder bands while keeping a band-separate representation. */
|
|
66
|
-
export declare function reorderBands(array: RasterArray, order: readonly number[]):
|
|
52
|
+
export declare function reorderBands(array: RasterArray, order: readonly number[]): RasterArrayBandSeparate;
|
|
67
53
|
/**
|
|
68
54
|
* Pack selected source bands into an RGBA pixel-interleaved typed array.
|
|
69
55
|
*
|
|
70
56
|
* This is useful as a fallback path when a single 4-channel texture upload
|
|
71
57
|
* is preferred over one texture per band.
|
|
72
58
|
*/
|
|
73
|
-
export declare function packBandsToRGBA(array: RasterArray, options?: PackBandsToRGBAOptions):
|
|
74
|
-
export {};
|
|
59
|
+
export declare function packBandsToRGBA(array: RasterArray, options?: PackBandsToRGBAOptions): RasterArrayPixelInterleaved;
|
|
75
60
|
//# sourceMappingURL=array.d.ts.map
|
package/dist/array.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACvB,aAAa,EACd,MAAM,aAAa,CAAC;AAErB,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAEjB,oDAAoD;AACpD,MAAM,MAAM,eAAe,GAAG;IAC5B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IAEd,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IAEf,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IAExB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB,+CAA+C;IAC/C,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC;IAEvB,gDAAgD;IAChD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,mBAAmB,CAAC;AAE5E,0DAA0D;AAC1D,MAAM,MAAM,2BAA2B,GAAG,eAAe,GACvD,uBAAuB,CAAC;AAE1B,iDAAiD;AACjD,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,aAAa,CAAC;AAE1D,4EAA4E;AAC5E,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACrE,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,uBAAuB,CA4B1E;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,EAClB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GACxB,2BAA2B,CAqC7B;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,uBAAuB,CASzB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,sBAA2B,GACnC,2BAA2B,CA2B7B"}
|
package/dist/array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../src/array.ts"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AAE,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IACnC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/codecs/lerc.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { DecodedPixels } from "../decode.js";
|
|
2
|
-
export declare function decode(bytes: ArrayBuffer): Promise<DecodedPixels>;
|
|
1
|
+
import type { DecodedPixels, DecoderMetadata } from "../decode.js";
|
|
2
|
+
export declare function decode(bytes: ArrayBuffer, metadata: DecoderMetadata): Promise<DecodedPixels>;
|
|
3
3
|
//# sourceMappingURL=lerc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lerc.d.ts","sourceRoot":"","sources":["../../src/codecs/lerc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lerc.d.ts","sourceRoot":"","sources":["../../src/codecs/lerc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAwBnE,wBAAsB,MAAM,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,aAAa,CAAC,CAsBxB"}
|
package/dist/codecs/lerc.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { Compression } from "@cogeotiff/core";
|
|
2
|
+
import { DECODER_REGISTRY } from "../decode.js";
|
|
3
|
+
/** Inner compression type encoded in LercParameters[1]. */
|
|
4
|
+
var LercCompression;
|
|
5
|
+
(function (LercCompression) {
|
|
6
|
+
LercCompression[LercCompression["None"] = 0] = "None";
|
|
7
|
+
LercCompression[LercCompression["Deflate"] = 1] = "Deflate";
|
|
8
|
+
LercCompression[LercCompression["Zstd"] = 2] = "Zstd";
|
|
9
|
+
})(LercCompression || (LercCompression = {}));
|
|
1
10
|
let wasmInitialized = false;
|
|
2
11
|
async function getLerc() {
|
|
3
12
|
// This import is cached by the module loader
|
|
@@ -8,9 +17,21 @@ async function getLerc() {
|
|
|
8
17
|
}
|
|
9
18
|
return lerc;
|
|
10
19
|
}
|
|
11
|
-
export async function decode(bytes) {
|
|
20
|
+
export async function decode(bytes, metadata) {
|
|
21
|
+
const lercCompressionType = metadata.lercParameters?.[1] ??
|
|
22
|
+
LercCompression.None;
|
|
23
|
+
let lercInput = bytes;
|
|
24
|
+
if (lercCompressionType === LercCompression.Deflate ||
|
|
25
|
+
lercCompressionType === LercCompression.Zstd) {
|
|
26
|
+
const innerCompression = lercCompressionType === LercCompression.Deflate
|
|
27
|
+
? Compression.Deflate
|
|
28
|
+
: Compression.Zstd;
|
|
29
|
+
const decoderEntry = DECODER_REGISTRY.get(innerCompression);
|
|
30
|
+
const decoder = await decoderEntry();
|
|
31
|
+
lercInput = (await decoder(bytes, metadata));
|
|
32
|
+
}
|
|
12
33
|
const lerc = await getLerc();
|
|
13
|
-
const result = lerc.decode(
|
|
34
|
+
const result = lerc.decode(lercInput);
|
|
14
35
|
return { layout: "band-separate", bands: result.pixels };
|
|
15
36
|
}
|
|
16
37
|
//# sourceMappingURL=lerc.js.map
|
package/dist/codecs/lerc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lerc.js","sourceRoot":"","sources":["../../src/codecs/lerc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lerc.js","sourceRoot":"","sources":["../../src/codecs/lerc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,2DAA2D;AAC3D,IAAK,eAIJ;AAJD,WAAK,eAAe;IAClB,qDAAQ,CAAA;IACR,2DAAW,CAAA;IACX,qDAAQ,CAAA;AACV,CAAC,EAJI,eAAe,KAAf,eAAe,QAInB;AAED,IAAI,eAAe,GAAG,KAAK,CAAC;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s/lzw.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"lzw.d.ts","sourceRoot":"","sources":["../../src/codecs/lzw.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,wBAAsB,MAAM,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,WAAW,CAAC,CAMtB"}
|
package/dist/codecs/lzw.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { decompress } from "@developmentseed/lzw-tiff-decoder";
|
|
2
|
+
import { copyIfViewNotFullBuffer } from "./utils.js";
|
|
2
3
|
export async function decode(bytes, metadata) {
|
|
3
4
|
const { width, height, samplesPerPixel, bitsPerSample } = metadata;
|
|
4
5
|
const maxUncompressedSize = width * height * samplesPerPixel * (bitsPerSample / 8);
|
|
5
6
|
const result = decompress(new Uint8Array(bytes), maxUncompressedSize);
|
|
6
|
-
return
|
|
7
|
+
return copyIfViewNotFullBuffer(result);
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=lzw.js.map
|
package/dist/codecs/lzw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lzw.js","sourceRoot":"","sources":["../../src/codecs/lzw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"lzw.js","sourceRoot":"","sources":["../../src/codecs/lzw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,KAAkB,EAClB,QAAyB;IAEzB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC;IACnE,MAAM,mBAAmB,GACvB,KAAK,GAAG,MAAM,GAAG,eAAe,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACtE,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predictor.d.ts","sourceRoot":"","sources":["../../src/codecs/predictor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"predictor.d.ts","sourceRoot":"","sources":["../../src/codecs/predictor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAoDjE;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,mBAAmB,EAAE,mBAAmB,GACvC,WAAW,CA6Cb"}
|
package/dist/codecs/predictor.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { PlanarConfiguration } from "@cogeotiff/core";
|
|
2
|
-
import { Predictor } from "../ifd.js";
|
|
1
|
+
import { PlanarConfiguration, Predictor } from "@cogeotiff/core";
|
|
3
2
|
/**
|
|
4
3
|
* Undo TIFF horizontal differencing (predictor 2) or floating-point
|
|
5
4
|
* prediction (predictor 3) in-place on a decoded tile buffer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predictor.js","sourceRoot":"","sources":["../../src/codecs/predictor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,
|
|
1
|
+
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G,IAAI,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;oBAChD,MAAM;gBACR,KAAK,EAAE;oBACL,GAAG,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;oBACjD,MAAM;gBACR,KAAK,EAAE;oBACL,GAAG,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;oBACjD,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CACb,iCAAiC,aAAa,mBAAmB,CAClE,CAAC;YACN,CAAC;YACD,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC5B,CAAC;aAAM,IAAI,SAAS,KAAK,SAAS,CAAC,aAAa,EAAE,CAAC;YACjD,MAAM,GAAG,GAAG,IAAI,UAAU,CACxB,KAAK,EACL,UAAU,EACV,MAAM,GAAG,KAAK,GAAG,cAAc,CAChC,CAAC;YACF,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/codecs/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,CAUrE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function copyIfViewNotFullBuffer(view) {
|
|
2
|
+
// If the view is already aligned, we can return its underlying buffer directly
|
|
3
|
+
if (view.byteOffset === 0 && view.byteLength === view.buffer.byteLength) {
|
|
4
|
+
return view.buffer;
|
|
5
|
+
}
|
|
6
|
+
// Otherwise, we need to copy the relevant portion of the buffer into a new ArrayBuffer
|
|
7
|
+
const copy = new Uint8Array(view.byteLength);
|
|
8
|
+
copy.set(view);
|
|
9
|
+
return copy.buffer;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/codecs/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,uBAAuB,CAAC,IAAgB;IACtD,+EAA+E;IAC/E,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACxE,OAAO,IAAI,CAAC,MAAqB,CAAC;IACpC,CAAC;IAED,uFAAuF;IACvF,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACf,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zstd.d.ts","sourceRoot":"","sources":["../../src/codecs/zstd.ts"],"names":[],"mappings":"AAGA,wBAAsB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAGrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zstd.js","sourceRoot":"","sources":["../../src/codecs/zstd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAkB;IAC7C,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/decode.d.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import type { PlanarConfiguration } from "@cogeotiff/core";
|
|
1
|
+
import type { PlanarConfiguration, Predictor } from "@cogeotiff/core";
|
|
2
2
|
import { Compression, SampleFormat } from "@cogeotiff/core";
|
|
3
3
|
import type { RasterTypedArray } from "./array.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type DecodedPixels = {
|
|
4
|
+
/** Raster stored in one pixel-interleaved typed array. */
|
|
5
|
+
export type DecodedPixelInterleaved = {
|
|
7
6
|
layout: "pixel-interleaved";
|
|
7
|
+
/**
|
|
8
|
+
* Pixel-interleaved raster data:
|
|
9
|
+
* [p00_band0, p00_band1, ..., p01_band0, ...]
|
|
10
|
+
*
|
|
11
|
+
* Length = width * height * count.
|
|
12
|
+
*/
|
|
8
13
|
data: RasterTypedArray;
|
|
9
|
-
}
|
|
14
|
+
};
|
|
15
|
+
/** Raster stored in one typed array per band (band-major / planar). */
|
|
16
|
+
export type DecodedBandSeparate = {
|
|
10
17
|
layout: "band-separate";
|
|
18
|
+
/**
|
|
19
|
+
* One typed array per band, each length = width * height.
|
|
20
|
+
*
|
|
21
|
+
* This is the preferred representation when uploading one texture per band.
|
|
22
|
+
*/
|
|
11
23
|
bands: RasterTypedArray[];
|
|
12
24
|
};
|
|
25
|
+
/** The result of a decoding process */
|
|
26
|
+
export type DecodedPixels = DecodedPixelInterleaved | DecodedBandSeparate;
|
|
13
27
|
/** Metadata from the TIFF IFD, passed to decoders that need it. */
|
|
14
28
|
export type DecoderMetadata = {
|
|
15
29
|
sampleFormat: SampleFormat;
|
|
@@ -19,6 +33,7 @@ export type DecoderMetadata = {
|
|
|
19
33
|
height: number;
|
|
20
34
|
predictor: Predictor;
|
|
21
35
|
planarConfiguration: PlanarConfiguration;
|
|
36
|
+
lercParameters?: number[] | null;
|
|
22
37
|
};
|
|
23
38
|
/**
|
|
24
39
|
* A decoder returns either:
|
|
@@ -26,9 +41,20 @@ export type DecoderMetadata = {
|
|
|
26
41
|
* - A DecodedPixels with typed pixel data (image codecs like LERC, JPEG)
|
|
27
42
|
*/
|
|
28
43
|
export type Decoder = (bytes: ArrayBuffer, metadata: DecoderMetadata) => Promise<ArrayBuffer | DecodedPixels>;
|
|
29
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The global registry of decoders for each compression type.
|
|
46
|
+
*
|
|
47
|
+
* This maps a {@link Compression} value to a function that returns a promise of
|
|
48
|
+
* a {@link Decoder}.
|
|
49
|
+
*/
|
|
50
|
+
export declare const DECODER_REGISTRY: Map<Compression, () => Promise<Decoder>>;
|
|
30
51
|
/**
|
|
31
52
|
* Decode a tile's bytes according to its compression and image metadata.
|
|
32
53
|
*/
|
|
33
54
|
export declare function decode(bytes: ArrayBuffer, compression: Compression, metadata: DecoderMetadata): Promise<DecodedPixels>;
|
|
55
|
+
/**
|
|
56
|
+
* Unpack a 1-bit packed mask buffer (MSB-first) into a Uint8Array of 0/255.
|
|
57
|
+
* Each input byte holds 8 pixels; bit 7 is the first pixel in that byte.
|
|
58
|
+
*/
|
|
59
|
+
export declare function unpackBitPacked(buffer: ArrayBuffer, pixelCount: number): Uint8Array;
|
|
34
60
|
//# sourceMappingURL=decode.d.ts.map
|
package/dist/decode.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAInD,0DAA0D;AAC1D,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,mBAAmB,CAAC;IAC5B;;;;;OAKG;IACH,IAAI,EAAE,gBAAgB,CAAC;CACxB,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB;;;;OAIG;IACH,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,aAAa,GAAG,uBAAuB,GAAG,mBAAmB,CAAC;AAE1E,mEAAmE;AACnE,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,eAAe,KACtB,OAAO,CAAC,WAAW,GAAG,aAAa,CAAC,CAAC;AAM1C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,yBAA8B,OAAO,CAAC,OAAO,CAAC,CAAG,CAAC;AA8B/E;;GAEG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,aAAa,CAAC,CAkCxB;AAED;;;GAGG;AAGH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,MAAM,GACjB,UAAU,CAOZ"}
|
package/dist/decode.js
CHANGED
|
@@ -4,29 +4,33 @@ import { applyPredictor } from "./codecs/predictor.js";
|
|
|
4
4
|
async function decodeUncompressed(bytes) {
|
|
5
5
|
return bytes;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
registry
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The global registry of decoders for each compression type.
|
|
9
|
+
*
|
|
10
|
+
* This maps a {@link Compression} value to a function that returns a promise of
|
|
11
|
+
* a {@link Decoder}.
|
|
12
|
+
*/
|
|
13
|
+
export const DECODER_REGISTRY = new Map();
|
|
14
|
+
DECODER_REGISTRY.set(Compression.None, () => Promise.resolve(decodeUncompressed));
|
|
15
|
+
DECODER_REGISTRY.set(Compression.Deflate, () => import("./codecs/deflate.js").then((m) => m.decode));
|
|
16
|
+
DECODER_REGISTRY.set(Compression.DeflateOther, () => import("./codecs/deflate.js").then((m) => m.decode));
|
|
17
|
+
DECODER_REGISTRY.set(Compression.Lzw, () => import("./codecs/lzw.js").then((m) => m.decode));
|
|
18
|
+
DECODER_REGISTRY.set(Compression.Zstd, () => import("./codecs/zstd.js").then((m) => m.decode));
|
|
19
|
+
// DECODER_REGISTRY.set(Compression.Lzma, () =>
|
|
16
20
|
// import("../codecs/lzma.js").then((m) => m.decode),
|
|
17
21
|
// );
|
|
18
|
-
//
|
|
22
|
+
// DECODER_REGISTRY.set(Compression.Jp2000, () =>
|
|
19
23
|
// import("../codecs/jp2000.js").then((m) => m.decode),
|
|
20
24
|
// );
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
DECODER_REGISTRY.set(Compression.Jpeg, () => Promise.resolve(decodeViaCanvas));
|
|
26
|
+
DECODER_REGISTRY.set(Compression.Jpeg6, () => Promise.resolve(decodeViaCanvas));
|
|
27
|
+
DECODER_REGISTRY.set(Compression.Webp, () => Promise.resolve(decodeViaCanvas));
|
|
28
|
+
DECODER_REGISTRY.set(Compression.Lerc, () => import("./codecs/lerc.js").then((m) => m.decode));
|
|
25
29
|
/**
|
|
26
30
|
* Decode a tile's bytes according to its compression and image metadata.
|
|
27
31
|
*/
|
|
28
32
|
export async function decode(bytes, compression, metadata) {
|
|
29
|
-
const loader =
|
|
33
|
+
const loader = DECODER_REGISTRY.get(compression);
|
|
30
34
|
if (!loader) {
|
|
31
35
|
throw new Error(`Unsupported compression: ${compression}`);
|
|
32
36
|
}
|
|
@@ -42,6 +46,20 @@ export async function decode(bytes, compression, metadata) {
|
|
|
42
46
|
}
|
|
43
47
|
return result;
|
|
44
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Unpack a 1-bit packed mask buffer (MSB-first) into a Uint8Array of 0/255.
|
|
51
|
+
* Each input byte holds 8 pixels; bit 7 is the first pixel in that byte.
|
|
52
|
+
*/
|
|
53
|
+
// TODO: check for FillOrder tag and reverse bit order if needed
|
|
54
|
+
// https://web.archive.org/web/20240329145342/https://www.awaresystems.be/imaging/tiff/tifftags/fillorder.html
|
|
55
|
+
export function unpackBitPacked(buffer, pixelCount) {
|
|
56
|
+
const packed = new Uint8Array(buffer);
|
|
57
|
+
const out = new Uint8Array(pixelCount);
|
|
58
|
+
for (let i = 0; i < pixelCount; i++) {
|
|
59
|
+
out[i] = (packed[i >> 3] >> (7 - (i & 7))) & 1 ? 255 : 0;
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
45
63
|
/**
|
|
46
64
|
* Convert a raw ArrayBuffer of pixel data into a typed array based on the
|
|
47
65
|
* sample format and bits per sample. This is used for codecs that return raw
|
|
@@ -52,6 +70,8 @@ function toTypedArray(buffer, metadata) {
|
|
|
52
70
|
switch (sampleFormat) {
|
|
53
71
|
case SampleFormat.Uint:
|
|
54
72
|
switch (bitsPerSample) {
|
|
73
|
+
case 1:
|
|
74
|
+
return unpackBitPacked(buffer, metadata.width * metadata.height * metadata.samplesPerPixel);
|
|
55
75
|
case 8:
|
|
56
76
|
return new Uint8Array(buffer);
|
|
57
77
|
case 16:
|
package/dist/decode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AACA,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AAO,eAAe,CACpB,MAAM,EACN,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,eAAe,CAC5D,CAAC;gBACJ,KAAK,CAAC;oBACJ,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;gBAChC,KAAK,EAAE;oBACL,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;gBACjC,KAAK,EAAE;oBACL,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YACD,MAAM;QACR,KAAK,YAAY,CAAC,GAAG;YACnB,QAAQ,aAAa,EAAE,CAAC;gBACtB,KAAK,CAAC;oBACJ,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;gBAC/B,KAAK,EAAE;oBACL,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;gBAChC,KAAK,EAAE;oBACL,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;YACD,MAAM;QACR,KAAK,YAAY,CAAC,KAAK;YACrB,QAAQ,aAAa,EAAE,CAAC;gBACtB,KAAK,EAAE;oBACL,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;gBAClC,KAAK,EAAE;oBACL,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;YACpC,CAAC;YACD,MAAM;IACV,CAAC;IACD,MAAM,IAAI,KAAK,CACb,iDAAiD,YAAY,mBAAmB,aAAa,EAAE,CAChG,CAAC;AACJ,CAAC"}
|
package/dist/fetch.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type { TiffImage } from "@cogeotiff/core";
|
|
1
|
+
import type { Source, TiffImage } from "@cogeotiff/core";
|
|
2
2
|
import type { ProjJson } from "./crs.js";
|
|
3
3
|
import type { CachedTags } from "./ifd.js";
|
|
4
|
+
import type { DecoderPool } from "./pool/pool.js";
|
|
4
5
|
import type { Tile } from "./tile";
|
|
5
6
|
import type { HasTransform } from "./transform";
|
|
6
7
|
/** Protocol for objects that hold a TIFF reference and can request tiles. */
|
|
7
8
|
interface HasTiffReference extends HasTransform {
|
|
8
9
|
readonly cachedTags: CachedTags;
|
|
10
|
+
/** The data source used for fetching tile data. */
|
|
11
|
+
readonly dataSource: Pick<Source, "fetch">;
|
|
9
12
|
/** The data Image File Directory (IFD) */
|
|
10
13
|
readonly image: TiffImage;
|
|
11
14
|
/** The mask Image File Directory (IFD), if any. */
|
|
@@ -19,8 +22,9 @@ interface HasTiffReference extends HasTransform {
|
|
|
19
22
|
/** The nodata value for the image, if any. */
|
|
20
23
|
readonly nodata: number | null;
|
|
21
24
|
}
|
|
22
|
-
export declare function fetchTile(self: HasTiffReference, x: number, y: number,
|
|
25
|
+
export declare function fetchTile(self: HasTiffReference, x: number, y: number, { boundless, pool, signal, }?: {
|
|
23
26
|
boundless?: boolean;
|
|
27
|
+
pool?: DecoderPool;
|
|
24
28
|
signal?: AbortSignal;
|
|
25
29
|
}): Promise<Tile>;
|
|
26
30
|
export {};
|
package/dist/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MA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