vibespatial.constructive.line_merge¶
GPU-accelerated line_merge: merge connected LineStrings into longer chains.
Replaces shapely.line_merge(data, directed=directed) with a fully
device-resident NVRTC implementation.
Architecture (ADR-0033 tier classification): - Tier 1 NVRTC: per-geometry endpoint graph construction and chain-following.
One thread per geometry. Graph data fits in thread-local arrays for typical MultiLineStrings (up to 256 parts).
Tier 3a CCCL: exclusive_sum for output offset computation.
Tier 2 CuPy: metadata array construction, element-wise operations.
Precision (ADR-0002): CONSTRUCTIVE class – stays fp64 on all devices. Coordinates are exact subsets of input (no arithmetic on coordinate values). PrecisionPlan wired through dispatch for observability.
Supports: - MultiLineString: merge connected parts into longer chains - LineString: returned as-is (single segment, trivial merge) - directed=True: only merge if endpoint == startpoint of next segment - directed=False: bidirectional endpoint matching (default) - Disconnected components: output MultiLineString with multiple parts - Rings (closed chains): detected via unvisited segments after open chains
Zero D2H transfers during computation.
Attributes¶
Functions¶
|
Merge connected LineStrings within each geometry. |
Module Contents¶
- vibespatial.constructive.line_merge.cp = None¶
- vibespatial.constructive.line_merge.logger¶
- vibespatial.constructive.line_merge.line_merge_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray, *, directed: bool = False, dispatch_mode: vibespatial.runtime.ExecutionMode | str = ExecutionMode.AUTO, precision: vibespatial.runtime.precision.PrecisionMode | str = PrecisionMode.AUTO) vibespatial.geometry.owned.OwnedGeometryArray¶
Merge connected LineStrings within each geometry.
For MultiLineString inputs, merges parts that share endpoints into longer LineString chains. Disconnected components produce a MultiLineString in the output.
Parameters¶
- ownedOwnedGeometryArray
Input geometries (LineString or MultiLineString).
- directedbool, default False
If True, only merge segments where endpoint == startpoint of next segment. If False, bidirectional endpoint matching.
- dispatch_modeExecutionMode or str, default AUTO
Execution mode hint.
- precisionPrecisionMode or str, default AUTO
Precision mode. CONSTRUCTIVE class stays fp64 per ADR-0002; wired for observability.
Returns¶
- OwnedGeometryArray
Merged geometries. Single-chain results are MultiLineString with one part; disconnected results have multiple parts.