geo-polygonize 0.36.2 → 0.39.2

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.
Files changed (51) hide show
  1. package/README.md +9 -3
  2. package/dist/geo_polygonize.wasm +0 -0
  3. package/dist/geo_polygonize_simd.wasm +0 -0
  4. package/dist/slim/cjs/bindings/PolygonizerOptions.d.ts +1 -1
  5. package/dist/slim/cjs/bindings/SnapStrategy.d.ts +9 -19
  6. package/dist/slim/cjs/index.d.ts +0 -1
  7. package/dist/slim/cjs/index_slim.d.ts +0 -1
  8. package/dist/slim/cjs/index_slim.js +1 -1
  9. package/dist/slim/cjs/index_threads.d.ts +0 -1
  10. package/dist/slim/es/bindings/PolygonizerOptions.d.ts +1 -1
  11. package/dist/slim/es/bindings/SnapStrategy.d.ts +9 -19
  12. package/dist/slim/es/index.d.ts +0 -1
  13. package/dist/slim/es/index_slim.d.ts +0 -1
  14. package/dist/slim/es/index_slim.js +1 -1
  15. package/dist/slim/es/index_threads.d.ts +0 -1
  16. package/dist/slim/pkg-scalar/geo_polygonize.d.ts +1 -1
  17. package/dist/slim/pkg-wrapper/bindings/PolygonizerOptions.d.ts +1 -1
  18. package/dist/slim/pkg-wrapper/bindings/SnapStrategy.d.ts +9 -19
  19. package/dist/standard/cjs/bindings/PolygonizerOptions.d.ts +1 -1
  20. package/dist/standard/cjs/bindings/SnapStrategy.d.ts +9 -19
  21. package/dist/standard/cjs/index.d.ts +0 -1
  22. package/dist/standard/cjs/index.js +3 -3
  23. package/dist/standard/cjs/index_slim.d.ts +0 -1
  24. package/dist/standard/cjs/index_threads.d.ts +0 -1
  25. package/dist/standard/es/bindings/PolygonizerOptions.d.ts +1 -1
  26. package/dist/standard/es/bindings/SnapStrategy.d.ts +9 -19
  27. package/dist/standard/es/index.d.ts +0 -1
  28. package/dist/standard/es/index.js +3 -3
  29. package/dist/standard/es/index_slim.d.ts +0 -1
  30. package/dist/standard/es/index_threads.d.ts +0 -1
  31. package/dist/standard/pkg-scalar/geo_polygonize.d.ts +1 -1
  32. package/dist/standard/pkg-wrapper/bindings/PolygonizerOptions.d.ts +1 -1
  33. package/dist/standard/pkg-wrapper/bindings/SnapStrategy.d.ts +9 -19
  34. package/dist/threads/es/bindings/PolygonizerOptions.d.ts +1 -1
  35. package/dist/threads/es/bindings/SnapStrategy.d.ts +9 -19
  36. package/dist/threads/es/index.d.ts +0 -1
  37. package/dist/threads/es/index.js +1 -1
  38. package/dist/threads/es/index_slim.d.ts +0 -1
  39. package/dist/threads/es/index_threads.d.ts +0 -1
  40. package/dist/threads/pkg-threads/geo_polygonize.d.ts +1 -1
  41. package/dist/threads/pkg-wrapper/bindings/PolygonizerOptions.d.ts +1 -1
  42. package/dist/threads/pkg-wrapper/bindings/SnapStrategy.d.ts +9 -19
  43. package/package.json +1 -1
  44. package/dist/slim/cjs/bindings/TilingOptions.d.ts +0 -6
  45. package/dist/slim/es/bindings/TilingOptions.d.ts +0 -6
  46. package/dist/slim/pkg-wrapper/bindings/TilingOptions.d.ts +0 -6
  47. package/dist/standard/cjs/bindings/TilingOptions.d.ts +0 -6
  48. package/dist/standard/es/bindings/TilingOptions.d.ts +0 -6
  49. package/dist/standard/pkg-wrapper/bindings/TilingOptions.d.ts +0 -6
  50. package/dist/threads/es/bindings/TilingOptions.d.ts +0 -6
  51. package/dist/threads/pkg-wrapper/bindings/TilingOptions.d.ts +0 -6
package/README.md CHANGED
@@ -9,10 +9,10 @@ A native Rust port of the JTS/GEOS polygonization algorithm. This crate allows y
9
9
  - **Robust Polygonization**: Extracts polygons from unstructured linework.
10
10
  - **Robust Noding**: Implements **Iterated Snap Rounding (ISR)** to guarantee topological correctness on dirty inputs (self-intersections, overlaps).
11
11
  - **Hardware Acceleration**: Uses **SIMD** instructions (via `wide` crate) for critical geometric predicates like Point-in-Polygon checks.
12
- - **Wasm Optimized**: Tailored for WebAssembly with `talc` allocator and Zero-Copy data support (`geoarrow`).
12
+ - **Wasm Optimized**: Tailored for WebAssembly with `talc` allocator and binary GeoArrow support.
13
13
  - **Performance**: Competitive with GEOS/Shapely (C++), outperforming it on random sparse inputs and scaling well on dense grids.
14
14
  - **Geo Ecosystem**: Fully integrated with `geo-types` and `geo` crates.
15
- - **GeoArrow Support**: Zero-copy data transfer via Arrow C Data Interface and Arrow IPC (Wasm).
15
+ - **GeoArrow Support**: Arrow C Data Interface and Arrow IPC integration with GeoArrow metadata.
16
16
 
17
17
  ## Engineering Roadmap
18
18
 
@@ -110,7 +110,7 @@ for p in polygons:
110
110
  print(p.area)
111
111
 
112
112
  # 2. Using High-Performance Flat Arrays
113
- # Perfect for zero-copy integrations or massive datasets
113
+ # Flat buffers avoid Python object-per-coordinate overhead
114
114
  coords = np.array([
115
115
  0.0, 0.0, 10.0, 0.0, 10.0, 10.0, 0.0, 10.0, 0.0, 0.0,
116
116
  0.0, 0.0, 10.0, 10.0
@@ -145,6 +145,12 @@ The default return shape is a stable dictionary with `polygons` as
145
145
  `SimplePolygon` values. Use `return_polygons=True` only when you want Shapely
146
146
  `Polygon` objects.
147
147
 
148
+ `SnapStrategy::Grid` keeps topology and output coordinates on the configured
149
+ precision grid. The CFB profile uses `GeosCompat`: the grid establishes robust
150
+ topology, then output nodes regain deterministic source coordinates to better
151
+ match Shapely `snap` plus full-precision noding. It is not `set_precision`
152
+ emulation, and exact parity is not guaranteed for many-to-one snaps.
153
+
148
154
  For Shapely parity checks, compare report-mode outputs with the built-in
149
155
  mismatch helper:
150
156
 
Binary file
Binary file
@@ -49,7 +49,7 @@ export type PolygonizerOptions = {
49
49
  */
50
50
  extract_only_polygonal: boolean;
51
51
  /**
52
- * The underlying strategy to apply when snapping coordinate geometries.
52
+ * Controls robust snap noding and output coordinate handling.
53
53
  *
54
54
  * See `SnapStrategy` for differences between strict `Grid` snapping and
55
55
  * Shapely/GEOS `GeosCompat` strategies.
@@ -1,25 +1,15 @@
1
1
  /**
2
- * Strategy for snapping coordinates to a grid.
2
+ * Strategy for robust snap noding and output coordinates.
3
3
  *
4
- * `Grid` applies a standard round-to-nearest integer grid policy `(coord / size).round() * size`.
5
- * `GeosCompat` attempts to emulate GEOS / Shapely's `set_precision` behavior, which uses
6
- * C++ std::round (rounding halfway cases away from zero).
4
+ * `Grid` uses the precision grid for both topology and output coordinates.
5
+ * `GeosCompat` uses the grid for topology, then restores one deterministic nearest source
6
+ * coordinate per snapped node. This targets Shapely-style `snap` followed by full-precision
7
+ * noding and polygonization; it does not emulate `set_precision` output.
7
8
  *
8
9
  * **Scale Guidance:**
9
- * Use `Grid` for native Rust applications where absolute topological determinism and
10
- * intuitive rounding is preferred.
11
- * Use `GeosCompat` if you are using `geo-polygonize` to replace a Shapely / GEOS pipeline
12
- * and require exact parity for edge cases at precision boundaries.
13
- *
14
- * **Expected Parity:**
15
- * Rust's native `f64::round()` rounds halfway cases away from zero. This perfectly
16
- * matches C++ `std::round` behavior, meaning that `Grid` and `GeosCompat` currently
17
- * map identical values for basic single-coordinate precision points (e.g., `-0.5` => `-1.0`
18
- * and `0.5` => `1.0`).
19
- *
20
- * **Expected Divergence:**
21
- * The divergence between `Grid` and `GeosCompat` strategies typically arises under complex
22
- * topological scaling sequences rather than simple single point coordinate rounding, but
23
- * the option ensures the library remains semantically compatible with Python/C++ GEOS pipelines.
10
+ * Use `Grid` when an explicit precision model is the desired output contract.
11
+ * Use `GeosCompat` when the grid is a robustness aid but source-coordinate fidelity matters.
12
+ * Both strategies are deterministic; exact GEOS/Shapely parity is not guaranteed for
13
+ * degenerate or many-to-one snaps.
24
14
  */
25
15
  export type SnapStrategy = "Grid" | "GeosCompat";
@@ -9,7 +9,6 @@ export * from "./bindings/NodingOptions";
9
9
  export * from "./bindings/ProvenanceOptions";
10
10
  export * from "./bindings/SnapStrategy";
11
11
  export * from "./bindings/TileOwnershipPolicy";
12
- export * from "./bindings/TilingOptions";
13
12
  export * from "./bindings/TouchPolicy";
14
13
  export * from "./cfb";
15
14
  export default function init(_input?: any): Promise<typeof exports>;
@@ -9,7 +9,6 @@ export * from "./bindings/NodingOptions";
9
9
  export * from "./bindings/ProvenanceOptions";
10
10
  export * from "./bindings/SnapStrategy";
11
11
  export * from "./bindings/TileOwnershipPolicy";
12
- export * from "./bindings/TilingOptions";
13
12
  export * from "./bindings/TouchPolicy";
14
13
  export * from "./cfb";
15
14
  export declare function initBest(scalarModule: any, simdModule?: any): Promise<typeof scalarExports>;
@@ -219,7 +219,7 @@ function polygonize(geojson_str, node_input, snap_grid_size, extract_only_polygo
219
219
  /**
220
220
  * Polygonizes an Arrow IPC stream containing a GeoArrow LineString array.
221
221
  *
222
- * This zero-copy path avoids JSON serialization overhead and returns a binary
222
+ * This binary path avoids JSON serialization overhead and returns an
223
223
  * Arrow IPC stream containing a GeoArrow Polygon array. Requires the options
224
224
  * to be passed as a parsed JS object.
225
225
  * @param {Uint8Array} ipc_bytes
@@ -9,7 +9,6 @@ export * from "./bindings/NodingOptions";
9
9
  export * from "./bindings/ProvenanceOptions";
10
10
  export * from "./bindings/SnapStrategy";
11
11
  export * from "./bindings/TileOwnershipPolicy";
12
- export * from "./bindings/TilingOptions";
13
12
  export * from "./bindings/TouchPolicy";
14
13
  export * from "./cfb";
15
14
  export default init;
@@ -49,7 +49,7 @@ export type PolygonizerOptions = {
49
49
  */
50
50
  extract_only_polygonal: boolean;
51
51
  /**
52
- * The underlying strategy to apply when snapping coordinate geometries.
52
+ * Controls robust snap noding and output coordinate handling.
53
53
  *
54
54
  * See `SnapStrategy` for differences between strict `Grid` snapping and
55
55
  * Shapely/GEOS `GeosCompat` strategies.
@@ -1,25 +1,15 @@
1
1
  /**
2
- * Strategy for snapping coordinates to a grid.
2
+ * Strategy for robust snap noding and output coordinates.
3
3
  *
4
- * `Grid` applies a standard round-to-nearest integer grid policy `(coord / size).round() * size`.
5
- * `GeosCompat` attempts to emulate GEOS / Shapely's `set_precision` behavior, which uses
6
- * C++ std::round (rounding halfway cases away from zero).
4
+ * `Grid` uses the precision grid for both topology and output coordinates.
5
+ * `GeosCompat` uses the grid for topology, then restores one deterministic nearest source
6
+ * coordinate per snapped node. This targets Shapely-style `snap` followed by full-precision
7
+ * noding and polygonization; it does not emulate `set_precision` output.
7
8
  *
8
9
  * **Scale Guidance:**
9
- * Use `Grid` for native Rust applications where absolute topological determinism and
10
- * intuitive rounding is preferred.
11
- * Use `GeosCompat` if you are using `geo-polygonize` to replace a Shapely / GEOS pipeline
12
- * and require exact parity for edge cases at precision boundaries.
13
- *
14
- * **Expected Parity:**
15
- * Rust's native `f64::round()` rounds halfway cases away from zero. This perfectly
16
- * matches C++ `std::round` behavior, meaning that `Grid` and `GeosCompat` currently
17
- * map identical values for basic single-coordinate precision points (e.g., `-0.5` => `-1.0`
18
- * and `0.5` => `1.0`).
19
- *
20
- * **Expected Divergence:**
21
- * The divergence between `Grid` and `GeosCompat` strategies typically arises under complex
22
- * topological scaling sequences rather than simple single point coordinate rounding, but
23
- * the option ensures the library remains semantically compatible with Python/C++ GEOS pipelines.
10
+ * Use `Grid` when an explicit precision model is the desired output contract.
11
+ * Use `GeosCompat` when the grid is a robustness aid but source-coordinate fidelity matters.
12
+ * Both strategies are deterministic; exact GEOS/Shapely parity is not guaranteed for
13
+ * degenerate or many-to-one snaps.
24
14
  */
25
15
  export type SnapStrategy = "Grid" | "GeosCompat";
@@ -9,7 +9,6 @@ export * from "./bindings/NodingOptions";
9
9
  export * from "./bindings/ProvenanceOptions";
10
10
  export * from "./bindings/SnapStrategy";
11
11
  export * from "./bindings/TileOwnershipPolicy";
12
- export * from "./bindings/TilingOptions";
13
12
  export * from "./bindings/TouchPolicy";
14
13
  export * from "./cfb";
15
14
  export default function init(_input?: any): Promise<typeof exports>;
@@ -9,7 +9,6 @@ export * from "./bindings/NodingOptions";
9
9
  export * from "./bindings/ProvenanceOptions";
10
10
  export * from "./bindings/SnapStrategy";
11
11
  export * from "./bindings/TileOwnershipPolicy";
12
- export * from "./bindings/TilingOptions";
13
12
  export * from "./bindings/TouchPolicy";
14
13
  export * from "./cfb";
15
14
  export declare function initBest(scalarModule: any, simdModule?: any): Promise<typeof scalarExports>;
@@ -216,7 +216,7 @@ function polygonize(geojson_str, node_input, snap_grid_size, extract_only_polygo
216
216
  /**
217
217
  * Polygonizes an Arrow IPC stream containing a GeoArrow LineString array.
218
218
  *
219
- * This zero-copy path avoids JSON serialization overhead and returns a binary
219
+ * This binary path avoids JSON serialization overhead and returns an
220
220
  * Arrow IPC stream containing a GeoArrow Polygon array. Requires the options
221
221
  * to be passed as a parsed JS object.
222
222
  * @param {Uint8Array} ipc_bytes
@@ -9,7 +9,6 @@ export * from "./bindings/NodingOptions";
9
9
  export * from "./bindings/ProvenanceOptions";
10
10
  export * from "./bindings/SnapStrategy";
11
11
  export * from "./bindings/TileOwnershipPolicy";
12
- export * from "./bindings/TilingOptions";
13
12
  export * from "./bindings/TouchPolicy";
14
13
  export * from "./cfb";
15
14
  export default init;
@@ -35,7 +35,7 @@ export function polygonize(geojson_str: string, node_input?: boolean | null, sna
35
35
  /**
36
36
  * Polygonizes an Arrow IPC stream containing a GeoArrow LineString array.
37
37
  *
38
- * This zero-copy path avoids JSON serialization overhead and returns a binary
38
+ * This binary path avoids JSON serialization overhead and returns an
39
39
  * Arrow IPC stream containing a GeoArrow Polygon array. Requires the options
40
40
  * to be passed as a parsed JS object.
41
41
  */
@@ -49,7 +49,7 @@ export type PolygonizerOptions = {
49
49
  */
50
50
  extract_only_polygonal: boolean;
51
51
  /**
52
- * The underlying strategy to apply when snapping coordinate geometries.
52
+ * Controls robust snap noding and output coordinate handling.
53
53
  *
54
54
  * See `SnapStrategy` for differences between strict `Grid` snapping and
55
55
  * Shapely/GEOS `GeosCompat` strategies.
@@ -1,25 +1,15 @@
1
1
  /**
2
- * Strategy for snapping coordinates to a grid.
2
+ * Strategy for robust snap noding and output coordinates.
3
3
  *
4
- * `Grid` applies a standard round-to-nearest integer grid policy `(coord / size).round() * size`.
5
- * `GeosCompat` attempts to emulate GEOS / Shapely's `set_precision` behavior, which uses
6
- * C++ std::round (rounding halfway cases away from zero).
4
+ * `Grid` uses the precision grid for both topology and output coordinates.
5
+ * `GeosCompat` uses the grid for topology, then restores one deterministic nearest source
6
+ * coordinate per snapped node. This targets Shapely-style `snap` followed by full-precision
7
+ * noding and polygonization; it does not emulate `set_precision` output.
7
8
  *
8
9
  * **Scale Guidance:**
9
- * Use `Grid` for native Rust applications where absolute topological determinism and
10
- * intuitive rounding is preferred.
11
- * Use `GeosCompat` if you are using `geo-polygonize` to replace a Shapely / GEOS pipeline
12
- * and require exact parity for edge cases at precision boundaries.
13
- *
14
- * **Expected Parity:**
15
- * Rust's native `f64::round()` rounds halfway cases away from zero. This perfectly
16
- * matches C++ `std::round` behavior, meaning that `Grid` and `GeosCompat` currently
17
- * map identical values for basic single-coordinate precision points (e.g., `-0.5` => `-1.0`
18
- * and `0.5` => `1.0`).
19
- *
20
- * **Expected Divergence:**
21
- * The divergence between `Grid` and `GeosCompat` strategies typically arises under complex
22
- * topological scaling sequences rather than simple single point coordinate rounding, but
23
- * the option ensures the library remains semantically compatible with Python/C++ GEOS pipelines.
10
+ * Use `Grid` when an explicit precision model is the desired output contract.
11
+ * Use `GeosCompat` when the grid is a robustness aid but source-coordinate fidelity matters.
12
+ * Both strategies are deterministic; exact GEOS/Shapely parity is not guaranteed for
13
+ * degenerate or many-to-one snaps.
24
14
  */
25
15
  export type SnapStrategy = "Grid" | "GeosCompat";
@@ -49,7 +49,7 @@ export type PolygonizerOptions = {
49
49
  */
50
50
  extract_only_polygonal: boolean;
51
51
  /**
52
- * The underlying strategy to apply when snapping coordinate geometries.
52
+ * Controls robust snap noding and output coordinate handling.
53
53
  *
54
54
  * See `SnapStrategy` for differences between strict `Grid` snapping and
55
55
  * Shapely/GEOS `GeosCompat` strategies.
@@ -1,25 +1,15 @@
1
1
  /**
2
- * Strategy for snapping coordinates to a grid.
2
+ * Strategy for robust snap noding and output coordinates.
3
3
  *
4
- * `Grid` applies a standard round-to-nearest integer grid policy `(coord / size).round() * size`.
5
- * `GeosCompat` attempts to emulate GEOS / Shapely's `set_precision` behavior, which uses
6
- * C++ std::round (rounding halfway cases away from zero).
4
+ * `Grid` uses the precision grid for both topology and output coordinates.
5
+ * `GeosCompat` uses the grid for topology, then restores one deterministic nearest source
6
+ * coordinate per snapped node. This targets Shapely-style `snap` followed by full-precision
7
+ * noding and polygonization; it does not emulate `set_precision` output.
7
8
  *
8
9
  * **Scale Guidance:**
9
- * Use `Grid` for native Rust applications where absolute topological determinism and
10
- * intuitive rounding is preferred.
11
- * Use `GeosCompat` if you are using `geo-polygonize` to replace a Shapely / GEOS pipeline
12
- * and require exact parity for edge cases at precision boundaries.
13
- *
14
- * **Expected Parity:**
15
- * Rust's native `f64::round()` rounds halfway cases away from zero. This perfectly
16
- * matches C++ `std::round` behavior, meaning that `Grid` and `GeosCompat` currently
17
- * map identical values for basic single-coordinate precision points (e.g., `-0.5` => `-1.0`
18
- * and `0.5` => `1.0`).
19
- *
20
- * **Expected Divergence:**
21
- * The divergence between `Grid` and `GeosCompat` strategies typically arises under complex
22
- * topological scaling sequences rather than simple single point coordinate rounding, but
23
- * the option ensures the library remains semantically compatible with Python/C++ GEOS pipelines.
10
+ * Use `Grid` when an explicit precision model is the desired output contract.
11
+ * Use `GeosCompat` when the grid is a robustness aid but source-coordinate fidelity matters.
12
+ * Both strategies are deterministic; exact GEOS/Shapely parity is not guaranteed for
13
+ * degenerate or many-to-one snaps.
24
14
  */
25
15
  export type SnapStrategy = "Grid" | "GeosCompat";
@@ -9,7 +9,6 @@ export * from "./bindings/NodingOptions";
9
9
  export * from "./bindings/ProvenanceOptions";
10
10
  export * from "./bindings/SnapStrategy";
11
11
  export * from "./bindings/TileOwnershipPolicy";
12
- export * from "./bindings/TilingOptions";
13
12
  export * from "./bindings/TouchPolicy";
14
13
  export * from "./cfb";
15
14
  export default function init(_input?: any): Promise<typeof exports>;