vibespatial.spatial.distance_owned

On-device element-wise distance and dwithin for OwnedGeometryArray.

Orchestrates existing GPU distance kernels (point_distance, segment_distance, spatial_nearest point-point) for the public distance/dwithin API surface. Zero geometry H/D transfers when GPU is available – only small index arrays and the final result array cross the bus.

METRIC kernel class per ADR-0002. Precision dispatch is forwarded to point_distance (already METRIC-compliant); segment_distance stays fp64 (compliance gap tracked separately).

Functions

distance_owned(→ numpy.ndarray)

Element-wise distance between two OwnedGeometryArrays.

dwithin_owned(→ numpy.ndarray)

Element-wise dwithin: distance(left[i], right[i]) <= threshold.

evaluate_geopandas_dwithin(→ numpy.ndarray | None)

Try GPU-dispatched dwithin for GeometryArray inputs.

Module Contents

vibespatial.spatial.distance_owned.distance_owned(left: vibespatial.geometry.owned.OwnedGeometryArray, right: vibespatial.geometry.owned.OwnedGeometryArray, *, dispatch_mode: vibespatial.runtime.ExecutionMode | str = ExecutionMode.AUTO, precision: vibespatial.runtime.precision.PrecisionMode | str = PrecisionMode.AUTO) numpy.ndarray

Element-wise distance between two OwnedGeometryArrays.

Returns float64 array of length left.row_count. NaN for null geometries, inf when both geometries are empty.

On GPU: zero geometry H/D transfers. Only small index arrays and the final float64 result cross the bus.

vibespatial.spatial.distance_owned.dwithin_owned(left: vibespatial.geometry.owned.OwnedGeometryArray, right: vibespatial.geometry.owned.OwnedGeometryArray, threshold: float | numpy.ndarray, *, dispatch_mode: vibespatial.runtime.ExecutionMode | str = ExecutionMode.AUTO, precision: vibespatial.runtime.precision.PrecisionMode | str = PrecisionMode.AUTO) numpy.ndarray

Element-wise dwithin: distance(left[i], right[i]) <= threshold.

Returns boolean array. Null geometries produce False. threshold may be a scalar or per-row array.

vibespatial.spatial.distance_owned.evaluate_geopandas_dwithin(left: numpy.ndarray | vibespatial.geometry.owned.OwnedGeometryArray, right: object | numpy.ndarray | vibespatial.geometry.owned.OwnedGeometryArray, distance: float | numpy.ndarray) numpy.ndarray | None

Try GPU-dispatched dwithin for GeometryArray inputs.

Accepts either numpy arrays of Shapely objects or pre-built OwnedGeometryArrays. When OwnedGeometryArrays are provided the Shapely serialisation round-trip (and its H->D transfer) is skipped entirely.

Returns None when GPU dispatch is not selected (below crossover threshold or GPU unavailable), letting the caller fall back to Shapely.