pub trait SpatialBackend<T, C, const D: usize>: Send + Syncwhere
C: CoordType,{
// Required methods
fn insert(&mut self, point: Point<C, D>, payload: T) -> EntryId;
fn remove(&mut self, id: EntryId) -> Option<T>;
fn range_query(&self, bbox: &BBox<C, D>) -> Vec<(EntryId, &T)>;
fn knn_query(
&self,
point: &Point<C, D>,
k: usize,
) -> Vec<(f64, EntryId, &T)>;
fn spatial_join(
&self,
other: &dyn SpatialBackend<T, C, D>,
) -> Vec<(EntryId, EntryId)>;
fn bulk_load(entries: Vec<(Point<C, D>, T)>) -> Self
where Self: Sized;
fn len(&self) -> usize;
fn kind(&self) -> BackendKind;
fn all_entries(&self) -> Vec<(Point<C, D>, EntryId, &T)>;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Required Methods§
Sourcefn insert(&mut self, point: Point<C, D>, payload: T) -> EntryId
fn insert(&mut self, point: Point<C, D>, payload: T) -> EntryId
Insert a point with an associated payload. Returns the unique EntryId
assigned to this entry.
Sourcefn remove(&mut self, id: EntryId) -> Option<T>
fn remove(&mut self, id: EntryId) -> Option<T>
Remove the entry with the given EntryId. Returns the payload if the
entry existed, or None otherwise.
Sourcefn range_query(&self, bbox: &BBox<C, D>) -> Vec<(EntryId, &T)>
fn range_query(&self, bbox: &BBox<C, D>) -> Vec<(EntryId, &T)>
Return all entries whose positions are contained within bbox.
Sourcefn knn_query(&self, point: &Point<C, D>, k: usize) -> Vec<(f64, EntryId, &T)>
fn knn_query(&self, point: &Point<C, D>, k: usize) -> Vec<(f64, EntryId, &T)>
Return the k nearest entries to point, ordered by ascending
Euclidean distance. Each result is (distance, id, payload_ref).
Sourcefn spatial_join(
&self,
other: &dyn SpatialBackend<T, C, D>,
) -> Vec<(EntryId, EntryId)>
fn spatial_join( &self, other: &dyn SpatialBackend<T, C, D>, ) -> Vec<(EntryId, EntryId)>
Return all pairs (id_a, id_b) where the bounding box of entry id_a
in self intersects the bounding box of entry id_b in other.
For point-only backends the “bounding box” of a point is the degenerate
box [p, p].
Sourcefn bulk_load(entries: Vec<(Point<C, D>, T)>) -> Selfwhere
Self: Sized,
fn bulk_load(entries: Vec<(Point<C, D>, T)>) -> Selfwhere
Self: Sized,
Bulk-load a set of (point, payload) pairs into a new backend instance.
Implementations may sort entries (e.g. by Hilbert index) for better spatial locality.
Sourcefn kind(&self) -> BackendKind
fn kind(&self) -> BackendKind
Return the BackendKind discriminant for this backend.