vibespatial.spatial.distance_metrics

Hausdorff and discrete Frechet distance on OwnedGeometryArray pairs.

CPU brute-force implementations plus GPU NVRTC kernels that read directly from device-resident coordinate buffers, avoiding _ensure_host_state(). Only the small result array (N floats) transfers D->H at the end.

METRIC kernel class per ADR-0002. ADR-0033: Tier 1 NVRTC – geometry-specific inner loops (min-of-max, DP coupling) require custom kernels.

Attributes

Functions

hausdorff_distance_owned(→ numpy.ndarray)

Per-pair Hausdorff distance between two OwnedGeometryArrays.

frechet_distance_owned(→ numpy.ndarray)

Per-pair discrete Frechet distance between two OwnedGeometryArrays.

Module Contents

vibespatial.spatial.distance_metrics.cp = None
vibespatial.spatial.distance_metrics.logger
vibespatial.spatial.distance_metrics.hausdorff_distance_owned(owned_a: vibespatial.geometry.owned.OwnedGeometryArray, owned_b: vibespatial.geometry.owned.OwnedGeometryArray, densify: float | None = None) numpy.ndarray

Per-pair Hausdorff distance between two OwnedGeometryArrays.

Returns a float64 array of length owned_a.row_count. NaN for null or empty geometry rows.

The densify parameter is accepted for API compatibility but is not currently used by the CPU brute-force implementation (reserved for future GPU kernel densification).

Works directly on OwnedGeometryArray coordinate buffers – no Shapely round-trip.

vibespatial.spatial.distance_metrics.frechet_distance_owned(owned_a: vibespatial.geometry.owned.OwnedGeometryArray, owned_b: vibespatial.geometry.owned.OwnedGeometryArray, densify: float | None = None) numpy.ndarray

Per-pair discrete Frechet distance between two OwnedGeometryArrays.

Only works on LineString pairs. Other geometry types produce NaN. Returns a float64 array of length owned_a.row_count. NaN for null rows or non-LineString geometry types.

The densify parameter is accepted for API compatibility but is not currently used by the CPU implementation.

Works directly on OwnedGeometryArray coordinate buffers – no Shapely round-trip.