geolibre-wasm 1.2.1 → 1.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 +27 -0
- package/geolibre-cli.wasm +0 -0
- package/geolibre_wasm.d.ts +174 -0
- package/geolibre_wasm.js +553 -0
- package/geolibre_wasm_bg.wasm +0 -0
- package/geolibre_wasm_bg.wasm.d.ts +29 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,6 +49,33 @@ const meta = JSON.parse(geotiff_info(tiffBytes));
|
|
|
49
49
|
Classes include `GeoTiffReader` (parse once, read many), `CogBuilder` (encode
|
|
50
50
|
Cloud Optimized GeoTIFFs), and `CogStream` (range-request tiled COG reading).
|
|
51
51
|
|
|
52
|
+
### Vector data as binary, not GeoJSON
|
|
53
|
+
|
|
54
|
+
`vector_to_geojson` returns a string, so the consumer pays for `JSON.parse` plus
|
|
55
|
+
a re-encode into typed arrays before anything reaches the GPU. Two binary paths
|
|
56
|
+
skip both steps, reading the same formats through the same reader
|
|
57
|
+
(`geojson`, `topojson`, `gml`, `gpx`, `kml`, `flatgeobuf`, `geopackage`,
|
|
58
|
+
`geoparquet`, `kmz` -- see `vector_formats()`):
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import init, { vector_to_binary, vector_to_arrow_ipc } from "geolibre-wasm";
|
|
62
|
+
await init();
|
|
63
|
+
|
|
64
|
+
// deck.gl binary attributes: Float64Array positions + Uint32Array indices.
|
|
65
|
+
const b = vector_to_binary(bytes, "geoparquet");
|
|
66
|
+
b.point_positions(); // Float64Array, position_size values per vertex
|
|
67
|
+
b.numeric_column(0); // Float64Array, one value per feature
|
|
68
|
+
JSON.parse(b.schema_json); // [{name, type}, ...]
|
|
69
|
+
b.free();
|
|
70
|
+
|
|
71
|
+
// GeoArrow record batch for apache-arrow, DuckDB-WASM, @geoarrow/deck.gl-layers.
|
|
72
|
+
const ipc = vector_to_arrow_ipc(bytes, "flatgeobuf"); // Uint8Array
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Reprojecting variants (`vector_to_binary_reproject`,
|
|
76
|
+
`vector_to_arrow_ipc_reproject`) take `dst_epsg` and `src_epsg`, where `0`
|
|
77
|
+
means "use the layer's own CRS".
|
|
78
|
+
|
|
52
79
|
## Tools usage (`./tools`)
|
|
53
80
|
|
|
54
81
|
```js
|
package/geolibre-cli.wasm
CHANGED
|
Binary file
|
package/geolibre_wasm.d.ts
CHANGED
|
@@ -314,6 +314,120 @@ export class PmtilesExtractor {
|
|
|
314
314
|
readonly done: boolean;
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
/**
|
|
318
|
+
* A layer's geometry and attributes as flat typed arrays.
|
|
319
|
+
*
|
|
320
|
+
* Produced by [`vector_to_binary`]. Every accessor copies into a fresh
|
|
321
|
+
* JavaScript typed array, so read each one once and keep the reference.
|
|
322
|
+
*/
|
|
323
|
+
export class VectorBinary {
|
|
324
|
+
private constructor();
|
|
325
|
+
free(): void;
|
|
326
|
+
[Symbol.dispose](): void;
|
|
327
|
+
/**
|
|
328
|
+
* Per line vertex: index into the line feature list.
|
|
329
|
+
*/
|
|
330
|
+
line_feature_ids(): Uint32Array;
|
|
331
|
+
/**
|
|
332
|
+
* Per line feature: its index in the whole layer.
|
|
333
|
+
*/
|
|
334
|
+
line_feature_index(): Uint32Array;
|
|
335
|
+
/**
|
|
336
|
+
* Per line vertex: index into the whole layer.
|
|
337
|
+
*/
|
|
338
|
+
line_global_feature_ids(): Uint32Array;
|
|
339
|
+
/**
|
|
340
|
+
* Vertex offsets delimiting each path; ends at the total vertex count.
|
|
341
|
+
*/
|
|
342
|
+
line_path_indices(): Uint32Array;
|
|
343
|
+
/**
|
|
344
|
+
* Line positions, `position_size` values per vertex.
|
|
345
|
+
*/
|
|
346
|
+
line_positions(): Float64Array;
|
|
347
|
+
/**
|
|
348
|
+
* Field `index` as one `f64` per feature: integers and floats as-is,
|
|
349
|
+
* booleans as 1/0, everything else (including nulls) as `NaN`.
|
|
350
|
+
*/
|
|
351
|
+
numeric_column(index: number): Float64Array;
|
|
352
|
+
/**
|
|
353
|
+
* Per point vertex: index into the point feature list.
|
|
354
|
+
*/
|
|
355
|
+
point_feature_ids(): Uint32Array;
|
|
356
|
+
/**
|
|
357
|
+
* Per point feature: its index in the whole layer.
|
|
358
|
+
*/
|
|
359
|
+
point_feature_index(): Uint32Array;
|
|
360
|
+
/**
|
|
361
|
+
* Per point vertex: index into the whole layer.
|
|
362
|
+
*/
|
|
363
|
+
point_global_feature_ids(): Uint32Array;
|
|
364
|
+
/**
|
|
365
|
+
* Point positions, `position_size` values per vertex.
|
|
366
|
+
*/
|
|
367
|
+
point_positions(): Float64Array;
|
|
368
|
+
/**
|
|
369
|
+
* Per polygon vertex: index into the polygon feature list.
|
|
370
|
+
*/
|
|
371
|
+
polygon_feature_ids(): Uint32Array;
|
|
372
|
+
/**
|
|
373
|
+
* Per polygon feature: its index in the whole layer.
|
|
374
|
+
*/
|
|
375
|
+
polygon_feature_index(): Uint32Array;
|
|
376
|
+
/**
|
|
377
|
+
* Per polygon vertex: index into the whole layer.
|
|
378
|
+
*/
|
|
379
|
+
polygon_global_feature_ids(): Uint32Array;
|
|
380
|
+
/**
|
|
381
|
+
* Vertex offsets delimiting each whole polygon.
|
|
382
|
+
*/
|
|
383
|
+
polygon_indices(): Uint32Array;
|
|
384
|
+
/**
|
|
385
|
+
* Polygon positions, `position_size` values per vertex.
|
|
386
|
+
*/
|
|
387
|
+
polygon_positions(): Float64Array;
|
|
388
|
+
/**
|
|
389
|
+
* Vertex offsets delimiting each ring (exterior and holes alike).
|
|
390
|
+
*/
|
|
391
|
+
polygon_primitive_polygon_indices(): Uint32Array;
|
|
392
|
+
/**
|
|
393
|
+
* Field `index` as UTF-8 bytes for every feature, concatenated. Split it
|
|
394
|
+
* with [`Self::text_column_offsets`]. Non-text values are stringified;
|
|
395
|
+
* nulls are empty.
|
|
396
|
+
*/
|
|
397
|
+
text_column(index: number): Uint8Array;
|
|
398
|
+
/**
|
|
399
|
+
* Byte offsets into [`Self::text_column`], `feature_count + 1` entries.
|
|
400
|
+
*/
|
|
401
|
+
text_column_offsets(index: number): Uint32Array;
|
|
402
|
+
/**
|
|
403
|
+
* Bounds as `[min_x, min_y, max_x, max_y]`, or an empty array when the
|
|
404
|
+
* layer has no geometry.
|
|
405
|
+
*/
|
|
406
|
+
readonly bbox: Float64Array;
|
|
407
|
+
/**
|
|
408
|
+
* EPSG code of the layer's CRS, if it declares one.
|
|
409
|
+
*/
|
|
410
|
+
readonly epsg: number | undefined;
|
|
411
|
+
/**
|
|
412
|
+
* Number of features in the source layer.
|
|
413
|
+
*/
|
|
414
|
+
readonly feature_count: number;
|
|
415
|
+
/**
|
|
416
|
+
* Number of attribute fields.
|
|
417
|
+
*/
|
|
418
|
+
readonly field_count: number;
|
|
419
|
+
/**
|
|
420
|
+
* Values per vertex in every `positions` array: 2, or 3 when any geometry
|
|
421
|
+
* carries a Z coordinate.
|
|
422
|
+
*/
|
|
423
|
+
readonly position_size: number;
|
|
424
|
+
/**
|
|
425
|
+
* Attribute schema as JSON: `[{"name":...,"type":...}, ...]`. Field values
|
|
426
|
+
* themselves come from [`Self::numeric_column`] / [`Self::text_column`].
|
|
427
|
+
*/
|
|
428
|
+
readonly schema_json: string;
|
|
429
|
+
}
|
|
430
|
+
|
|
317
431
|
/**
|
|
318
432
|
* Install a panic hook so Rust panics surface as readable `console.error`
|
|
319
433
|
* messages instead of an opaque `RuntimeError: unreachable`.
|
|
@@ -417,6 +531,37 @@ export function vector_formats(): string;
|
|
|
417
531
|
*/
|
|
418
532
|
export function vector_info(data: Uint8Array, format: string): string;
|
|
419
533
|
|
|
534
|
+
/**
|
|
535
|
+
* Read a vector dataset and return it as a GeoArrow-encoded Arrow IPC stream.
|
|
536
|
+
*
|
|
537
|
+
* `format` accepts the same names as [`crate::vector::vector_formats`]. Feed
|
|
538
|
+
* the bytes to `tableFromIPC` (apache-arrow) or
|
|
539
|
+
* `insertArrowFromIPCStream` (DuckDB-WASM).
|
|
540
|
+
*/
|
|
541
|
+
export function vector_to_arrow_ipc(data: Uint8Array, format: string): Uint8Array;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Read a vector dataset, reproject it to `dst_epsg`, and return a GeoArrow
|
|
545
|
+
* Arrow IPC stream. `src_epsg` of `0` uses the layer's own CRS (falling back
|
|
546
|
+
* to EPSG:4326).
|
|
547
|
+
*/
|
|
548
|
+
export function vector_to_arrow_ipc_reproject(data: Uint8Array, format: string, dst_epsg: number, src_epsg: number): Uint8Array;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Read a vector dataset and return its geometry and attributes as flat typed
|
|
552
|
+
* arrays — no GeoJSON string, no `JSON.parse`.
|
|
553
|
+
*
|
|
554
|
+
* `format` accepts the same names as [`crate::vector::vector_formats`].
|
|
555
|
+
*/
|
|
556
|
+
export function vector_to_binary(data: Uint8Array, format: string): VectorBinary;
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Read a vector dataset, reproject it to `dst_epsg`, and return flat typed
|
|
560
|
+
* arrays. `src_epsg` of `0` uses the layer's own CRS (falling back to
|
|
561
|
+
* EPSG:4326), matching [`crate::vector::vector_to_geojson_reproject`].
|
|
562
|
+
*/
|
|
563
|
+
export function vector_to_binary_reproject(data: Uint8Array, format: string, dst_epsg: number, src_epsg: number): VectorBinary;
|
|
564
|
+
|
|
420
565
|
/**
|
|
421
566
|
* Read a vector dataset and return it as a GeoJSON `FeatureCollection` string.
|
|
422
567
|
*/
|
|
@@ -445,6 +590,7 @@ export interface InitOutput {
|
|
|
445
590
|
readonly __wbg_cogstream_free: (a: number, b: number) => void;
|
|
446
591
|
readonly __wbg_geotiffreader_free: (a: number, b: number) => void;
|
|
447
592
|
readonly __wbg_pmtilesextractor_free: (a: number, b: number) => void;
|
|
593
|
+
readonly __wbg_vectorbinary_free: (a: number, b: number) => void;
|
|
448
594
|
readonly cogbuilder_new: (a: number, b: number, c: number) => number;
|
|
449
595
|
readonly cogbuilder_set_bigtiff: (a: number, b: number) => void;
|
|
450
596
|
readonly cogbuilder_set_compression: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -525,8 +671,36 @@ export interface InitOutput {
|
|
|
525
671
|
readonly transform_points_epsg: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
526
672
|
readonly vector_formats: (a: number) => void;
|
|
527
673
|
readonly vector_info: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
674
|
+
readonly vector_to_arrow_ipc: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
675
|
+
readonly vector_to_arrow_ipc_reproject: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
676
|
+
readonly vector_to_binary: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
677
|
+
readonly vector_to_binary_reproject: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
528
678
|
readonly vector_to_geojson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
529
679
|
readonly vector_to_geojson_reproject: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
680
|
+
readonly vectorbinary_bbox: (a: number, b: number) => void;
|
|
681
|
+
readonly vectorbinary_epsg: (a: number) => number;
|
|
682
|
+
readonly vectorbinary_feature_count: (a: number) => number;
|
|
683
|
+
readonly vectorbinary_field_count: (a: number) => number;
|
|
684
|
+
readonly vectorbinary_line_feature_ids: (a: number, b: number) => void;
|
|
685
|
+
readonly vectorbinary_line_feature_index: (a: number, b: number) => void;
|
|
686
|
+
readonly vectorbinary_line_global_feature_ids: (a: number, b: number) => void;
|
|
687
|
+
readonly vectorbinary_line_path_indices: (a: number, b: number) => void;
|
|
688
|
+
readonly vectorbinary_line_positions: (a: number, b: number) => void;
|
|
689
|
+
readonly vectorbinary_numeric_column: (a: number, b: number, c: number) => void;
|
|
690
|
+
readonly vectorbinary_point_feature_ids: (a: number, b: number) => void;
|
|
691
|
+
readonly vectorbinary_point_feature_index: (a: number, b: number) => void;
|
|
692
|
+
readonly vectorbinary_point_global_feature_ids: (a: number, b: number) => void;
|
|
693
|
+
readonly vectorbinary_point_positions: (a: number, b: number) => void;
|
|
694
|
+
readonly vectorbinary_polygon_feature_ids: (a: number, b: number) => void;
|
|
695
|
+
readonly vectorbinary_polygon_feature_index: (a: number, b: number) => void;
|
|
696
|
+
readonly vectorbinary_polygon_global_feature_ids: (a: number, b: number) => void;
|
|
697
|
+
readonly vectorbinary_polygon_indices: (a: number, b: number) => void;
|
|
698
|
+
readonly vectorbinary_polygon_positions: (a: number, b: number) => void;
|
|
699
|
+
readonly vectorbinary_polygon_primitive_polygon_indices: (a: number, b: number) => void;
|
|
700
|
+
readonly vectorbinary_position_size: (a: number) => number;
|
|
701
|
+
readonly vectorbinary_schema_json: (a: number, b: number) => void;
|
|
702
|
+
readonly vectorbinary_text_column: (a: number, b: number, c: number) => void;
|
|
703
|
+
readonly vectorbinary_text_column_offsets: (a: number, b: number, c: number) => void;
|
|
530
704
|
readonly version: (a: number) => void;
|
|
531
705
|
readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
532
706
|
readonly rust_zstd_wasm_shim_free: (a: number) => void;
|
package/geolibre_wasm.js
CHANGED
|
@@ -1290,6 +1290,431 @@ export class PmtilesExtractor {
|
|
|
1290
1290
|
}
|
|
1291
1291
|
if (Symbol.dispose) PmtilesExtractor.prototype[Symbol.dispose] = PmtilesExtractor.prototype.free;
|
|
1292
1292
|
|
|
1293
|
+
/**
|
|
1294
|
+
* A layer's geometry and attributes as flat typed arrays.
|
|
1295
|
+
*
|
|
1296
|
+
* Produced by [`vector_to_binary`]. Every accessor copies into a fresh
|
|
1297
|
+
* JavaScript typed array, so read each one once and keep the reference.
|
|
1298
|
+
*/
|
|
1299
|
+
export class VectorBinary {
|
|
1300
|
+
static __wrap(ptr) {
|
|
1301
|
+
const obj = Object.create(VectorBinary.prototype);
|
|
1302
|
+
obj.__wbg_ptr = ptr;
|
|
1303
|
+
VectorBinaryFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1304
|
+
return obj;
|
|
1305
|
+
}
|
|
1306
|
+
__destroy_into_raw() {
|
|
1307
|
+
const ptr = this.__wbg_ptr;
|
|
1308
|
+
this.__wbg_ptr = 0;
|
|
1309
|
+
VectorBinaryFinalization.unregister(this);
|
|
1310
|
+
return ptr;
|
|
1311
|
+
}
|
|
1312
|
+
free() {
|
|
1313
|
+
const ptr = this.__destroy_into_raw();
|
|
1314
|
+
wasm.__wbg_vectorbinary_free(ptr, 0);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Bounds as `[min_x, min_y, max_x, max_y]`, or an empty array when the
|
|
1318
|
+
* layer has no geometry.
|
|
1319
|
+
* @returns {Float64Array}
|
|
1320
|
+
*/
|
|
1321
|
+
get bbox() {
|
|
1322
|
+
try {
|
|
1323
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1324
|
+
wasm.vectorbinary_bbox(retptr, this.__wbg_ptr);
|
|
1325
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1326
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1327
|
+
var v1 = getArrayF64FromWasm0(r0, r1).slice();
|
|
1328
|
+
wasm.__wbindgen_export(r0, r1 * 8, 8);
|
|
1329
|
+
return v1;
|
|
1330
|
+
} finally {
|
|
1331
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* EPSG code of the layer's CRS, if it declares one.
|
|
1336
|
+
* @returns {number | undefined}
|
|
1337
|
+
*/
|
|
1338
|
+
get epsg() {
|
|
1339
|
+
const ret = wasm.vectorbinary_epsg(this.__wbg_ptr);
|
|
1340
|
+
return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Number of features in the source layer.
|
|
1344
|
+
* @returns {number}
|
|
1345
|
+
*/
|
|
1346
|
+
get feature_count() {
|
|
1347
|
+
const ret = wasm.vectorbinary_feature_count(this.__wbg_ptr);
|
|
1348
|
+
return ret >>> 0;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Number of attribute fields.
|
|
1352
|
+
* @returns {number}
|
|
1353
|
+
*/
|
|
1354
|
+
get field_count() {
|
|
1355
|
+
const ret = wasm.vectorbinary_field_count(this.__wbg_ptr);
|
|
1356
|
+
return ret >>> 0;
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Per line vertex: index into the line feature list.
|
|
1360
|
+
* @returns {Uint32Array}
|
|
1361
|
+
*/
|
|
1362
|
+
line_feature_ids() {
|
|
1363
|
+
try {
|
|
1364
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1365
|
+
wasm.vectorbinary_line_feature_ids(retptr, this.__wbg_ptr);
|
|
1366
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1367
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1368
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1369
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1370
|
+
return v1;
|
|
1371
|
+
} finally {
|
|
1372
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Per line feature: its index in the whole layer.
|
|
1377
|
+
* @returns {Uint32Array}
|
|
1378
|
+
*/
|
|
1379
|
+
line_feature_index() {
|
|
1380
|
+
try {
|
|
1381
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1382
|
+
wasm.vectorbinary_line_feature_index(retptr, this.__wbg_ptr);
|
|
1383
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1384
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1385
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1386
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1387
|
+
return v1;
|
|
1388
|
+
} finally {
|
|
1389
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Per line vertex: index into the whole layer.
|
|
1394
|
+
* @returns {Uint32Array}
|
|
1395
|
+
*/
|
|
1396
|
+
line_global_feature_ids() {
|
|
1397
|
+
try {
|
|
1398
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1399
|
+
wasm.vectorbinary_line_global_feature_ids(retptr, this.__wbg_ptr);
|
|
1400
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1401
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1402
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1403
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1404
|
+
return v1;
|
|
1405
|
+
} finally {
|
|
1406
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Vertex offsets delimiting each path; ends at the total vertex count.
|
|
1411
|
+
* @returns {Uint32Array}
|
|
1412
|
+
*/
|
|
1413
|
+
line_path_indices() {
|
|
1414
|
+
try {
|
|
1415
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1416
|
+
wasm.vectorbinary_line_path_indices(retptr, this.__wbg_ptr);
|
|
1417
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1418
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1419
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1420
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1421
|
+
return v1;
|
|
1422
|
+
} finally {
|
|
1423
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Line positions, `position_size` values per vertex.
|
|
1428
|
+
* @returns {Float64Array}
|
|
1429
|
+
*/
|
|
1430
|
+
line_positions() {
|
|
1431
|
+
try {
|
|
1432
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1433
|
+
wasm.vectorbinary_line_positions(retptr, this.__wbg_ptr);
|
|
1434
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1435
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1436
|
+
var v1 = getArrayF64FromWasm0(r0, r1).slice();
|
|
1437
|
+
wasm.__wbindgen_export(r0, r1 * 8, 8);
|
|
1438
|
+
return v1;
|
|
1439
|
+
} finally {
|
|
1440
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Field `index` as one `f64` per feature: integers and floats as-is,
|
|
1445
|
+
* booleans as 1/0, everything else (including nulls) as `NaN`.
|
|
1446
|
+
* @param {number} index
|
|
1447
|
+
* @returns {Float64Array}
|
|
1448
|
+
*/
|
|
1449
|
+
numeric_column(index) {
|
|
1450
|
+
try {
|
|
1451
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1452
|
+
wasm.vectorbinary_numeric_column(retptr, this.__wbg_ptr, index);
|
|
1453
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1454
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1455
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1456
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1457
|
+
if (r3) {
|
|
1458
|
+
throw takeObject(r2);
|
|
1459
|
+
}
|
|
1460
|
+
var v1 = getArrayF64FromWasm0(r0, r1).slice();
|
|
1461
|
+
wasm.__wbindgen_export(r0, r1 * 8, 8);
|
|
1462
|
+
return v1;
|
|
1463
|
+
} finally {
|
|
1464
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Per point vertex: index into the point feature list.
|
|
1469
|
+
* @returns {Uint32Array}
|
|
1470
|
+
*/
|
|
1471
|
+
point_feature_ids() {
|
|
1472
|
+
try {
|
|
1473
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1474
|
+
wasm.vectorbinary_point_feature_ids(retptr, this.__wbg_ptr);
|
|
1475
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1476
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1477
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1478
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1479
|
+
return v1;
|
|
1480
|
+
} finally {
|
|
1481
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Per point feature: its index in the whole layer.
|
|
1486
|
+
* @returns {Uint32Array}
|
|
1487
|
+
*/
|
|
1488
|
+
point_feature_index() {
|
|
1489
|
+
try {
|
|
1490
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1491
|
+
wasm.vectorbinary_point_feature_index(retptr, this.__wbg_ptr);
|
|
1492
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1493
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1494
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1495
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1496
|
+
return v1;
|
|
1497
|
+
} finally {
|
|
1498
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Per point vertex: index into the whole layer.
|
|
1503
|
+
* @returns {Uint32Array}
|
|
1504
|
+
*/
|
|
1505
|
+
point_global_feature_ids() {
|
|
1506
|
+
try {
|
|
1507
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1508
|
+
wasm.vectorbinary_point_global_feature_ids(retptr, this.__wbg_ptr);
|
|
1509
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1510
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1511
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1512
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1513
|
+
return v1;
|
|
1514
|
+
} finally {
|
|
1515
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Point positions, `position_size` values per vertex.
|
|
1520
|
+
* @returns {Float64Array}
|
|
1521
|
+
*/
|
|
1522
|
+
point_positions() {
|
|
1523
|
+
try {
|
|
1524
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1525
|
+
wasm.vectorbinary_point_positions(retptr, this.__wbg_ptr);
|
|
1526
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1527
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1528
|
+
var v1 = getArrayF64FromWasm0(r0, r1).slice();
|
|
1529
|
+
wasm.__wbindgen_export(r0, r1 * 8, 8);
|
|
1530
|
+
return v1;
|
|
1531
|
+
} finally {
|
|
1532
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Per polygon vertex: index into the polygon feature list.
|
|
1537
|
+
* @returns {Uint32Array}
|
|
1538
|
+
*/
|
|
1539
|
+
polygon_feature_ids() {
|
|
1540
|
+
try {
|
|
1541
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1542
|
+
wasm.vectorbinary_polygon_feature_ids(retptr, this.__wbg_ptr);
|
|
1543
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1544
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1545
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1546
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1547
|
+
return v1;
|
|
1548
|
+
} finally {
|
|
1549
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Per polygon feature: its index in the whole layer.
|
|
1554
|
+
* @returns {Uint32Array}
|
|
1555
|
+
*/
|
|
1556
|
+
polygon_feature_index() {
|
|
1557
|
+
try {
|
|
1558
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1559
|
+
wasm.vectorbinary_polygon_feature_index(retptr, this.__wbg_ptr);
|
|
1560
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1561
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1562
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1563
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1564
|
+
return v1;
|
|
1565
|
+
} finally {
|
|
1566
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
/**
|
|
1570
|
+
* Per polygon vertex: index into the whole layer.
|
|
1571
|
+
* @returns {Uint32Array}
|
|
1572
|
+
*/
|
|
1573
|
+
polygon_global_feature_ids() {
|
|
1574
|
+
try {
|
|
1575
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1576
|
+
wasm.vectorbinary_polygon_global_feature_ids(retptr, this.__wbg_ptr);
|
|
1577
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1578
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1579
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1580
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1581
|
+
return v1;
|
|
1582
|
+
} finally {
|
|
1583
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Vertex offsets delimiting each whole polygon.
|
|
1588
|
+
* @returns {Uint32Array}
|
|
1589
|
+
*/
|
|
1590
|
+
polygon_indices() {
|
|
1591
|
+
try {
|
|
1592
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1593
|
+
wasm.vectorbinary_polygon_indices(retptr, this.__wbg_ptr);
|
|
1594
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1595
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1596
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1597
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1598
|
+
return v1;
|
|
1599
|
+
} finally {
|
|
1600
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Polygon positions, `position_size` values per vertex.
|
|
1605
|
+
* @returns {Float64Array}
|
|
1606
|
+
*/
|
|
1607
|
+
polygon_positions() {
|
|
1608
|
+
try {
|
|
1609
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1610
|
+
wasm.vectorbinary_polygon_positions(retptr, this.__wbg_ptr);
|
|
1611
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1612
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1613
|
+
var v1 = getArrayF64FromWasm0(r0, r1).slice();
|
|
1614
|
+
wasm.__wbindgen_export(r0, r1 * 8, 8);
|
|
1615
|
+
return v1;
|
|
1616
|
+
} finally {
|
|
1617
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Vertex offsets delimiting each ring (exterior and holes alike).
|
|
1622
|
+
* @returns {Uint32Array}
|
|
1623
|
+
*/
|
|
1624
|
+
polygon_primitive_polygon_indices() {
|
|
1625
|
+
try {
|
|
1626
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1627
|
+
wasm.vectorbinary_polygon_primitive_polygon_indices(retptr, this.__wbg_ptr);
|
|
1628
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1629
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1630
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1631
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1632
|
+
return v1;
|
|
1633
|
+
} finally {
|
|
1634
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Values per vertex in every `positions` array: 2, or 3 when any geometry
|
|
1639
|
+
* carries a Z coordinate.
|
|
1640
|
+
* @returns {number}
|
|
1641
|
+
*/
|
|
1642
|
+
get position_size() {
|
|
1643
|
+
const ret = wasm.vectorbinary_position_size(this.__wbg_ptr);
|
|
1644
|
+
return ret >>> 0;
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* Attribute schema as JSON: `[{"name":...,"type":...}, ...]`. Field values
|
|
1648
|
+
* themselves come from [`Self::numeric_column`] / [`Self::text_column`].
|
|
1649
|
+
* @returns {string}
|
|
1650
|
+
*/
|
|
1651
|
+
get schema_json() {
|
|
1652
|
+
let deferred1_0;
|
|
1653
|
+
let deferred1_1;
|
|
1654
|
+
try {
|
|
1655
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1656
|
+
wasm.vectorbinary_schema_json(retptr, this.__wbg_ptr);
|
|
1657
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1658
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1659
|
+
deferred1_0 = r0;
|
|
1660
|
+
deferred1_1 = r1;
|
|
1661
|
+
return getStringFromWasm0(r0, r1);
|
|
1662
|
+
} finally {
|
|
1663
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1664
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Field `index` as UTF-8 bytes for every feature, concatenated. Split it
|
|
1669
|
+
* with [`Self::text_column_offsets`]. Non-text values are stringified;
|
|
1670
|
+
* nulls are empty.
|
|
1671
|
+
* @param {number} index
|
|
1672
|
+
* @returns {Uint8Array}
|
|
1673
|
+
*/
|
|
1674
|
+
text_column(index) {
|
|
1675
|
+
try {
|
|
1676
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1677
|
+
wasm.vectorbinary_text_column(retptr, this.__wbg_ptr, index);
|
|
1678
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1679
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1680
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1681
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1682
|
+
if (r3) {
|
|
1683
|
+
throw takeObject(r2);
|
|
1684
|
+
}
|
|
1685
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1686
|
+
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
1687
|
+
return v1;
|
|
1688
|
+
} finally {
|
|
1689
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* Byte offsets into [`Self::text_column`], `feature_count + 1` entries.
|
|
1694
|
+
* @param {number} index
|
|
1695
|
+
* @returns {Uint32Array}
|
|
1696
|
+
*/
|
|
1697
|
+
text_column_offsets(index) {
|
|
1698
|
+
try {
|
|
1699
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1700
|
+
wasm.vectorbinary_text_column_offsets(retptr, this.__wbg_ptr, index);
|
|
1701
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1702
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1703
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1704
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1705
|
+
if (r3) {
|
|
1706
|
+
throw takeObject(r2);
|
|
1707
|
+
}
|
|
1708
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1709
|
+
wasm.__wbindgen_export(r0, r1 * 4, 4);
|
|
1710
|
+
return v1;
|
|
1711
|
+
} finally {
|
|
1712
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
if (Symbol.dispose) VectorBinary.prototype[Symbol.dispose] = VectorBinary.prototype.free;
|
|
1717
|
+
|
|
1293
1718
|
/**
|
|
1294
1719
|
* Install a panic hook so Rust panics surface as readable `console.error`
|
|
1295
1720
|
* messages instead of an opaque `RuntimeError: unreachable`.
|
|
@@ -1717,6 +2142,131 @@ export function vector_info(data, format) {
|
|
|
1717
2142
|
}
|
|
1718
2143
|
}
|
|
1719
2144
|
|
|
2145
|
+
/**
|
|
2146
|
+
* Read a vector dataset and return it as a GeoArrow-encoded Arrow IPC stream.
|
|
2147
|
+
*
|
|
2148
|
+
* `format` accepts the same names as [`crate::vector::vector_formats`]. Feed
|
|
2149
|
+
* the bytes to `tableFromIPC` (apache-arrow) or
|
|
2150
|
+
* `insertArrowFromIPCStream` (DuckDB-WASM).
|
|
2151
|
+
* @param {Uint8Array} data
|
|
2152
|
+
* @param {string} format
|
|
2153
|
+
* @returns {Uint8Array}
|
|
2154
|
+
*/
|
|
2155
|
+
export function vector_to_arrow_ipc(data, format) {
|
|
2156
|
+
try {
|
|
2157
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2158
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
|
|
2159
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2160
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
2161
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2162
|
+
wasm.vector_to_arrow_ipc(retptr, ptr0, len0, ptr1, len1);
|
|
2163
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2164
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2165
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2166
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2167
|
+
if (r3) {
|
|
2168
|
+
throw takeObject(r2);
|
|
2169
|
+
}
|
|
2170
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
2171
|
+
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
2172
|
+
return v3;
|
|
2173
|
+
} finally {
|
|
2174
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
/**
|
|
2179
|
+
* Read a vector dataset, reproject it to `dst_epsg`, and return a GeoArrow
|
|
2180
|
+
* Arrow IPC stream. `src_epsg` of `0` uses the layer's own CRS (falling back
|
|
2181
|
+
* to EPSG:4326).
|
|
2182
|
+
* @param {Uint8Array} data
|
|
2183
|
+
* @param {string} format
|
|
2184
|
+
* @param {number} dst_epsg
|
|
2185
|
+
* @param {number} src_epsg
|
|
2186
|
+
* @returns {Uint8Array}
|
|
2187
|
+
*/
|
|
2188
|
+
export function vector_to_arrow_ipc_reproject(data, format, dst_epsg, src_epsg) {
|
|
2189
|
+
try {
|
|
2190
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2191
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
|
|
2192
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2193
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
2194
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2195
|
+
wasm.vector_to_arrow_ipc_reproject(retptr, ptr0, len0, ptr1, len1, dst_epsg, src_epsg);
|
|
2196
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2197
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2198
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2199
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
2200
|
+
if (r3) {
|
|
2201
|
+
throw takeObject(r2);
|
|
2202
|
+
}
|
|
2203
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
2204
|
+
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
2205
|
+
return v3;
|
|
2206
|
+
} finally {
|
|
2207
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
/**
|
|
2212
|
+
* Read a vector dataset and return its geometry and attributes as flat typed
|
|
2213
|
+
* arrays — no GeoJSON string, no `JSON.parse`.
|
|
2214
|
+
*
|
|
2215
|
+
* `format` accepts the same names as [`crate::vector::vector_formats`].
|
|
2216
|
+
* @param {Uint8Array} data
|
|
2217
|
+
* @param {string} format
|
|
2218
|
+
* @returns {VectorBinary}
|
|
2219
|
+
*/
|
|
2220
|
+
export function vector_to_binary(data, format) {
|
|
2221
|
+
try {
|
|
2222
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2223
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
|
|
2224
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2225
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
2226
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2227
|
+
wasm.vector_to_binary(retptr, ptr0, len0, ptr1, len1);
|
|
2228
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2229
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2230
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2231
|
+
if (r2) {
|
|
2232
|
+
throw takeObject(r1);
|
|
2233
|
+
}
|
|
2234
|
+
return VectorBinary.__wrap(r0);
|
|
2235
|
+
} finally {
|
|
2236
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
/**
|
|
2241
|
+
* Read a vector dataset, reproject it to `dst_epsg`, and return flat typed
|
|
2242
|
+
* arrays. `src_epsg` of `0` uses the layer's own CRS (falling back to
|
|
2243
|
+
* EPSG:4326), matching [`crate::vector::vector_to_geojson_reproject`].
|
|
2244
|
+
* @param {Uint8Array} data
|
|
2245
|
+
* @param {string} format
|
|
2246
|
+
* @param {number} dst_epsg
|
|
2247
|
+
* @param {number} src_epsg
|
|
2248
|
+
* @returns {VectorBinary}
|
|
2249
|
+
*/
|
|
2250
|
+
export function vector_to_binary_reproject(data, format, dst_epsg, src_epsg) {
|
|
2251
|
+
try {
|
|
2252
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2253
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
|
|
2254
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2255
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
2256
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2257
|
+
wasm.vector_to_binary_reproject(retptr, ptr0, len0, ptr1, len1, dst_epsg, src_epsg);
|
|
2258
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2259
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2260
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2261
|
+
if (r2) {
|
|
2262
|
+
throw takeObject(r1);
|
|
2263
|
+
}
|
|
2264
|
+
return VectorBinary.__wrap(r0);
|
|
2265
|
+
} finally {
|
|
2266
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
|
|
1720
2270
|
/**
|
|
1721
2271
|
* Read a vector dataset and return it as a GeoJSON `FeatureCollection` string.
|
|
1722
2272
|
* @param {Uint8Array} data
|
|
@@ -1868,6 +2418,9 @@ const GeoTiffReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
1868
2418
|
const PmtilesExtractorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1869
2419
|
? { register: () => {}, unregister: () => {} }
|
|
1870
2420
|
: new FinalizationRegistry(ptr => wasm.__wbg_pmtilesextractor_free(ptr, 1));
|
|
2421
|
+
const VectorBinaryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2422
|
+
? { register: () => {}, unregister: () => {} }
|
|
2423
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_vectorbinary_free(ptr, 1));
|
|
1871
2424
|
|
|
1872
2425
|
function addHeapObject(obj) {
|
|
1873
2426
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
package/geolibre_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -6,6 +6,7 @@ export const __wbg_cogbuilder_free: (a: number, b: number) => void;
|
|
|
6
6
|
export const __wbg_cogstream_free: (a: number, b: number) => void;
|
|
7
7
|
export const __wbg_geotiffreader_free: (a: number, b: number) => void;
|
|
8
8
|
export const __wbg_pmtilesextractor_free: (a: number, b: number) => void;
|
|
9
|
+
export const __wbg_vectorbinary_free: (a: number, b: number) => void;
|
|
9
10
|
export const cogbuilder_new: (a: number, b: number, c: number) => number;
|
|
10
11
|
export const cogbuilder_set_bigtiff: (a: number, b: number) => void;
|
|
11
12
|
export const cogbuilder_set_compression: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -86,8 +87,36 @@ export const transform_bbox_epsg: (a: number, b: number, c: number, d: number, e
|
|
|
86
87
|
export const transform_points_epsg: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
87
88
|
export const vector_formats: (a: number) => void;
|
|
88
89
|
export const vector_info: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
90
|
+
export const vector_to_arrow_ipc: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
91
|
+
export const vector_to_arrow_ipc_reproject: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
92
|
+
export const vector_to_binary: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
93
|
+
export const vector_to_binary_reproject: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
89
94
|
export const vector_to_geojson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
90
95
|
export const vector_to_geojson_reproject: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
96
|
+
export const vectorbinary_bbox: (a: number, b: number) => void;
|
|
97
|
+
export const vectorbinary_epsg: (a: number) => number;
|
|
98
|
+
export const vectorbinary_feature_count: (a: number) => number;
|
|
99
|
+
export const vectorbinary_field_count: (a: number) => number;
|
|
100
|
+
export const vectorbinary_line_feature_ids: (a: number, b: number) => void;
|
|
101
|
+
export const vectorbinary_line_feature_index: (a: number, b: number) => void;
|
|
102
|
+
export const vectorbinary_line_global_feature_ids: (a: number, b: number) => void;
|
|
103
|
+
export const vectorbinary_line_path_indices: (a: number, b: number) => void;
|
|
104
|
+
export const vectorbinary_line_positions: (a: number, b: number) => void;
|
|
105
|
+
export const vectorbinary_numeric_column: (a: number, b: number, c: number) => void;
|
|
106
|
+
export const vectorbinary_point_feature_ids: (a: number, b: number) => void;
|
|
107
|
+
export const vectorbinary_point_feature_index: (a: number, b: number) => void;
|
|
108
|
+
export const vectorbinary_point_global_feature_ids: (a: number, b: number) => void;
|
|
109
|
+
export const vectorbinary_point_positions: (a: number, b: number) => void;
|
|
110
|
+
export const vectorbinary_polygon_feature_ids: (a: number, b: number) => void;
|
|
111
|
+
export const vectorbinary_polygon_feature_index: (a: number, b: number) => void;
|
|
112
|
+
export const vectorbinary_polygon_global_feature_ids: (a: number, b: number) => void;
|
|
113
|
+
export const vectorbinary_polygon_indices: (a: number, b: number) => void;
|
|
114
|
+
export const vectorbinary_polygon_positions: (a: number, b: number) => void;
|
|
115
|
+
export const vectorbinary_polygon_primitive_polygon_indices: (a: number, b: number) => void;
|
|
116
|
+
export const vectorbinary_position_size: (a: number) => number;
|
|
117
|
+
export const vectorbinary_schema_json: (a: number, b: number) => void;
|
|
118
|
+
export const vectorbinary_text_column: (a: number, b: number, c: number) => void;
|
|
119
|
+
export const vectorbinary_text_column_offsets: (a: number, b: number, c: number) => void;
|
|
91
120
|
export const version: (a: number) => void;
|
|
92
121
|
export const rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
93
122
|
export const rust_zstd_wasm_shim_free: (a: number) => void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geolibre-wasm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "Pure-Rust geospatial toolkit (whitebox_next_gen) compiled to WebAssembly (WASI) for GeoLibre's in-browser tool execution",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|