vibespatial.constructive.set_precision

GPU-accelerated set_precision: grid snapping + topology cleanup.

Replaces shapely.set_precision() with a zero-D2H GPU pipeline.

Pipeline stages:
  1. Grid quantization (Tier 2 CuPy): snap coordinates to grid_size multiples

  2. Deduplication (reuse remove_repeated_points): remove coincident points

  3. Topology cleanup (valid_output mode): make_valid for full repair

Three modes:
  • pointwise: snap only, no topology cleanup (fastest)

  • keep_collapsed: snap + dedup, keep degenerate geometries

  • valid_output (default): snap + dedup + make_valid topology repair

ADR-0033: Tier 2 CuPy for element-wise coordinate quantization (round/multiply).

Reuses existing Tier 1 NVRTC remove_repeated_points kernel for dedup. Reuses existing make_valid_owned pipeline for topology repair.

ADR-0002: CONSTRUCTIVE class – stays fp64 on all devices per policy.

PrecisionPlan wired through for observability only.

Attributes

Functions

set_precision_owned(...)

Set precision (grid snap + topology cleanup) for geometries.

Module Contents

vibespatial.constructive.set_precision.cp = None
vibespatial.constructive.set_precision.logger
vibespatial.constructive.set_precision.set_precision_owned(owned: vibespatial.geometry.owned.OwnedGeometryArray, grid_size: float, mode: str = 'valid_output', *, dispatch_mode: vibespatial.runtime.ExecutionMode | str = ExecutionMode.AUTO, precision: vibespatial.runtime.precision.PrecisionMode | str = PrecisionMode.AUTO) vibespatial.geometry.owned.OwnedGeometryArray

Set precision (grid snap + topology cleanup) for geometries.

Snaps all coordinates to multiples of grid_size and optionally removes degenerate features and repairs topology.

Parameters

ownedOwnedGeometryArray

Input geometries.

grid_sizefloat

Grid resolution. Coordinates are snapped to the nearest multiple. If 0, returns the input unchanged (Shapely-compatible no-op).

modestr

One of "valid_output" (default), "pointwise", or "keep_collapsed".

dispatch_modeExecutionMode

Execution mode selection (AUTO / CPU / GPU).

precisionPrecisionMode

Precision mode selection (AUTO / FP32 / FP64).

Returns

OwnedGeometryArray

New geometry array with snapped coordinates.