geo-polygonize 0.8.1 → 0.10.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.
@@ -105,6 +105,71 @@ function addToExternrefTable0(obj) {
105
105
  return idx;
106
106
  }
107
107
 
108
+ function debugString(val) {
109
+ // primitive types
110
+ const type = typeof val;
111
+ if (type == 'number' || type == 'boolean' || val == null) {
112
+ return `${val}`;
113
+ }
114
+ if (type == 'string') {
115
+ return `"${val}"`;
116
+ }
117
+ if (type == 'symbol') {
118
+ const description = val.description;
119
+ if (description == null) {
120
+ return 'Symbol';
121
+ } else {
122
+ return `Symbol(${description})`;
123
+ }
124
+ }
125
+ if (type == 'function') {
126
+ const name = val.name;
127
+ if (typeof name == 'string' && name.length > 0) {
128
+ return `Function(${name})`;
129
+ } else {
130
+ return 'Function';
131
+ }
132
+ }
133
+ // objects
134
+ if (Array.isArray(val)) {
135
+ const length = val.length;
136
+ let debug = '[';
137
+ if (length > 0) {
138
+ debug += debugString(val[0]);
139
+ }
140
+ for(let i = 1; i < length; i++) {
141
+ debug += ', ' + debugString(val[i]);
142
+ }
143
+ debug += ']';
144
+ return debug;
145
+ }
146
+ // Test for built-in
147
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
148
+ let className;
149
+ if (builtInMatches && builtInMatches.length > 1) {
150
+ className = builtInMatches[1];
151
+ } else {
152
+ // Failed to match the standard '[object ClassName]'
153
+ return toString.call(val);
154
+ }
155
+ if (className == 'Object') {
156
+ // we're a user defined class or Object
157
+ // JSON.stringify avoids problems with cycles, and is generally much
158
+ // easier than looping through ownProperties of `val`.
159
+ try {
160
+ return 'Object(' + JSON.stringify(val) + ')';
161
+ } catch (_) {
162
+ return 'Object';
163
+ }
164
+ }
165
+ // errors
166
+ if (val instanceof Error) {
167
+ return `${val.name}: ${val.message}\n${val.stack}`;
168
+ }
169
+ // TODO we could test for more things here, like `Set`s and `Map`s.
170
+ return className;
171
+ }
172
+
108
173
  function getArrayU8FromWasm0(ptr, len) {
109
174
  ptr = ptr >>> 0;
110
175
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -253,6 +318,10 @@ if (!('encodeInto' in cachedTextEncoder)) {
253
318
 
254
319
  let WASM_VECTOR_LEN = 0;
255
320
 
321
+ const PolygonizerWasmErrorFinalization = (typeof FinalizationRegistry === 'undefined')
322
+ ? { register: () => {}, unregister: () => {} }
323
+ : new FinalizationRegistry(ptr => wasm.__wbg_polygonizerwasmerror_free(ptr >>> 0, 1));
324
+
256
325
  const WasmPolygonResultFinalization = (typeof FinalizationRegistry === 'undefined')
257
326
  ? { register: () => {}, unregister: () => {} }
258
327
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmpolygonresult_free(ptr >>> 0, 1));
@@ -261,6 +330,71 @@ const wbg_rayon_PoolBuilderFinalization = (typeof FinalizationRegistry === 'unde
261
330
  ? { register: () => {}, unregister: () => {} }
262
331
  : new FinalizationRegistry(ptr => wasm.__wbg_wbg_rayon_poolbuilder_free(ptr >>> 0, 1));
263
332
 
333
+ class PolygonizerWasmError {
334
+ static __wrap(ptr) {
335
+ ptr = ptr >>> 0;
336
+ const obj = Object.create(PolygonizerWasmError.prototype);
337
+ obj.__wbg_ptr = ptr;
338
+ PolygonizerWasmErrorFinalization.register(obj, obj.__wbg_ptr, obj);
339
+ return obj;
340
+ }
341
+ __destroy_into_raw() {
342
+ const ptr = this.__wbg_ptr;
343
+ this.__wbg_ptr = 0;
344
+ PolygonizerWasmErrorFinalization.unregister(this);
345
+ return ptr;
346
+ }
347
+ free() {
348
+ const ptr = this.__destroy_into_raw();
349
+ wasm.__wbg_polygonizerwasmerror_free(ptr, 0);
350
+ }
351
+ /**
352
+ * @param {string} name
353
+ * @param {string} message
354
+ */
355
+ constructor(name, message) {
356
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
357
+ const len0 = WASM_VECTOR_LEN;
358
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
359
+ const len1 = WASM_VECTOR_LEN;
360
+ const ret = wasm.polygonizerwasmerror_new(ptr0, len0, ptr1, len1);
361
+ this.__wbg_ptr = ret >>> 0;
362
+ PolygonizerWasmErrorFinalization.register(this, this.__wbg_ptr, this);
363
+ return this;
364
+ }
365
+ /**
366
+ * @returns {string}
367
+ */
368
+ get name() {
369
+ let deferred1_0;
370
+ let deferred1_1;
371
+ try {
372
+ const ret = wasm.polygonizerwasmerror_name(this.__wbg_ptr);
373
+ deferred1_0 = ret[0];
374
+ deferred1_1 = ret[1];
375
+ return getStringFromWasm0(ret[0], ret[1]);
376
+ } finally {
377
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
378
+ }
379
+ }
380
+ /**
381
+ * @returns {string}
382
+ */
383
+ get message() {
384
+ let deferred1_0;
385
+ let deferred1_1;
386
+ try {
387
+ const ret = wasm.polygonizerwasmerror_message(this.__wbg_ptr);
388
+ deferred1_0 = ret[0];
389
+ deferred1_1 = ret[1];
390
+ return getStringFromWasm0(ret[0], ret[1]);
391
+ } finally {
392
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
393
+ }
394
+ }
395
+ }
396
+ if (Symbol.dispose) PolygonizerWasmError.prototype[Symbol.dispose] = PolygonizerWasmError.prototype.free;
397
+
264
398
  class WasmPolygonResult {
265
399
  static __wrap(ptr) {
266
400
  ptr = ptr >>> 0;
@@ -345,15 +479,42 @@ function initThreadPool(num_threads) {
345
479
  * @param {boolean | null} [node_input]
346
480
  * @param {number | null} [snap_grid_size]
347
481
  * @param {boolean | null} [extract_only_polygonal]
482
+ * @param {boolean | null} [report_mode]
483
+ * @returns {string}
484
+ */
485
+ function polygonize(geojson_str, node_input, snap_grid_size, extract_only_polygonal, report_mode) {
486
+ let deferred3_0;
487
+ let deferred3_1;
488
+ try {
489
+ const ptr0 = passStringToWasm0(geojson_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
490
+ const len0 = WASM_VECTOR_LEN;
491
+ const ret = wasm.polygonize(ptr0, len0, isLikeNone(node_input) ? 0xFFFFFF : node_input ? 1 : 0, !isLikeNone(snap_grid_size), isLikeNone(snap_grid_size) ? 0 : snap_grid_size, isLikeNone(extract_only_polygonal) ? 0xFFFFFF : extract_only_polygonal ? 1 : 0, isLikeNone(report_mode) ? 0xFFFFFF : report_mode ? 1 : 0);
492
+ var ptr2 = ret[0];
493
+ var len2 = ret[1];
494
+ if (ret[3]) {
495
+ ptr2 = 0; len2 = 0;
496
+ throw takeFromExternrefTable0(ret[2]);
497
+ }
498
+ deferred3_0 = ptr2;
499
+ deferred3_1 = len2;
500
+ return getStringFromWasm0(ptr2, len2);
501
+ } finally {
502
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
503
+ }
504
+ }
505
+
506
+ /**
507
+ * @param {string} geojson_str
508
+ * @param {any} options_val
348
509
  * @returns {string}
349
510
  */
350
- function polygonize(geojson_str, node_input, snap_grid_size, extract_only_polygonal) {
511
+ function polygonizeWithOptions(geojson_str, options_val) {
351
512
  let deferred3_0;
352
513
  let deferred3_1;
353
514
  try {
354
515
  const ptr0 = passStringToWasm0(geojson_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
355
516
  const len0 = WASM_VECTOR_LEN;
356
- const ret = wasm.polygonize(ptr0, len0, isLikeNone(node_input) ? 0xFFFFFF : node_input ? 1 : 0, !isLikeNone(snap_grid_size), isLikeNone(snap_grid_size) ? 0 : snap_grid_size, isLikeNone(extract_only_polygonal) ? 0xFFFFFF : extract_only_polygonal ? 1 : 0);
517
+ const ret = wasm.polygonizeWithOptions(ptr0, len0, options_val);
357
518
  var ptr2 = ret[0];
358
519
  var len2 = ret[1];
359
520
  if (ret[3]) {
@@ -368,6 +529,25 @@ function polygonize(geojson_str, node_input, snap_grid_size, extract_only_polygo
368
529
  }
369
530
  }
370
531
 
532
+ /**
533
+ * @param {Float64Array} coords
534
+ * @param {Uint32Array} offsets
535
+ * @param {number} stride
536
+ * @param {any} options_val
537
+ * @returns {WasmPolygonResult}
538
+ */
539
+ function polygonizeWithOptionsBuffer(coords, offsets, stride, options_val) {
540
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
541
+ const len0 = WASM_VECTOR_LEN;
542
+ const ptr1 = passArray32ToWasm0(offsets, wasm.__wbindgen_malloc);
543
+ const len1 = WASM_VECTOR_LEN;
544
+ const ret = wasm.polygonizeWithOptionsBuffer(ptr0, len0, ptr1, len1, stride, options_val);
545
+ if (ret[2]) {
546
+ throw takeFromExternrefTable0(ret[1]);
547
+ }
548
+ return WasmPolygonResult.__wrap(ret[0]);
549
+ }
550
+
371
551
  /**
372
552
  * @param {Float64Array} coords
373
553
  * @param {Uint32Array} offsets
@@ -487,10 +667,50 @@ async function __wbg_load(module, imports) {
487
667
  function __wbg_get_imports() {
488
668
  const imports = {};
489
669
  imports.wbg = {};
670
+ imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
671
+ const ret = Error(getStringFromWasm0(arg0, arg1));
672
+ return ret;
673
+ };
674
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
675
+ const ret = String(arg1);
676
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
677
+ const len1 = WASM_VECTOR_LEN;
678
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
679
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
680
+ };
681
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
682
+ const v = arg0;
683
+ const ret = typeof(v) === 'boolean' ? v : undefined;
684
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
685
+ };
686
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
687
+ const ret = debugString(arg1);
688
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
689
+ const len1 = WASM_VECTOR_LEN;
690
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
691
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
692
+ };
693
+ imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
694
+ const ret = arg0 in arg1;
695
+ return ret;
696
+ };
697
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
698
+ const val = arg0;
699
+ const ret = typeof(val) === 'object' && val !== null;
700
+ return ret;
701
+ };
702
+ imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
703
+ const ret = typeof(arg0) === 'string';
704
+ return ret;
705
+ };
490
706
  imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
491
707
  const ret = arg0 === undefined;
492
708
  return ret;
493
709
  };
710
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
711
+ const ret = arg0 == arg1;
712
+ return ret;
713
+ };
494
714
  imports.wbg.__wbg___wbindgen_memory_a342e963fbcabd68 = function() {
495
715
  const ret = wasm.memory;
496
716
  return ret;
@@ -499,6 +719,20 @@ function __wbg_get_imports() {
499
719
  const ret = __wbg_init.__wbindgen_wasm_module;
500
720
  return ret;
501
721
  };
722
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
723
+ const obj = arg1;
724
+ const ret = typeof(obj) === 'number' ? obj : undefined;
725
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
726
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
727
+ };
728
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
729
+ const obj = arg1;
730
+ const ret = typeof(obj) === 'string' ? obj : undefined;
731
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
732
+ var len1 = WASM_VECTOR_LEN;
733
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
734
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
735
+ };
502
736
  imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
503
737
  throw new Error(getStringFromWasm0(arg0, arg1));
504
738
  };
@@ -506,6 +740,10 @@ function __wbg_get_imports() {
506
740
  const ret = arg0.call(arg1);
507
741
  return ret;
508
742
  }, arguments) };
743
+ imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
744
+ const ret = Object.entries(arg0);
745
+ return ret;
746
+ };
509
747
  imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
510
748
  let deferred0_0;
511
749
  let deferred0_1;
@@ -517,6 +755,34 @@ function __wbg_get_imports() {
517
755
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
518
756
  }
519
757
  };
758
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
759
+ const ret = arg0[arg1 >>> 0];
760
+ return ret;
761
+ };
762
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
763
+ const ret = arg0[arg1];
764
+ return ret;
765
+ };
766
+ imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
767
+ let result;
768
+ try {
769
+ result = arg0 instanceof ArrayBuffer;
770
+ } catch (_) {
771
+ result = false;
772
+ }
773
+ const ret = result;
774
+ return ret;
775
+ };
776
+ imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
777
+ let result;
778
+ try {
779
+ result = arg0 instanceof Uint8Array;
780
+ } catch (_) {
781
+ result = false;
782
+ }
783
+ const ret = result;
784
+ return ret;
785
+ };
520
786
  imports.wbg.__wbg_instanceof_Window_b5cf7783caa68180 = function(arg0) {
521
787
  let result;
522
788
  try {
@@ -527,6 +793,18 @@ function __wbg_get_imports() {
527
793
  const ret = result;
528
794
  return ret;
529
795
  };
796
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
797
+ const ret = arg0.length;
798
+ return ret;
799
+ };
800
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
801
+ const ret = arg0.length;
802
+ return ret;
803
+ };
804
+ imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
805
+ const ret = new Uint8Array(arg0);
806
+ return ret;
807
+ };
530
808
  imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
531
809
  const ret = new Error();
532
810
  return ret;
@@ -535,6 +813,13 @@ function __wbg_get_imports() {
535
813
  const ret = new Function(getStringFromWasm0(arg0, arg1));
536
814
  return ret;
537
815
  };
816
+ imports.wbg.__wbg_polygonizerwasmerror_new = function(arg0) {
817
+ const ret = PolygonizerWasmError.__wrap(arg0);
818
+ return ret;
819
+ };
820
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
821
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
822
+ };
538
823
  imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
539
824
  const ret = arg1.stack;
540
825
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -641,15 +926,18 @@ async function __wbg_init(module_or_path) {
641
926
 
642
927
  var geo_polygonize = /*#__PURE__*/Object.freeze({
643
928
  __proto__: null,
929
+ PolygonizerWasmError: PolygonizerWasmError,
644
930
  WasmPolygonResult: WasmPolygonResult,
645
931
  default: __wbg_init,
646
932
  initSync: initSync,
647
933
  initThreadPool: initThreadPool,
648
934
  polygonize: polygonize,
935
+ polygonizeWithOptions: polygonizeWithOptions,
936
+ polygonizeWithOptionsBuffer: polygonizeWithOptionsBuffer,
649
937
  polygonize_buffers: polygonize_buffers,
650
938
  polygonize_geoarrow: polygonize_geoarrow,
651
939
  wbg_rayon_PoolBuilder: wbg_rayon_PoolBuilder,
652
940
  wbg_rayon_start_worker: wbg_rayon_start_worker
653
941
  });
654
942
 
655
- export { WasmPolygonResult, __wbg_init as default, initSync, initThreadPool, polygonize, polygonize_buffers, polygonize_geoarrow, wbg_rayon_PoolBuilder, wbg_rayon_start_worker };
943
+ export { PolygonizerWasmError, WasmPolygonResult, __wbg_init as default, initSync, initThreadPool, polygonize, polygonizeWithOptions, polygonizeWithOptionsBuffer, polygonize_buffers, polygonize_geoarrow, wbg_rayon_PoolBuilder, wbg_rayon_start_worker };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geo-polygonize",
3
- "version": "0.8.1",
3
+ "version": "0.10.0",
4
4
  "description": "A native Rust port of the JTS/GEOS polygonization algorithm (Wasm)",
5
5
  "type": "module",
6
6
  "scripts": {