whitebox-wasm 0.1.0 → 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 ADDED
@@ -0,0 +1,191 @@
1
+ # whitebox-wasm
2
+
3
+ **Pure-Rust geospatial toolkit compiled to WebAssembly.** No GDAL, no PROJ, no
4
+ native libraries, no server. Work with raster, vector, and LiDAR data entirely
5
+ in the browser, Node, Deno, or any Wasm host:
6
+
7
+ - **Raster** - read/write GeoTIFF / BigTIFF / COG, stats, range-request streaming
8
+ - **Projections** - full EPSG + user-defined CRS to WGS84 lon/lat
9
+ - **Vector** - read GeoJSON, TopoJSON, GML, GPX, KML, FlatGeobuf, GeoPackage, KMZ -> GeoJSON, with reprojection
10
+ - **LiDAR** - read LAS / LAZ / PLY point clouds (xyz, classification, intensity)
11
+ - **Analysis** - convex hull, Moran's I spatial autocorrelation
12
+
13
+ This wraps `wbgeotiff`, the shared GeoTIFF engine from the original
14
+ [**whitebox_next_gen**](https://github.com/jblindsay/whitebox_next_gen) project
15
+ by John Lindsay (Whitebox Geospatial Inc.) - the next-generation, pure-Rust
16
+ rewrite of WhiteboxTools - and exposes a tiny WebAssembly API. The entire codec
17
+ stack (Deflate, LZW, PackBits, JPEG, WebP, JPEG-XL, PNG predictors, BigTIFF,
18
+ tiling) is pure Rust with zero C dependencies, so the published module imports
19
+ nothing from the host beyond its own linear memory.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ npm install whitebox-wasm
25
+ ```
26
+
27
+ ## Usage (browser / Deno / Node >= 20, ESM)
28
+
29
+ ```js
30
+ import init, { geotiff_info, GeoTiffReader, CogBuilder } from "whitebox-wasm";
31
+
32
+ await init(); // in Node, pass the .wasm bytes to init()
33
+ const bytes = new Uint8Array(await (await fetch("dem.tif")).arrayBuffer());
34
+
35
+ // Metadata only - O(header) memory, works on multi-GB rasters:
36
+ console.log(JSON.parse(geotiff_info(bytes)));
37
+ // { ok:true, width, height, bands, epsg, nodata, bits_per_sample,
38
+ // sample_format, compression, tiled, bigtiff }
39
+
40
+ // Parse once, read many times:
41
+ const tif = new GeoTiffReader(bytes);
42
+ console.log(tif.width, tif.height, tif.bands, tif.epsg, tif.nodata);
43
+ console.log(Array.from(tif.geo_transform())); // [ox, px, 0, oy, 0, -py]
44
+ console.log(Array.from(tif.bounding_box())); // [minx, miny, maxx, maxy]
45
+ const band0 = tif.read_band_f64(0); // Float64Array
46
+ console.log(JSON.parse(tif.stats_json()));
47
+
48
+ // Encode a Cloud Optimized GeoTIFF (also a valid plain GeoTIFF):
49
+ const cb = new CogBuilder(width, height, 1);
50
+ cb.set_epsg(32610);
51
+ cb.set_origin(500000, 4000000, 30); // x_min, y_max, pixel size
52
+ cb.set_compression("deflate");
53
+ cb.set_nodata(-9999);
54
+ const cogBytes = cb.write_f64(new Float64Array(pixels)); // Uint8Array
55
+ ```
56
+
57
+ In Node the `web` target needs the wasm bytes handed to `init()`:
58
+
59
+ ```js
60
+ import { readFileSync } from "node:fs";
61
+ import init, { geotiff_info } from "whitebox-wasm";
62
+ await init({ module_or_path: readFileSync("node_modules/whitebox-wasm/whitebox_wasm_bg.wasm") });
63
+ ```
64
+
65
+ ## API
66
+
67
+ ### Convenience functions
68
+
69
+ | Function | Returns |
70
+ |---|---|
71
+ | `geotiff_info(bytes)` | JSON metadata, header-only (incl. `bbox`, `center`, `center_lonlat`) |
72
+ | `geotiff_stats(bytes)` | JSON band-0 stats `{valid, min, max, mean, ...}` |
73
+ | `geotiff_read_band_f64(bytes, band)` | `Float64Array` of band pixels |
74
+ | `version()` | crate version string |
75
+
76
+ ### `GeoTiffReader` (parse once, read many)
77
+
78
+ `new GeoTiffReader(bytes)`, then:
79
+
80
+ - Properties: `width`, `height`, `bands`, `bits_per_sample`, `sample_format`, `compression`, `is_bigtiff`, `epsg`, `nodata`
81
+ - `geo_transform()` -> `[x_origin, pixel_width, row_rot, y_origin, col_rot, pixel_height]` (empty if none)
82
+ - `bounding_box()` -> `[min_x, min_y, max_x, max_y]` in the dataset CRS (empty if not georeferenced)
83
+ - `center()` -> `[x, y]` center in the dataset CRS
84
+ - `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)
85
+ - `value_transform()` -> `[scale, offset]` (GDAL scale/offset; empty if none)
86
+ - `info_json()`, `stats_json()` -> JSON strings
87
+ - `read_band_f64(band)` / `read_all_f64()` -> `Float64Array` (any on-disk type converted)
88
+ - `read_band_bytes(band)` -> raw `Uint8Array`
89
+ - Native typed reads (require matching on-disk type): `read_band_u8` / `i8` / `u16` / `i16` / `u32` / `i32` / `f32`
90
+
91
+ ### `CogBuilder` (write Cloud Optimized GeoTIFFs)
92
+
93
+ `new CogBuilder(width, height, bands)`, configure, then `write_u8` / `write_f32` / `write_f64(data)` -> `Uint8Array`:
94
+
95
+ - `set_epsg(code)`, `set_nodata(v)`, `set_compression("none|lzw|deflate|packbits|webp|jpeg|jpegxl")`
96
+ - `set_geo_transform([6 values])` or `set_origin(x_min, y_max, pixel_size)`
97
+ - `set_tile_size(px)`, `set_bigtiff(bool)`, `set_overview_levels([2,4,8])`
98
+
99
+ Output is a tiled COG with overviews and GDAL ghost metadata - readable by GDAL, rasterio, QGIS, and `GeoTiffReader`.
100
+
101
+ ### `CogStream` (read remote COGs via HTTP range requests)
102
+
103
+ Read a window or overview out of a large COG **without downloading the whole
104
+ file**. The wasm parses the header and reports byte ranges; your JS does the
105
+ range requests:
106
+
107
+ ```js
108
+ import init, { CogStream } from "whitebox-wasm";
109
+ await init();
110
+
111
+ const url = "https://example.com/big-cog.tif";
112
+ const range = (a, b) => fetch(url, { headers: { Range: `bytes=${a}-${b}` } })
113
+ .then(r => r.arrayBuffer()).then(b => new Uint8Array(b));
114
+
115
+ const stream = new CogStream(await range(0, 65535)); // header prefix
116
+ const lv = JSON.parse(stream.levels_json())[0]; // level 0 = full res
117
+ const tiles = JSON.parse(stream.tiles_for_window(0, 1200, 800, 256, 256));
118
+
119
+ for (const t of tiles) {
120
+ const bytes = await range(t.offset, t.offset + t.length - 1); // one tile
121
+ const px = stream.decode_tile_f64(0, bytes); // Float64Array
122
+ // place px (tile_width x tile_height) into your output window...
123
+ }
124
+ ```
125
+
126
+ - `new CogStream(headerBytes)` - parse the IFD chain + tile index (throws if the
127
+ prefix is too short; fetch more and retry).
128
+ - `num_levels`, `epsg`, `nodata`, `geo_transform()`, `levels_json()`
129
+ - `bounding_box()`, `center()`, `center_lonlat()`, `bounds_lonlat()` (same semantics as `GeoTiffReader`)
130
+ - `tiles_for_window(level, x, y, w, h)` -> JSON `[{col,row,offset,length}]`
131
+ - `tile_range(level, col, row)` -> `[offset, length]`
132
+ - `decode_tile_f64(level, tileBytes)` -> `Float64Array` (one decoded tile)
133
+
134
+ Use a higher `level` (overview) for zoomed-out views. See
135
+ [`examples/cog-stream.mjs`](../../examples/cog-stream.mjs) for a full window read
136
+ that fetches only the tiles it needs (about 13% of a 5.7 MiB file for a 256x256
137
+ window). Requires a tiled COG on a server that supports HTTP range requests.
138
+
139
+ JSON-returning functions report failures as `{"ok":false,"error":"..."}`; class methods throw on error.
140
+
141
+ ## Vector
142
+
143
+ ```js
144
+ import init, { vector_to_geojson, vector_info, vector_to_geojson_reproject } from "whitebox-wasm";
145
+ await init();
146
+ const bytes = new Uint8Array(await (await fetch("data.fgb")).arrayBuffer());
147
+ const geojson = JSON.parse(vector_to_geojson(bytes, "flatgeobuf"));
148
+ const meta = JSON.parse(vector_info(bytes, "flatgeobuf")); // { features, geometry, epsg, fields, bbox }
149
+ const wgs84 = vector_to_geojson_reproject(bytes, "flatgeobuf", 4326, 0); // dst, src(0=auto)
150
+ ```
151
+
152
+ - `vector_formats()` -> supported formats (geojson, topojson, gml, gpx, kml, flatgeobuf, geopackage, kmz)
153
+ - `vector_to_geojson(data, format)` -> GeoJSON string
154
+ - `vector_to_geojson_reproject(data, format, dst_epsg, src_epsg)` -> reprojected GeoJSON (`src_epsg=0` uses the layer CRS, or 4326)
155
+ - `vector_info(data, format)` -> JSON `{name, features, geometry, epsg, fields, bbox}`
156
+
157
+ ## LiDAR
158
+
159
+ ```js
160
+ import init, { lidar_info, lidar_read_xyz } from "whitebox-wasm";
161
+ await init();
162
+ const las = new Uint8Array(await (await fetch("cloud.laz")).arrayBuffer());
163
+ const meta = JSON.parse(lidar_info(las, "laz")); // { points, epsg, point_format, bounds }
164
+ const xyz = lidar_read_xyz(las, "laz"); // Float64Array [x0,y0,z0, x1,y1,z1, ...]
165
+ ```
166
+
167
+ - `lidar_formats()`, `lidar_info(data, format)` (header-only count/bounds for LAS/LAZ)
168
+ - `lidar_read_xyz` -> `Float64Array`; `lidar_read_classification` -> `Uint8Array`; `lidar_read_intensity` -> `Uint16Array`
169
+
170
+ ## Analysis
171
+
172
+ - `convex_hull(points_xy)` -> hull ring `Float64Array` (input `[x0,y0,x1,y1,...]`)
173
+ - `morans_i(points_xy, values, distance_threshold)` -> JSON global spatial autocorrelation `{morans_i, expected, variance, z_score, p_value, n}`
174
+
175
+ ## Limits
176
+
177
+ WebAssembly is 32-bit, so linear memory is capped at ~4 GiB. `geotiff_info` is
178
+ header-only and unaffected, but reads/writes that materialize a full raster are
179
+ bounded by that ceiling (a national 1-billion-pixel raster cannot be fully
180
+ decoded in-browser). For such data, read metadata only or process server-side.
181
+
182
+ ## Links
183
+
184
+ - Source, live demo, and issues: https://github.com/opengeos/whitebox-wasm
185
+ - Live browser demo: https://opengeos.org/whitebox-wasm/
186
+
187
+ ## License
188
+
189
+ Dual-licensed under MIT or Apache-2.0, at your option. Includes the vendored
190
+ `wbgeotiff`, `wbprojection`, `wbvector`, `wblidar`, `wbtopology`, `wbspatialstats`, and `wbhdf` crates (Copyright John Lindsay, Whitebox
191
+ Geospatial Inc.), used under the same dual license.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "whitebox-wasm",
3
3
  "type": "module",
4
- "description": "WebAssembly bindings for the pure-Rust Whitebox GeoTIFF engine",
5
- "version": "0.1.0",
4
+ "description": "Pure-Rust geospatial toolkit (raster, vector, LiDAR, projections) compiled to WebAssembly",
5
+ "version": "0.3.0",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -20,10 +20,10 @@
20
20
  "./snippets/*"
21
21
  ],
22
22
  "keywords": [
23
- "geotiff",
23
+ "geospatial",
24
24
  "wasm",
25
25
  "gis",
26
- "raster",
27
- "webassembly"
26
+ "geotiff",
27
+ "lidar"
28
28
  ]
29
- }
29
+ }
@@ -2,23 +2,349 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  /**
5
- * Decode a GeoTIFF and return only its georeferencing/shape metadata as JSON:
6
- * `{"ok":true,"width":W,"height":H,"bands":B,"epsg":E|null,"nodata":V|null}`.
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 function geotiff_info(data: Uint8Array): string;
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
- * Decode a GeoTIFF from raw bytes and return summary statistics as a JSON string.
66
+ * Range-request reader for a (tiled) Cloud Optimized GeoTIFF.
67
+ *
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:
12
71
  *
13
- * The returned JSON has the shape:
14
- * `{"ok":true,"width":W,"height":H,"bands":B,"epsg":E|null,"valid":N,
15
- * "min":..,"max":..,"mean":..}` on success, or
16
- * `{"ok":false,"error":"..."}` on failure.
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
+ * Convex hull of a 2D point set. Input is `[x0,y0,x1,y1,...]`; output is the
253
+ * hull ring as `[x0,y0,...]` (closed). Needs at least 3 points.
254
+ */
255
+ export function convex_hull(points_xy: Float64Array): Float64Array;
256
+
257
+ /**
258
+ * Decode only a GeoTIFF's header and return its metadata as JSON. O(header)
259
+ * memory, so it works on multi-gigabyte rasters that whole-image reads cannot
260
+ * fit in WASM's 4 GiB address space.
17
261
  *
18
- * Statistics are computed over band 0, skipping NaN and the nodata value.
262
+ * `{"ok":true,"width","height","bands","epsg"|null,"nodata"|null,
263
+ * "bits_per_sample","sample_format","compression","tiled","bigtiff"}`
264
+ */
265
+ export function geotiff_info(data: Uint8Array): string;
266
+
267
+ /**
268
+ * Read a single band of pixel values as an `f64` `Float64Array` (any on-disk
269
+ * sample format is converted), row-major, length `width * height`.
270
+ */
271
+ export function geotiff_read_band_f64(data: Uint8Array, band: number): Float64Array;
272
+
273
+ /**
274
+ * Decode a GeoTIFF and return band-0 summary statistics as JSON:
275
+ * `{"ok":true,"width","height","bands","epsg","valid","min","max","mean"}`.
19
276
  */
20
277
  export function geotiff_stats(data: Uint8Array): string;
21
278
 
279
+ /**
280
+ * LiDAR formats this build can read from memory.
281
+ */
282
+ export function lidar_formats(): string;
283
+
284
+ /**
285
+ * Read a LiDAR file's metadata as JSON without loading all points where
286
+ * possible (LAS/LAZ report count and bounds from the header):
287
+ * `{"ok":true,"format","points","epsg"|null,"point_format"|null,
288
+ * "bounds":[min_x,min_y,min_z,max_x,max_y,max_z]|null}`.
289
+ */
290
+ export function lidar_info(data: Uint8Array, format: string): string;
291
+
292
+ /**
293
+ * Read per-point classification codes as a `Uint8Array` (length `point_count`).
294
+ */
295
+ export function lidar_read_classification(data: Uint8Array, format: string): Uint8Array;
296
+
297
+ /**
298
+ * Read per-point intensity as a `Uint16Array` (length `point_count`).
299
+ */
300
+ export function lidar_read_intensity(data: Uint8Array, format: string): Uint16Array;
301
+
302
+ /**
303
+ * Read all point coordinates as an interleaved `Float64Array`
304
+ * `[x0,y0,z0, x1,y1,z1, ...]` (length `3 * point_count`).
305
+ *
306
+ * Guarded against 32-bit memory blowup; very large clouds return a clean error
307
+ * (read the header with `lidar_info`, or downsample on your side).
308
+ */
309
+ export function lidar_read_xyz(data: Uint8Array, format: string): Float64Array;
310
+
311
+ /**
312
+ * Global Moran's I spatial autocorrelation for point data, using a binary
313
+ * distance-band spatial weights matrix (neighbors within `distance_threshold`).
314
+ *
315
+ * `points_xy` is `[x0,y0,...]`, `values` is one value per point. Returns JSON:
316
+ * `{"ok":true,"morans_i","expected","variance","z_score","p_value","n"}`.
317
+ *
318
+ * Builds neighbors in O(n^2); intended for up to a few thousand points.
319
+ */
320
+ export function morans_i(points_xy: Float64Array, values: Float64Array, distance_threshold: number): string;
321
+
322
+ /**
323
+ * Vector formats this build can read from memory (comma-separated).
324
+ */
325
+ export function vector_formats(): string;
326
+
327
+ /**
328
+ * Read a vector dataset and return metadata as JSON:
329
+ * `{"ok":true,"name","features","geometry","epsg"|null,"fields":[...],
330
+ * "bbox":[min_x,min_y,max_x,max_y]|null}`.
331
+ */
332
+ export function vector_info(data: Uint8Array, format: string): string;
333
+
334
+ /**
335
+ * Read a vector dataset and return it as a GeoJSON `FeatureCollection` string.
336
+ */
337
+ export function vector_to_geojson(data: Uint8Array, format: string): string;
338
+
339
+ /**
340
+ * Read a vector dataset, reproject it to `dst_epsg`, and return GeoJSON.
341
+ * Uses the bundled pure-Rust projection engine (full EPSG support).
342
+ *
343
+ * `src_epsg` overrides the source CRS: pass `0` to use the layer's own CRS, or
344
+ * fall back to EPSG:4326 if it declares none (GeoJSON is WGS84 by RFC 7946).
345
+ */
346
+ export function vector_to_geojson_reproject(data: Uint8Array, format: string, dst_epsg: number, src_epsg: number): string;
347
+
22
348
  /**
23
349
  * Semantic version of this crate, exposed for runtime feature detection.
24
350
  */
@@ -28,12 +354,91 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
28
354
 
29
355
  export interface InitOutput {
30
356
  readonly memory: WebAssembly.Memory;
357
+ readonly __start: () => void;
358
+ readonly __wbg_cogbuilder_free: (a: number, b: number) => void;
359
+ readonly __wbg_cogstream_free: (a: number, b: number) => void;
360
+ readonly __wbg_geotiffreader_free: (a: number, b: number) => void;
361
+ readonly cogbuilder_new: (a: number, b: number, c: number) => number;
362
+ readonly cogbuilder_set_bigtiff: (a: number, b: number) => void;
363
+ readonly cogbuilder_set_compression: (a: number, b: number, c: number, d: number) => void;
364
+ readonly cogbuilder_set_epsg: (a: number, b: number) => void;
365
+ readonly cogbuilder_set_geo_transform: (a: number, b: number, c: number, d: number) => void;
366
+ readonly cogbuilder_set_nodata: (a: number, b: number) => void;
367
+ readonly cogbuilder_set_origin: (a: number, b: number, c: number, d: number) => void;
368
+ readonly cogbuilder_set_overview_levels: (a: number, b: number, c: number) => void;
369
+ readonly cogbuilder_set_tile_size: (a: number, b: number) => void;
370
+ readonly cogbuilder_write_f32: (a: number, b: number, c: number, d: number) => void;
371
+ readonly cogbuilder_write_f64: (a: number, b: number, c: number, d: number) => void;
372
+ readonly cogbuilder_write_u8: (a: number, b: number, c: number, d: number) => void;
373
+ readonly cogstream_bounding_box: (a: number, b: number) => void;
374
+ readonly cogstream_bounds_lonlat: (a: number, b: number) => void;
375
+ readonly cogstream_center: (a: number, b: number) => void;
376
+ readonly cogstream_center_lonlat: (a: number, b: number) => void;
377
+ readonly cogstream_decode_tile_f64: (a: number, b: number, c: number, d: number, e: number) => void;
378
+ readonly cogstream_epsg: (a: number) => number;
379
+ readonly cogstream_geo_transform: (a: number, b: number) => void;
380
+ readonly cogstream_levels_json: (a: number, b: number) => void;
381
+ readonly cogstream_new: (a: number, b: number, c: number) => void;
382
+ readonly cogstream_nodata: (a: number, b: number) => void;
383
+ readonly cogstream_num_levels: (a: number) => number;
384
+ readonly cogstream_tile_range: (a: number, b: number, c: number, d: number, e: number) => void;
385
+ readonly cogstream_tiles_for_window: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
386
+ readonly convex_hull: (a: number, b: number, c: number) => void;
31
387
  readonly geotiff_info: (a: number, b: number, c: number) => void;
388
+ readonly geotiff_read_band_f64: (a: number, b: number, c: number, d: number) => void;
32
389
  readonly geotiff_stats: (a: number, b: number, c: number) => void;
390
+ readonly geotiffreader_bands: (a: number) => number;
391
+ readonly geotiffreader_bits_per_sample: (a: number) => number;
392
+ readonly geotiffreader_bounding_box: (a: number, b: number) => void;
393
+ readonly geotiffreader_bounds_lonlat: (a: number, b: number) => void;
394
+ readonly geotiffreader_center: (a: number, b: number) => void;
395
+ readonly geotiffreader_center_lonlat: (a: number, b: number) => void;
396
+ readonly geotiffreader_compression: (a: number, b: number) => void;
397
+ readonly geotiffreader_epsg: (a: number) => number;
398
+ readonly geotiffreader_geo_transform: (a: number, b: number) => void;
399
+ readonly geotiffreader_height: (a: number) => number;
400
+ readonly geotiffreader_info_json: (a: number, b: number) => void;
401
+ readonly geotiffreader_is_bigtiff: (a: number) => number;
402
+ readonly geotiffreader_new: (a: number, b: number, c: number) => void;
403
+ readonly geotiffreader_nodata: (a: number, b: number) => void;
404
+ readonly geotiffreader_read_all_f64: (a: number, b: number) => void;
405
+ readonly geotiffreader_read_band_bytes: (a: number, b: number, c: number) => void;
406
+ readonly geotiffreader_read_band_f32: (a: number, b: number, c: number) => void;
407
+ readonly geotiffreader_read_band_f64: (a: number, b: number, c: number) => void;
408
+ readonly geotiffreader_read_band_i16: (a: number, b: number, c: number) => void;
409
+ readonly geotiffreader_read_band_i32: (a: number, b: number, c: number) => void;
410
+ readonly geotiffreader_read_band_i8: (a: number, b: number, c: number) => void;
411
+ readonly geotiffreader_read_band_u16: (a: number, b: number, c: number) => void;
412
+ readonly geotiffreader_read_band_u32: (a: number, b: number, c: number) => void;
413
+ readonly geotiffreader_read_band_u8: (a: number, b: number, c: number) => void;
414
+ readonly geotiffreader_sample_format: (a: number, b: number) => void;
415
+ readonly geotiffreader_stats_json: (a: number, b: number) => void;
416
+ readonly geotiffreader_value_transform: (a: number, b: number) => void;
417
+ readonly geotiffreader_width: (a: number) => number;
418
+ readonly lidar_formats: (a: number) => void;
419
+ readonly lidar_info: (a: number, b: number, c: number, d: number, e: number) => void;
420
+ readonly lidar_read_classification: (a: number, b: number, c: number, d: number, e: number) => void;
421
+ readonly lidar_read_intensity: (a: number, b: number, c: number, d: number, e: number) => void;
422
+ readonly lidar_read_xyz: (a: number, b: number, c: number, d: number, e: number) => void;
423
+ readonly morans_i: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
424
+ readonly vector_formats: (a: number) => void;
425
+ readonly vector_info: (a: number, b: number, c: number, d: number, e: number) => void;
426
+ readonly vector_to_geojson: (a: number, b: number, c: number, d: number, e: number) => void;
427
+ readonly vector_to_geojson_reproject: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
33
428
  readonly version: (a: number) => void;
429
+ readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
430
+ readonly rust_zstd_wasm_shim_free: (a: number) => void;
431
+ readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
432
+ readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
433
+ readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
434
+ readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
435
+ readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
436
+ readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
437
+ readonly __wbindgen_export: (a: number, b: number, c: number) => void;
438
+ readonly __wbindgen_export2: (a: number, b: number) => number;
439
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
34
440
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
35
- readonly __wbindgen_export: (a: number, b: number) => number;
36
- readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
441
+ readonly __wbindgen_start: () => void;
37
442
  }
38
443
 
39
444
  export type SyncInitInput = BufferSource | WebAssembly.Module;