vibespatial.spatial.nearest

Classes

DistanceStrategy

Base class for GPU distance computation strategies.

PointPointDistanceStrategy

Compute point-to-point distances via the inline NVRTC kernel.

PointFamilyDistanceStrategy

Compute point-to-{line, polygon, ...} distances via point_distance kernels.

SegmentFamilyDistanceStrategy

Compute non-point-to-non-point distances via segment_distance kernels.

Functions

nearest_spatial_index(→ tuple[Any, str])

Find nearest tree geometry for each query geometry.

Module Contents

class vibespatial.spatial.nearest.DistanceStrategy

Base class for GPU distance computation strategies.

Each subclass knows how to compute pairwise distances for a specific combination of query/tree geometry families.

abstractmethod compute(query_owned: vibespatial.geometry.owned.OwnedGeometryArray, tree_owned: vibespatial.geometry.owned.OwnedGeometryArray, d_left, d_right, d_distances, pair_count: int, *, exclusive: bool = False) bool

Compute distances for candidate pairs on GPU.

Writes results into d_distances. Returns True on success, False if the family combination is not supported.

move_to_device(query_owned: vibespatial.geometry.owned.OwnedGeometryArray, tree_owned: vibespatial.geometry.owned.OwnedGeometryArray, *, query_reason: str, tree_reason: str)

Move both geometry arrays to device.

class vibespatial.spatial.nearest.PointPointDistanceStrategy

Compute point-to-point distances via the inline NVRTC kernel.

compute(query_owned: vibespatial.geometry.owned.OwnedGeometryArray, tree_owned: vibespatial.geometry.owned.OwnedGeometryArray, d_left, d_right, d_distances, pair_count: int, *, exclusive: bool = False) bool

Compute distances for candidate pairs on GPU.

Writes results into d_distances. Returns True on success, False if the family combination is not supported.

class vibespatial.spatial.nearest.PointFamilyDistanceStrategy(tree_family: vibespatial.geometry.buffers.GeometryFamily)

Compute point-to-{line, polygon, …} distances via point_distance kernels.

tree_family
compute(query_owned: vibespatial.geometry.owned.OwnedGeometryArray, tree_owned: vibespatial.geometry.owned.OwnedGeometryArray, d_left, d_right, d_distances, pair_count: int, *, exclusive: bool = False) bool

Compute distances for candidate pairs on GPU.

Writes results into d_distances. Returns True on success, False if the family combination is not supported.

class vibespatial.spatial.nearest.SegmentFamilyDistanceStrategy(query_family: vibespatial.geometry.buffers.GeometryFamily, tree_family: vibespatial.geometry.buffers.GeometryFamily)

Compute non-point-to-non-point distances via segment_distance kernels.

query_family
tree_family
compute(query_owned: vibespatial.geometry.owned.OwnedGeometryArray, tree_owned: vibespatial.geometry.owned.OwnedGeometryArray, d_left, d_right, d_distances, pair_count: int, *, exclusive: bool = False) bool

Compute distances for candidate pairs on GPU.

Writes results into d_distances. Returns True on success, False if the family combination is not supported.

vibespatial.spatial.nearest.nearest_spatial_index(tree_geometries: numpy.ndarray, geometry: Any, *, tree_query_nearest, return_all: bool = True, max_distance: float | None = None, return_distance: bool = False, exclusive: bool = False) tuple[Any, str]

Find nearest tree geometry for each query geometry.

Returns (result, implementation) where implementation is one of "strtree_host", "owned_gpu_nearest", or "owned_cpu_nearest".