whitebox-wasm 0.2.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 CHANGED
@@ -1,8 +1,14 @@
1
1
  # whitebox-wasm
2
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.
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
6
12
 
7
13
  This wraps `wbgeotiff`, the shared GeoTIFF engine from the original
8
14
  [**whitebox_next_gen**](https://github.com/jblindsay/whitebox_next_gen) project
@@ -132,6 +138,40 @@ window). Requires a tiled COG on a server that supports HTTP range requests.
132
138
 
133
139
  JSON-returning functions report failures as `{"ok":false,"error":"..."}`; class methods throw on error.
134
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
+
135
175
  ## Limits
136
176
 
137
177
  WebAssembly is 32-bit, so linear memory is capped at ~4 GiB. `geotiff_info` is
@@ -147,5 +187,5 @@ decoded in-browser). For such data, read metadata only or process server-side.
147
187
  ## License
148
188
 
149
189
  Dual-licensed under MIT or Apache-2.0, at your option. Includes the vendored
150
- `wbgeotiff` and `wbprojection` crates (Copyright John Lindsay, Whitebox
190
+ `wbgeotiff`, `wbprojection`, `wbvector`, `wblidar`, `wbtopology`, `wbspatialstats`, and `wbhdf` crates (Copyright John Lindsay, Whitebox
151
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.2.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
  }
@@ -248,6 +248,12 @@ export class GeoTiffReader {
248
248
  */
249
249
  export function __start(): void;
250
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
+
251
257
  /**
252
258
  * Decode only a GeoTIFF's header and return its metadata as JSON. O(header)
253
259
  * memory, so it works on multi-gigabyte rasters that whole-image reads cannot
@@ -270,6 +276,75 @@ export function geotiff_read_band_f64(data: Uint8Array, band: number): Float64Ar
270
276
  */
271
277
  export function geotiff_stats(data: Uint8Array): string;
272
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
+
273
348
  /**
274
349
  * Semantic version of this crate, exposed for runtime feature detection.
275
350
  */
@@ -279,6 +354,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
279
354
 
280
355
  export interface InitOutput {
281
356
  readonly memory: WebAssembly.Memory;
357
+ readonly __start: () => void;
282
358
  readonly __wbg_cogbuilder_free: (a: number, b: number) => void;
283
359
  readonly __wbg_cogstream_free: (a: number, b: number) => void;
284
360
  readonly __wbg_geotiffreader_free: (a: number, b: number) => void;
@@ -307,6 +383,7 @@ export interface InitOutput {
307
383
  readonly cogstream_num_levels: (a: number) => number;
308
384
  readonly cogstream_tile_range: (a: number, b: number, c: number, d: number, e: number) => void;
309
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;
310
387
  readonly geotiff_info: (a: number, b: number, c: number) => void;
311
388
  readonly geotiff_read_band_f64: (a: number, b: number, c: number, d: number) => void;
312
389
  readonly geotiff_stats: (a: number, b: number, c: number) => void;
@@ -338,8 +415,25 @@ export interface InitOutput {
338
415
  readonly geotiffreader_stats_json: (a: number, b: number) => void;
339
416
  readonly geotiffreader_value_transform: (a: number, b: number) => void;
340
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;
341
428
  readonly version: (a: number) => void;
342
- readonly __start: () => 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;
343
437
  readonly __wbindgen_export: (a: number, b: number, c: number) => void;
344
438
  readonly __wbindgen_export2: (a: number, b: number) => number;
345
439
  readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
package/whitebox_wasm.js CHANGED
@@ -989,6 +989,33 @@ export function __start() {
989
989
  wasm.__start();
990
990
  }
991
991
 
992
+ /**
993
+ * Convex hull of a 2D point set. Input is `[x0,y0,x1,y1,...]`; output is the
994
+ * hull ring as `[x0,y0,...]` (closed). Needs at least 3 points.
995
+ * @param {Float64Array} points_xy
996
+ * @returns {Float64Array}
997
+ */
998
+ export function convex_hull(points_xy) {
999
+ try {
1000
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1001
+ const ptr0 = passArrayF64ToWasm0(points_xy, wasm.__wbindgen_export2);
1002
+ const len0 = WASM_VECTOR_LEN;
1003
+ wasm.convex_hull(retptr, ptr0, len0);
1004
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1005
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1006
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1007
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1008
+ if (r3) {
1009
+ throw takeObject(r2);
1010
+ }
1011
+ var v2 = getArrayF64FromWasm0(r0, r1).slice();
1012
+ wasm.__wbindgen_export(r0, r1 * 8, 8);
1013
+ return v2;
1014
+ } finally {
1015
+ wasm.__wbindgen_add_to_stack_pointer(16);
1016
+ }
1017
+ }
1018
+
992
1019
  /**
993
1020
  * Decode only a GeoTIFF's header and return its metadata as JSON. O(header)
994
1021
  * memory, so it works on multi-gigabyte rasters that whole-image reads cannot
@@ -1071,6 +1098,332 @@ export function geotiff_stats(data) {
1071
1098
  }
1072
1099
  }
1073
1100
 
1101
+ /**
1102
+ * LiDAR formats this build can read from memory.
1103
+ * @returns {string}
1104
+ */
1105
+ export function lidar_formats() {
1106
+ let deferred1_0;
1107
+ let deferred1_1;
1108
+ try {
1109
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1110
+ wasm.lidar_formats(retptr);
1111
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1112
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1113
+ deferred1_0 = r0;
1114
+ deferred1_1 = r1;
1115
+ return getStringFromWasm0(r0, r1);
1116
+ } finally {
1117
+ wasm.__wbindgen_add_to_stack_pointer(16);
1118
+ wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
1119
+ }
1120
+ }
1121
+
1122
+ /**
1123
+ * Read a LiDAR file's metadata as JSON without loading all points where
1124
+ * possible (LAS/LAZ report count and bounds from the header):
1125
+ * `{"ok":true,"format","points","epsg"|null,"point_format"|null,
1126
+ * "bounds":[min_x,min_y,min_z,max_x,max_y,max_z]|null}`.
1127
+ * @param {Uint8Array} data
1128
+ * @param {string} format
1129
+ * @returns {string}
1130
+ */
1131
+ export function lidar_info(data, format) {
1132
+ let deferred4_0;
1133
+ let deferred4_1;
1134
+ try {
1135
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1136
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
1137
+ const len0 = WASM_VECTOR_LEN;
1138
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1139
+ const len1 = WASM_VECTOR_LEN;
1140
+ wasm.lidar_info(retptr, ptr0, len0, ptr1, len1);
1141
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1142
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1143
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1144
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1145
+ var ptr3 = r0;
1146
+ var len3 = r1;
1147
+ if (r3) {
1148
+ ptr3 = 0; len3 = 0;
1149
+ throw takeObject(r2);
1150
+ }
1151
+ deferred4_0 = ptr3;
1152
+ deferred4_1 = len3;
1153
+ return getStringFromWasm0(ptr3, len3);
1154
+ } finally {
1155
+ wasm.__wbindgen_add_to_stack_pointer(16);
1156
+ wasm.__wbindgen_export(deferred4_0, deferred4_1, 1);
1157
+ }
1158
+ }
1159
+
1160
+ /**
1161
+ * Read per-point classification codes as a `Uint8Array` (length `point_count`).
1162
+ * @param {Uint8Array} data
1163
+ * @param {string} format
1164
+ * @returns {Uint8Array}
1165
+ */
1166
+ export function lidar_read_classification(data, format) {
1167
+ try {
1168
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1169
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
1170
+ const len0 = WASM_VECTOR_LEN;
1171
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1172
+ const len1 = WASM_VECTOR_LEN;
1173
+ wasm.lidar_read_classification(retptr, ptr0, len0, ptr1, len1);
1174
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1175
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1176
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1177
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1178
+ if (r3) {
1179
+ throw takeObject(r2);
1180
+ }
1181
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
1182
+ wasm.__wbindgen_export(r0, r1 * 1, 1);
1183
+ return v3;
1184
+ } finally {
1185
+ wasm.__wbindgen_add_to_stack_pointer(16);
1186
+ }
1187
+ }
1188
+
1189
+ /**
1190
+ * Read per-point intensity as a `Uint16Array` (length `point_count`).
1191
+ * @param {Uint8Array} data
1192
+ * @param {string} format
1193
+ * @returns {Uint16Array}
1194
+ */
1195
+ export function lidar_read_intensity(data, format) {
1196
+ try {
1197
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1198
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
1199
+ const len0 = WASM_VECTOR_LEN;
1200
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1201
+ const len1 = WASM_VECTOR_LEN;
1202
+ wasm.lidar_read_intensity(retptr, ptr0, len0, ptr1, len1);
1203
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1204
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1205
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1206
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1207
+ if (r3) {
1208
+ throw takeObject(r2);
1209
+ }
1210
+ var v3 = getArrayU16FromWasm0(r0, r1).slice();
1211
+ wasm.__wbindgen_export(r0, r1 * 2, 2);
1212
+ return v3;
1213
+ } finally {
1214
+ wasm.__wbindgen_add_to_stack_pointer(16);
1215
+ }
1216
+ }
1217
+
1218
+ /**
1219
+ * Read all point coordinates as an interleaved `Float64Array`
1220
+ * `[x0,y0,z0, x1,y1,z1, ...]` (length `3 * point_count`).
1221
+ *
1222
+ * Guarded against 32-bit memory blowup; very large clouds return a clean error
1223
+ * (read the header with `lidar_info`, or downsample on your side).
1224
+ * @param {Uint8Array} data
1225
+ * @param {string} format
1226
+ * @returns {Float64Array}
1227
+ */
1228
+ export function lidar_read_xyz(data, format) {
1229
+ try {
1230
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1231
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
1232
+ const len0 = WASM_VECTOR_LEN;
1233
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1234
+ const len1 = WASM_VECTOR_LEN;
1235
+ wasm.lidar_read_xyz(retptr, ptr0, len0, ptr1, len1);
1236
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1237
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1238
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1239
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1240
+ if (r3) {
1241
+ throw takeObject(r2);
1242
+ }
1243
+ var v3 = getArrayF64FromWasm0(r0, r1).slice();
1244
+ wasm.__wbindgen_export(r0, r1 * 8, 8);
1245
+ return v3;
1246
+ } finally {
1247
+ wasm.__wbindgen_add_to_stack_pointer(16);
1248
+ }
1249
+ }
1250
+
1251
+ /**
1252
+ * Global Moran's I spatial autocorrelation for point data, using a binary
1253
+ * distance-band spatial weights matrix (neighbors within `distance_threshold`).
1254
+ *
1255
+ * `points_xy` is `[x0,y0,...]`, `values` is one value per point. Returns JSON:
1256
+ * `{"ok":true,"morans_i","expected","variance","z_score","p_value","n"}`.
1257
+ *
1258
+ * Builds neighbors in O(n^2); intended for up to a few thousand points.
1259
+ * @param {Float64Array} points_xy
1260
+ * @param {Float64Array} values
1261
+ * @param {number} distance_threshold
1262
+ * @returns {string}
1263
+ */
1264
+ export function morans_i(points_xy, values, distance_threshold) {
1265
+ let deferred4_0;
1266
+ let deferred4_1;
1267
+ try {
1268
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1269
+ const ptr0 = passArrayF64ToWasm0(points_xy, wasm.__wbindgen_export2);
1270
+ const len0 = WASM_VECTOR_LEN;
1271
+ const ptr1 = passArrayF64ToWasm0(values, wasm.__wbindgen_export2);
1272
+ const len1 = WASM_VECTOR_LEN;
1273
+ wasm.morans_i(retptr, ptr0, len0, ptr1, len1, distance_threshold);
1274
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1275
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1276
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1277
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1278
+ var ptr3 = r0;
1279
+ var len3 = r1;
1280
+ if (r3) {
1281
+ ptr3 = 0; len3 = 0;
1282
+ throw takeObject(r2);
1283
+ }
1284
+ deferred4_0 = ptr3;
1285
+ deferred4_1 = len3;
1286
+ return getStringFromWasm0(ptr3, len3);
1287
+ } finally {
1288
+ wasm.__wbindgen_add_to_stack_pointer(16);
1289
+ wasm.__wbindgen_export(deferred4_0, deferred4_1, 1);
1290
+ }
1291
+ }
1292
+
1293
+ /**
1294
+ * Vector formats this build can read from memory (comma-separated).
1295
+ * @returns {string}
1296
+ */
1297
+ export function vector_formats() {
1298
+ let deferred1_0;
1299
+ let deferred1_1;
1300
+ try {
1301
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1302
+ wasm.vector_formats(retptr);
1303
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1304
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1305
+ deferred1_0 = r0;
1306
+ deferred1_1 = r1;
1307
+ return getStringFromWasm0(r0, r1);
1308
+ } finally {
1309
+ wasm.__wbindgen_add_to_stack_pointer(16);
1310
+ wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
1311
+ }
1312
+ }
1313
+
1314
+ /**
1315
+ * Read a vector dataset and return metadata as JSON:
1316
+ * `{"ok":true,"name","features","geometry","epsg"|null,"fields":[...],
1317
+ * "bbox":[min_x,min_y,max_x,max_y]|null}`.
1318
+ * @param {Uint8Array} data
1319
+ * @param {string} format
1320
+ * @returns {string}
1321
+ */
1322
+ export function vector_info(data, format) {
1323
+ let deferred4_0;
1324
+ let deferred4_1;
1325
+ try {
1326
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1327
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
1328
+ const len0 = WASM_VECTOR_LEN;
1329
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1330
+ const len1 = WASM_VECTOR_LEN;
1331
+ wasm.vector_info(retptr, ptr0, len0, ptr1, len1);
1332
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1333
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1334
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1335
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1336
+ var ptr3 = r0;
1337
+ var len3 = r1;
1338
+ if (r3) {
1339
+ ptr3 = 0; len3 = 0;
1340
+ throw takeObject(r2);
1341
+ }
1342
+ deferred4_0 = ptr3;
1343
+ deferred4_1 = len3;
1344
+ return getStringFromWasm0(ptr3, len3);
1345
+ } finally {
1346
+ wasm.__wbindgen_add_to_stack_pointer(16);
1347
+ wasm.__wbindgen_export(deferred4_0, deferred4_1, 1);
1348
+ }
1349
+ }
1350
+
1351
+ /**
1352
+ * Read a vector dataset and return it as a GeoJSON `FeatureCollection` string.
1353
+ * @param {Uint8Array} data
1354
+ * @param {string} format
1355
+ * @returns {string}
1356
+ */
1357
+ export function vector_to_geojson(data, format) {
1358
+ let deferred4_0;
1359
+ let deferred4_1;
1360
+ try {
1361
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1362
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
1363
+ const len0 = WASM_VECTOR_LEN;
1364
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1365
+ const len1 = WASM_VECTOR_LEN;
1366
+ wasm.vector_to_geojson(retptr, ptr0, len0, ptr1, len1);
1367
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1368
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1369
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1370
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1371
+ var ptr3 = r0;
1372
+ var len3 = r1;
1373
+ if (r3) {
1374
+ ptr3 = 0; len3 = 0;
1375
+ throw takeObject(r2);
1376
+ }
1377
+ deferred4_0 = ptr3;
1378
+ deferred4_1 = len3;
1379
+ return getStringFromWasm0(ptr3, len3);
1380
+ } finally {
1381
+ wasm.__wbindgen_add_to_stack_pointer(16);
1382
+ wasm.__wbindgen_export(deferred4_0, deferred4_1, 1);
1383
+ }
1384
+ }
1385
+
1386
+ /**
1387
+ * Read a vector dataset, reproject it to `dst_epsg`, and return GeoJSON.
1388
+ * Uses the bundled pure-Rust projection engine (full EPSG support).
1389
+ *
1390
+ * `src_epsg` overrides the source CRS: pass `0` to use the layer's own CRS, or
1391
+ * fall back to EPSG:4326 if it declares none (GeoJSON is WGS84 by RFC 7946).
1392
+ * @param {Uint8Array} data
1393
+ * @param {string} format
1394
+ * @param {number} dst_epsg
1395
+ * @param {number} src_epsg
1396
+ * @returns {string}
1397
+ */
1398
+ export function vector_to_geojson_reproject(data, format, dst_epsg, src_epsg) {
1399
+ let deferred4_0;
1400
+ let deferred4_1;
1401
+ try {
1402
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1403
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
1404
+ const len0 = WASM_VECTOR_LEN;
1405
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1406
+ const len1 = WASM_VECTOR_LEN;
1407
+ wasm.vector_to_geojson_reproject(retptr, ptr0, len0, ptr1, len1, dst_epsg, src_epsg);
1408
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1409
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1410
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1411
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1412
+ var ptr3 = r0;
1413
+ var len3 = r1;
1414
+ if (r3) {
1415
+ ptr3 = 0; len3 = 0;
1416
+ throw takeObject(r2);
1417
+ }
1418
+ deferred4_0 = ptr3;
1419
+ deferred4_1 = len3;
1420
+ return getStringFromWasm0(ptr3, len3);
1421
+ } finally {
1422
+ wasm.__wbindgen_add_to_stack_pointer(16);
1423
+ wasm.__wbindgen_export(deferred4_0, deferred4_1, 1);
1424
+ }
1425
+ }
1426
+
1074
1427
  /**
1075
1428
  * Semantic version of this crate, exposed for runtime feature detection.
1076
1429
  * @returns {string}
Binary file