whitebox-wasm 0.1.0 → 0.2.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 +151 -0
- package/package.json +2 -2
- package/whitebox_wasm.d.ts +322 -11
- package/whitebox_wasm.js +1276 -15
- package/whitebox_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# whitebox-wasm
|
|
2
|
+
|
|
3
|
+
**Pure-Rust GeoTIFF decoding compiled to WebAssembly.** No GDAL, no PROJ, no
|
|
4
|
+
native libraries, no server. Decode GeoTIFF / BigTIFF / COG entirely in the
|
|
5
|
+
browser, Node, Deno, or any Wasm host.
|
|
6
|
+
|
|
7
|
+
This wraps `wbgeotiff`, the shared GeoTIFF engine from the original
|
|
8
|
+
[**whitebox_next_gen**](https://github.com/jblindsay/whitebox_next_gen) project
|
|
9
|
+
by John Lindsay (Whitebox Geospatial Inc.) - the next-generation, pure-Rust
|
|
10
|
+
rewrite of WhiteboxTools - and exposes a tiny WebAssembly API. The entire codec
|
|
11
|
+
stack (Deflate, LZW, PackBits, JPEG, WebP, JPEG-XL, PNG predictors, BigTIFF,
|
|
12
|
+
tiling) is pure Rust with zero C dependencies, so the published module imports
|
|
13
|
+
nothing from the host beyond its own linear memory.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install whitebox-wasm
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage (browser / Deno / Node >= 20, ESM)
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import init, { geotiff_info, GeoTiffReader, CogBuilder } from "whitebox-wasm";
|
|
25
|
+
|
|
26
|
+
await init(); // in Node, pass the .wasm bytes to init()
|
|
27
|
+
const bytes = new Uint8Array(await (await fetch("dem.tif")).arrayBuffer());
|
|
28
|
+
|
|
29
|
+
// Metadata only - O(header) memory, works on multi-GB rasters:
|
|
30
|
+
console.log(JSON.parse(geotiff_info(bytes)));
|
|
31
|
+
// { ok:true, width, height, bands, epsg, nodata, bits_per_sample,
|
|
32
|
+
// sample_format, compression, tiled, bigtiff }
|
|
33
|
+
|
|
34
|
+
// Parse once, read many times:
|
|
35
|
+
const tif = new GeoTiffReader(bytes);
|
|
36
|
+
console.log(tif.width, tif.height, tif.bands, tif.epsg, tif.nodata);
|
|
37
|
+
console.log(Array.from(tif.geo_transform())); // [ox, px, 0, oy, 0, -py]
|
|
38
|
+
console.log(Array.from(tif.bounding_box())); // [minx, miny, maxx, maxy]
|
|
39
|
+
const band0 = tif.read_band_f64(0); // Float64Array
|
|
40
|
+
console.log(JSON.parse(tif.stats_json()));
|
|
41
|
+
|
|
42
|
+
// Encode a Cloud Optimized GeoTIFF (also a valid plain GeoTIFF):
|
|
43
|
+
const cb = new CogBuilder(width, height, 1);
|
|
44
|
+
cb.set_epsg(32610);
|
|
45
|
+
cb.set_origin(500000, 4000000, 30); // x_min, y_max, pixel size
|
|
46
|
+
cb.set_compression("deflate");
|
|
47
|
+
cb.set_nodata(-9999);
|
|
48
|
+
const cogBytes = cb.write_f64(new Float64Array(pixels)); // Uint8Array
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In Node the `web` target needs the wasm bytes handed to `init()`:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { readFileSync } from "node:fs";
|
|
55
|
+
import init, { geotiff_info } from "whitebox-wasm";
|
|
56
|
+
await init({ module_or_path: readFileSync("node_modules/whitebox-wasm/whitebox_wasm_bg.wasm") });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## API
|
|
60
|
+
|
|
61
|
+
### Convenience functions
|
|
62
|
+
|
|
63
|
+
| Function | Returns |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `geotiff_info(bytes)` | JSON metadata, header-only (incl. `bbox`, `center`, `center_lonlat`) |
|
|
66
|
+
| `geotiff_stats(bytes)` | JSON band-0 stats `{valid, min, max, mean, ...}` |
|
|
67
|
+
| `geotiff_read_band_f64(bytes, band)` | `Float64Array` of band pixels |
|
|
68
|
+
| `version()` | crate version string |
|
|
69
|
+
|
|
70
|
+
### `GeoTiffReader` (parse once, read many)
|
|
71
|
+
|
|
72
|
+
`new GeoTiffReader(bytes)`, then:
|
|
73
|
+
|
|
74
|
+
- Properties: `width`, `height`, `bands`, `bits_per_sample`, `sample_format`, `compression`, `is_bigtiff`, `epsg`, `nodata`
|
|
75
|
+
- `geo_transform()` -> `[x_origin, pixel_width, row_rot, y_origin, col_rot, pixel_height]` (empty if none)
|
|
76
|
+
- `bounding_box()` -> `[min_x, min_y, max_x, max_y]` in the dataset CRS (empty if not georeferenced)
|
|
77
|
+
- `center()` -> `[x, y]` center in the dataset CRS
|
|
78
|
+
- `center_lonlat()` -> `[lon, lat]` WGS84 degrees; `bounds_lonlat()` -> `[min_lon, min_lat, max_lon, max_lat]` WGS84 (any EPSG via the bundled pure-Rust projection engine; also handles user-defined projections like NLCD's Albers; empty if not georeferenced)
|
|
79
|
+
- `value_transform()` -> `[scale, offset]` (GDAL scale/offset; empty if none)
|
|
80
|
+
- `info_json()`, `stats_json()` -> JSON strings
|
|
81
|
+
- `read_band_f64(band)` / `read_all_f64()` -> `Float64Array` (any on-disk type converted)
|
|
82
|
+
- `read_band_bytes(band)` -> raw `Uint8Array`
|
|
83
|
+
- Native typed reads (require matching on-disk type): `read_band_u8` / `i8` / `u16` / `i16` / `u32` / `i32` / `f32`
|
|
84
|
+
|
|
85
|
+
### `CogBuilder` (write Cloud Optimized GeoTIFFs)
|
|
86
|
+
|
|
87
|
+
`new CogBuilder(width, height, bands)`, configure, then `write_u8` / `write_f32` / `write_f64(data)` -> `Uint8Array`:
|
|
88
|
+
|
|
89
|
+
- `set_epsg(code)`, `set_nodata(v)`, `set_compression("none|lzw|deflate|packbits|webp|jpeg|jpegxl")`
|
|
90
|
+
- `set_geo_transform([6 values])` or `set_origin(x_min, y_max, pixel_size)`
|
|
91
|
+
- `set_tile_size(px)`, `set_bigtiff(bool)`, `set_overview_levels([2,4,8])`
|
|
92
|
+
|
|
93
|
+
Output is a tiled COG with overviews and GDAL ghost metadata - readable by GDAL, rasterio, QGIS, and `GeoTiffReader`.
|
|
94
|
+
|
|
95
|
+
### `CogStream` (read remote COGs via HTTP range requests)
|
|
96
|
+
|
|
97
|
+
Read a window or overview out of a large COG **without downloading the whole
|
|
98
|
+
file**. The wasm parses the header and reports byte ranges; your JS does the
|
|
99
|
+
range requests:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import init, { CogStream } from "whitebox-wasm";
|
|
103
|
+
await init();
|
|
104
|
+
|
|
105
|
+
const url = "https://example.com/big-cog.tif";
|
|
106
|
+
const range = (a, b) => fetch(url, { headers: { Range: `bytes=${a}-${b}` } })
|
|
107
|
+
.then(r => r.arrayBuffer()).then(b => new Uint8Array(b));
|
|
108
|
+
|
|
109
|
+
const stream = new CogStream(await range(0, 65535)); // header prefix
|
|
110
|
+
const lv = JSON.parse(stream.levels_json())[0]; // level 0 = full res
|
|
111
|
+
const tiles = JSON.parse(stream.tiles_for_window(0, 1200, 800, 256, 256));
|
|
112
|
+
|
|
113
|
+
for (const t of tiles) {
|
|
114
|
+
const bytes = await range(t.offset, t.offset + t.length - 1); // one tile
|
|
115
|
+
const px = stream.decode_tile_f64(0, bytes); // Float64Array
|
|
116
|
+
// place px (tile_width x tile_height) into your output window...
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- `new CogStream(headerBytes)` - parse the IFD chain + tile index (throws if the
|
|
121
|
+
prefix is too short; fetch more and retry).
|
|
122
|
+
- `num_levels`, `epsg`, `nodata`, `geo_transform()`, `levels_json()`
|
|
123
|
+
- `bounding_box()`, `center()`, `center_lonlat()`, `bounds_lonlat()` (same semantics as `GeoTiffReader`)
|
|
124
|
+
- `tiles_for_window(level, x, y, w, h)` -> JSON `[{col,row,offset,length}]`
|
|
125
|
+
- `tile_range(level, col, row)` -> `[offset, length]`
|
|
126
|
+
- `decode_tile_f64(level, tileBytes)` -> `Float64Array` (one decoded tile)
|
|
127
|
+
|
|
128
|
+
Use a higher `level` (overview) for zoomed-out views. See
|
|
129
|
+
[`examples/cog-stream.mjs`](../../examples/cog-stream.mjs) for a full window read
|
|
130
|
+
that fetches only the tiles it needs (about 13% of a 5.7 MiB file for a 256x256
|
|
131
|
+
window). Requires a tiled COG on a server that supports HTTP range requests.
|
|
132
|
+
|
|
133
|
+
JSON-returning functions report failures as `{"ok":false,"error":"..."}`; class methods throw on error.
|
|
134
|
+
|
|
135
|
+
## Limits
|
|
136
|
+
|
|
137
|
+
WebAssembly is 32-bit, so linear memory is capped at ~4 GiB. `geotiff_info` is
|
|
138
|
+
header-only and unaffected, but reads/writes that materialize a full raster are
|
|
139
|
+
bounded by that ceiling (a national 1-billion-pixel raster cannot be fully
|
|
140
|
+
decoded in-browser). For such data, read metadata only or process server-side.
|
|
141
|
+
|
|
142
|
+
## Links
|
|
143
|
+
|
|
144
|
+
- Source, live demo, and issues: https://github.com/opengeos/whitebox-wasm
|
|
145
|
+
- Live browser demo: https://opengeos.org/whitebox-wasm/
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
Dual-licensed under MIT or Apache-2.0, at your option. Includes the vendored
|
|
150
|
+
`wbgeotiff` and `wbprojection` crates (Copyright John Lindsay, Whitebox
|
|
151
|
+
Geospatial Inc.), used under the same dual license.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "whitebox-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WebAssembly bindings for the pure-Rust Whitebox GeoTIFF engine",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.2.0",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
"raster",
|
|
27
27
|
"webassembly"
|
|
28
28
|
]
|
|
29
|
-
}
|
|
29
|
+
}
|
package/whitebox_wasm.d.ts
CHANGED
|
@@ -2,20 +2,271 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Builder for encoding a Cloud Optimized GeoTIFF (tiled, with overviews and
|
|
6
|
+
* GDAL ghost metadata) to bytes. A COG is also a valid plain GeoTIFF.
|
|
7
|
+
*
|
|
8
|
+
* Configure with the `set_*` methods, then call one of `write_*` with the
|
|
9
|
+
* pixel data to get a `Uint8Array` of the encoded file.
|
|
7
10
|
*/
|
|
8
|
-
export
|
|
11
|
+
export class CogBuilder {
|
|
12
|
+
free(): void;
|
|
13
|
+
[Symbol.dispose](): void;
|
|
14
|
+
/**
|
|
15
|
+
* New builder for a `width` x `height` raster with `bands` bands.
|
|
16
|
+
*/
|
|
17
|
+
constructor(width: number, height: number, bands: number);
|
|
18
|
+
/**
|
|
19
|
+
* Force BigTIFF (64-bit offsets) for very large outputs.
|
|
20
|
+
*/
|
|
21
|
+
set_bigtiff(on: boolean): void;
|
|
22
|
+
/**
|
|
23
|
+
* Compression: `none`, `lzw`, `deflate`, `packbits`, `webp`, `jpeg`, `jpegxl`.
|
|
24
|
+
*/
|
|
25
|
+
set_compression(name: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Set the EPSG code (1..=65535).
|
|
28
|
+
*/
|
|
29
|
+
set_epsg(epsg: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Set the full affine geo-transform:
|
|
32
|
+
* `[x_origin, pixel_width, row_rotation, y_origin, col_rotation, pixel_height]`.
|
|
33
|
+
*/
|
|
34
|
+
set_geo_transform(gt: Float64Array): void;
|
|
35
|
+
/**
|
|
36
|
+
* Set the no-data sentinel value.
|
|
37
|
+
*/
|
|
38
|
+
set_nodata(v: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Convenience: north-up geo-transform from upper-left origin and pixel size.
|
|
41
|
+
*/
|
|
42
|
+
set_origin(x_min: number, y_max: number, pixel_size: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Explicit overview decimation factors (e.g. `[2,4,8]`); empty disables overviews.
|
|
45
|
+
*/
|
|
46
|
+
set_overview_levels(levels: Uint32Array): void;
|
|
47
|
+
/**
|
|
48
|
+
* Internal tile size in pixels (default 512).
|
|
49
|
+
*/
|
|
50
|
+
set_tile_size(px: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Encode `f32` pixel data to a COG. `Uint8Array`.
|
|
53
|
+
*/
|
|
54
|
+
write_f32(data: Float32Array): Uint8Array;
|
|
55
|
+
/**
|
|
56
|
+
* Encode `f64` pixel data to a COG. `Uint8Array`.
|
|
57
|
+
*/
|
|
58
|
+
write_f64(data: Float64Array): Uint8Array;
|
|
59
|
+
/**
|
|
60
|
+
* Encode `u8` pixel data to a COG. `Uint8Array`.
|
|
61
|
+
*/
|
|
62
|
+
write_u8(data: Uint8Array): Uint8Array;
|
|
63
|
+
}
|
|
9
64
|
|
|
10
65
|
/**
|
|
11
|
-
*
|
|
66
|
+
* Range-request reader for a (tiled) Cloud Optimized GeoTIFF.
|
|
12
67
|
*
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
68
|
+
* The wasm module does no network I/O itself; this class parses the header and
|
|
69
|
+
* tells the JS host exactly which byte ranges to fetch, then decodes the tiles
|
|
70
|
+
* the host fetches. Typical flow:
|
|
71
|
+
*
|
|
72
|
+
* 1. Range-fetch the first chunk of the file (e.g. 0..1 MiB) and
|
|
73
|
+
* `new CogStream(headerBytes)`. If it throws "need more header bytes", fetch
|
|
74
|
+
* a larger prefix and retry.
|
|
75
|
+
* 2. Pick a level (0 = full res, higher = overviews) and a pixel window.
|
|
76
|
+
* 3. `tiles_for_window(level, x, y, w, h)` returns the tiles and their byte
|
|
77
|
+
* ranges; range-fetch each, then `decode_tile_f64(level, bytes)`.
|
|
78
|
+
*/
|
|
79
|
+
export class CogStream {
|
|
80
|
+
free(): void;
|
|
81
|
+
[Symbol.dispose](): void;
|
|
82
|
+
/**
|
|
83
|
+
* Bounding box `[min_x, min_y, max_x, max_y]` in the dataset CRS, or empty.
|
|
84
|
+
*/
|
|
85
|
+
bounding_box(): Float64Array;
|
|
86
|
+
/**
|
|
87
|
+
* Bounds `[min_lon, min_lat, max_lon, max_lat]` in WGS84 degrees, or empty.
|
|
88
|
+
*/
|
|
89
|
+
bounds_lonlat(): Float64Array;
|
|
90
|
+
/**
|
|
91
|
+
* Image center `[x, y]` in the dataset CRS, or empty.
|
|
92
|
+
*/
|
|
93
|
+
center(): Float64Array;
|
|
94
|
+
/**
|
|
95
|
+
* Image center `[lon, lat]` in WGS84 degrees, or empty if not convertible.
|
|
96
|
+
*/
|
|
97
|
+
center_lonlat(): Float64Array;
|
|
98
|
+
/**
|
|
99
|
+
* Decode one tile's fetched (compressed) bytes into an `f64` `Float64Array`,
|
|
100
|
+
* pixel-interleaved, length `tile_width * tile_height * bands`. Edge tiles
|
|
101
|
+
* come back full-size; clip to the image/window on the JS side.
|
|
102
|
+
*/
|
|
103
|
+
decode_tile_f64(level: number, tile_bytes: Uint8Array): Float64Array;
|
|
104
|
+
/**
|
|
105
|
+
* Level-0 geo-transform `[x_origin, pixel_width, row_rot, y_origin, col_rot,
|
|
106
|
+
* pixel_height]`, or empty if not georeferenced.
|
|
107
|
+
*/
|
|
108
|
+
geo_transform(): Float64Array;
|
|
109
|
+
/**
|
|
110
|
+
* JSON array describing every level: `[{level,width,height,tile_width,
|
|
111
|
+
* tile_height,tiles_x,tiles_y,bands,bits_per_sample,sample_format,compression}]`.
|
|
112
|
+
*/
|
|
113
|
+
levels_json(): string;
|
|
114
|
+
/**
|
|
115
|
+
* Parse a COG's tile layout from front-of-file header bytes.
|
|
116
|
+
*/
|
|
117
|
+
constructor(header_bytes: Uint8Array);
|
|
118
|
+
/**
|
|
119
|
+
* `[offset, length]` byte range of the tile at `(col, row)` on `level`.
|
|
120
|
+
*/
|
|
121
|
+
tile_range(level: number, col: number, row: number): Float64Array;
|
|
122
|
+
/**
|
|
123
|
+
* Tiles covering a pixel window on `level`, as a JSON array of
|
|
124
|
+
* `{col,row,offset,length}`. Fetch each byte range, then `decode_tile_f64`.
|
|
125
|
+
*/
|
|
126
|
+
tiles_for_window(level: number, x: number, y: number, w: number, h: number): string;
|
|
127
|
+
/**
|
|
128
|
+
* EPSG code of the full-resolution level, if any.
|
|
129
|
+
*/
|
|
130
|
+
readonly epsg: number | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* No-data sentinel, if declared.
|
|
133
|
+
*/
|
|
134
|
+
readonly nodata: number | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Number of resolution levels (1 + overview count).
|
|
137
|
+
*/
|
|
138
|
+
readonly num_levels: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* A parsed GeoTIFF held in memory. Construct once, then call the accessor and
|
|
143
|
+
* `read_*` methods many times without re-parsing the file.
|
|
144
|
+
*/
|
|
145
|
+
export class GeoTiffReader {
|
|
146
|
+
free(): void;
|
|
147
|
+
[Symbol.dispose](): void;
|
|
148
|
+
/**
|
|
149
|
+
* Bounding box as `[min_x, min_y, max_x, max_y]`, or empty if not georeferenced.
|
|
150
|
+
*/
|
|
151
|
+
bounding_box(): Float64Array;
|
|
152
|
+
/**
|
|
153
|
+
* Bounds `[min_lon, min_lat, max_lon, max_lat]` in WGS84 degrees, or empty
|
|
154
|
+
* if not convertible.
|
|
155
|
+
*/
|
|
156
|
+
bounds_lonlat(): Float64Array;
|
|
157
|
+
/**
|
|
158
|
+
* Image center `[x, y]` in the dataset CRS, or empty if not georeferenced.
|
|
159
|
+
*/
|
|
160
|
+
center(): Float64Array;
|
|
161
|
+
/**
|
|
162
|
+
* Image center `[lon, lat]` in WGS84 degrees, or empty if not georeferenced
|
|
163
|
+
* or the CRS is not convertible.
|
|
164
|
+
*/
|
|
165
|
+
center_lonlat(): Float64Array;
|
|
166
|
+
/**
|
|
167
|
+
* Affine geo-transform as `[x_origin, pixel_width, row_rotation,
|
|
168
|
+
* y_origin, col_rotation, pixel_height]`, or an empty array if absent.
|
|
169
|
+
*/
|
|
170
|
+
geo_transform(): Float64Array;
|
|
171
|
+
/**
|
|
172
|
+
* Full metadata as a JSON string (same shape as [`geotiff_info`]).
|
|
173
|
+
*/
|
|
174
|
+
info_json(): string;
|
|
175
|
+
/**
|
|
176
|
+
* Parse a GeoTIFF / BigTIFF / COG from raw bytes.
|
|
177
|
+
*/
|
|
178
|
+
constructor(data: Uint8Array);
|
|
179
|
+
/**
|
|
180
|
+
* Read every band as `f64`, interleaved per pixel (`band0,band1,...`).
|
|
181
|
+
*/
|
|
182
|
+
read_all_f64(): Float64Array;
|
|
183
|
+
/**
|
|
184
|
+
* Read a band's raw, undecoded-to-native bytes. `Uint8Array`.
|
|
185
|
+
*/
|
|
186
|
+
read_band_bytes(band: number): Uint8Array;
|
|
187
|
+
/**
|
|
188
|
+
* Native `f32` band. `Float32Array`.
|
|
189
|
+
*/
|
|
190
|
+
read_band_f32(band: number): Float32Array;
|
|
191
|
+
/**
|
|
192
|
+
* Read a band as `f64`, converting from any on-disk type. `Float64Array`.
|
|
193
|
+
*/
|
|
194
|
+
read_band_f64(band: number): Float64Array;
|
|
195
|
+
/**
|
|
196
|
+
* Native `i16` band. `Int16Array`.
|
|
197
|
+
*/
|
|
198
|
+
read_band_i16(band: number): Int16Array;
|
|
199
|
+
/**
|
|
200
|
+
* Native `i32` band. `Int32Array`.
|
|
201
|
+
*/
|
|
202
|
+
read_band_i32(band: number): Int32Array;
|
|
203
|
+
/**
|
|
204
|
+
* Native `i8` band. `Int8Array`.
|
|
205
|
+
*/
|
|
206
|
+
read_band_i8(band: number): Int8Array;
|
|
207
|
+
/**
|
|
208
|
+
* Native `u16` band. `Uint16Array`.
|
|
209
|
+
*/
|
|
210
|
+
read_band_u16(band: number): Uint16Array;
|
|
211
|
+
/**
|
|
212
|
+
* Native `u32` band. `Uint32Array`.
|
|
213
|
+
*/
|
|
214
|
+
read_band_u32(band: number): Uint32Array;
|
|
215
|
+
/**
|
|
216
|
+
* Native `u8` band. `Uint8Array`.
|
|
217
|
+
*/
|
|
218
|
+
read_band_u8(band: number): Uint8Array;
|
|
219
|
+
/**
|
|
220
|
+
* Band-0 statistics as a JSON string (same shape as [`geotiff_stats`]).
|
|
221
|
+
*/
|
|
222
|
+
stats_json(): string;
|
|
223
|
+
/**
|
|
224
|
+
* GDAL value transform as `[scale, offset]` (physical = raw*scale+offset),
|
|
225
|
+
* or empty if none. Apply to `read_*` outputs to get physical values.
|
|
226
|
+
*/
|
|
227
|
+
value_transform(): Float64Array;
|
|
228
|
+
readonly bands: number;
|
|
229
|
+
readonly bits_per_sample: number;
|
|
230
|
+
readonly compression: string;
|
|
231
|
+
/**
|
|
232
|
+
* EPSG code, or `undefined` if the file is not georeferenced by EPSG.
|
|
233
|
+
*/
|
|
234
|
+
readonly epsg: number | undefined;
|
|
235
|
+
readonly height: number;
|
|
236
|
+
readonly is_bigtiff: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* No-data sentinel, or `undefined` if none is declared.
|
|
239
|
+
*/
|
|
240
|
+
readonly nodata: number | undefined;
|
|
241
|
+
readonly sample_format: string;
|
|
242
|
+
readonly width: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Install a panic hook so Rust panics surface as readable `console.error`
|
|
247
|
+
* messages instead of an opaque `RuntimeError: unreachable`.
|
|
248
|
+
*/
|
|
249
|
+
export function __start(): void;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Decode only a GeoTIFF's header and return its metadata as JSON. O(header)
|
|
253
|
+
* memory, so it works on multi-gigabyte rasters that whole-image reads cannot
|
|
254
|
+
* fit in WASM's 4 GiB address space.
|
|
17
255
|
*
|
|
18
|
-
*
|
|
256
|
+
* `{"ok":true,"width","height","bands","epsg"|null,"nodata"|null,
|
|
257
|
+
* "bits_per_sample","sample_format","compression","tiled","bigtiff"}`
|
|
258
|
+
*/
|
|
259
|
+
export function geotiff_info(data: Uint8Array): string;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Read a single band of pixel values as an `f64` `Float64Array` (any on-disk
|
|
263
|
+
* sample format is converted), row-major, length `width * height`.
|
|
264
|
+
*/
|
|
265
|
+
export function geotiff_read_band_f64(data: Uint8Array, band: number): Float64Array;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Decode a GeoTIFF and return band-0 summary statistics as JSON:
|
|
269
|
+
* `{"ok":true,"width","height","bands","epsg","valid","min","max","mean"}`.
|
|
19
270
|
*/
|
|
20
271
|
export function geotiff_stats(data: Uint8Array): string;
|
|
21
272
|
|
|
@@ -28,12 +279,72 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
28
279
|
|
|
29
280
|
export interface InitOutput {
|
|
30
281
|
readonly memory: WebAssembly.Memory;
|
|
282
|
+
readonly __wbg_cogbuilder_free: (a: number, b: number) => void;
|
|
283
|
+
readonly __wbg_cogstream_free: (a: number, b: number) => void;
|
|
284
|
+
readonly __wbg_geotiffreader_free: (a: number, b: number) => void;
|
|
285
|
+
readonly cogbuilder_new: (a: number, b: number, c: number) => number;
|
|
286
|
+
readonly cogbuilder_set_bigtiff: (a: number, b: number) => void;
|
|
287
|
+
readonly cogbuilder_set_compression: (a: number, b: number, c: number, d: number) => void;
|
|
288
|
+
readonly cogbuilder_set_epsg: (a: number, b: number) => void;
|
|
289
|
+
readonly cogbuilder_set_geo_transform: (a: number, b: number, c: number, d: number) => void;
|
|
290
|
+
readonly cogbuilder_set_nodata: (a: number, b: number) => void;
|
|
291
|
+
readonly cogbuilder_set_origin: (a: number, b: number, c: number, d: number) => void;
|
|
292
|
+
readonly cogbuilder_set_overview_levels: (a: number, b: number, c: number) => void;
|
|
293
|
+
readonly cogbuilder_set_tile_size: (a: number, b: number) => void;
|
|
294
|
+
readonly cogbuilder_write_f32: (a: number, b: number, c: number, d: number) => void;
|
|
295
|
+
readonly cogbuilder_write_f64: (a: number, b: number, c: number, d: number) => void;
|
|
296
|
+
readonly cogbuilder_write_u8: (a: number, b: number, c: number, d: number) => void;
|
|
297
|
+
readonly cogstream_bounding_box: (a: number, b: number) => void;
|
|
298
|
+
readonly cogstream_bounds_lonlat: (a: number, b: number) => void;
|
|
299
|
+
readonly cogstream_center: (a: number, b: number) => void;
|
|
300
|
+
readonly cogstream_center_lonlat: (a: number, b: number) => void;
|
|
301
|
+
readonly cogstream_decode_tile_f64: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
302
|
+
readonly cogstream_epsg: (a: number) => number;
|
|
303
|
+
readonly cogstream_geo_transform: (a: number, b: number) => void;
|
|
304
|
+
readonly cogstream_levels_json: (a: number, b: number) => void;
|
|
305
|
+
readonly cogstream_new: (a: number, b: number, c: number) => void;
|
|
306
|
+
readonly cogstream_nodata: (a: number, b: number) => void;
|
|
307
|
+
readonly cogstream_num_levels: (a: number) => number;
|
|
308
|
+
readonly cogstream_tile_range: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
309
|
+
readonly cogstream_tiles_for_window: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
31
310
|
readonly geotiff_info: (a: number, b: number, c: number) => void;
|
|
311
|
+
readonly geotiff_read_band_f64: (a: number, b: number, c: number, d: number) => void;
|
|
32
312
|
readonly geotiff_stats: (a: number, b: number, c: number) => void;
|
|
313
|
+
readonly geotiffreader_bands: (a: number) => number;
|
|
314
|
+
readonly geotiffreader_bits_per_sample: (a: number) => number;
|
|
315
|
+
readonly geotiffreader_bounding_box: (a: number, b: number) => void;
|
|
316
|
+
readonly geotiffreader_bounds_lonlat: (a: number, b: number) => void;
|
|
317
|
+
readonly geotiffreader_center: (a: number, b: number) => void;
|
|
318
|
+
readonly geotiffreader_center_lonlat: (a: number, b: number) => void;
|
|
319
|
+
readonly geotiffreader_compression: (a: number, b: number) => void;
|
|
320
|
+
readonly geotiffreader_epsg: (a: number) => number;
|
|
321
|
+
readonly geotiffreader_geo_transform: (a: number, b: number) => void;
|
|
322
|
+
readonly geotiffreader_height: (a: number) => number;
|
|
323
|
+
readonly geotiffreader_info_json: (a: number, b: number) => void;
|
|
324
|
+
readonly geotiffreader_is_bigtiff: (a: number) => number;
|
|
325
|
+
readonly geotiffreader_new: (a: number, b: number, c: number) => void;
|
|
326
|
+
readonly geotiffreader_nodata: (a: number, b: number) => void;
|
|
327
|
+
readonly geotiffreader_read_all_f64: (a: number, b: number) => void;
|
|
328
|
+
readonly geotiffreader_read_band_bytes: (a: number, b: number, c: number) => void;
|
|
329
|
+
readonly geotiffreader_read_band_f32: (a: number, b: number, c: number) => void;
|
|
330
|
+
readonly geotiffreader_read_band_f64: (a: number, b: number, c: number) => void;
|
|
331
|
+
readonly geotiffreader_read_band_i16: (a: number, b: number, c: number) => void;
|
|
332
|
+
readonly geotiffreader_read_band_i32: (a: number, b: number, c: number) => void;
|
|
333
|
+
readonly geotiffreader_read_band_i8: (a: number, b: number, c: number) => void;
|
|
334
|
+
readonly geotiffreader_read_band_u16: (a: number, b: number, c: number) => void;
|
|
335
|
+
readonly geotiffreader_read_band_u32: (a: number, b: number, c: number) => void;
|
|
336
|
+
readonly geotiffreader_read_band_u8: (a: number, b: number, c: number) => void;
|
|
337
|
+
readonly geotiffreader_sample_format: (a: number, b: number) => void;
|
|
338
|
+
readonly geotiffreader_stats_json: (a: number, b: number) => void;
|
|
339
|
+
readonly geotiffreader_value_transform: (a: number, b: number) => void;
|
|
340
|
+
readonly geotiffreader_width: (a: number) => number;
|
|
33
341
|
readonly version: (a: number) => void;
|
|
342
|
+
readonly __start: () => void;
|
|
343
|
+
readonly __wbindgen_export: (a: number, b: number, c: number) => void;
|
|
344
|
+
readonly __wbindgen_export2: (a: number, b: number) => number;
|
|
345
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
34
346
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
35
|
-
readonly
|
|
36
|
-
readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
347
|
+
readonly __wbindgen_start: () => void;
|
|
37
348
|
}
|
|
38
349
|
|
|
39
350
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|