Skip to main content

RTree

Struct RTree 

Source
pub struct RTree<T, C, const D: usize> { /* private fields */ }
Expand description

R*-tree spatial index.

Stores points with associated payloads and supports range queries, kNN queries, and spatial joins. Uses forced reinsertion on overflow and quadratic splits.

Implementations§

Source§

impl<T, C: CoordType, const D: usize> RTree<T, C, D>

Source

pub fn new() -> Self

Create an empty R-tree.

Source

pub fn insert_entry(&mut self, point: Point<C, D>, payload: T) -> EntryId

Source

pub fn remove_entry(&mut self, id: EntryId) -> Option<T>

Source

pub fn range_query_impl<'a>( &'a self, bbox: &BBox<C, D>, ) -> Vec<(EntryId, &'a T)>

Return all entries whose points lie within bbox.

Source

pub fn knn_query_impl<'a>( &'a self, point: &Point<C, D>, k: usize, ) -> Vec<(f64, EntryId, &'a T)>

Trait Implementations§

Source§

impl<T, C: CoordType, const D: usize> Default for RTree<T, C, D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Send + Sync + 'static, C: CoordType, const D: usize> SpatialBackend<T, C, D> for RTree<T, C, D>

Source§

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.
Source§

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.
Source§

fn range_query(&self, bbox: &BBox<C, D>) -> Vec<(EntryId, &T)>

Return all entries whose positions are contained within bbox.
Source§

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).
Source§

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. Read more
Source§

fn bulk_load(entries: Vec<(Point<C, D>, T)>) -> Self

Bulk-load a set of (point, payload) pairs into a new backend instance. Read more
Source§

fn len(&self) -> usize

Return the number of entries currently stored.
Source§

fn kind(&self) -> BackendKind

Return the BackendKind discriminant for this backend.
Source§

fn all_entries(&self) -> Vec<(Point<C, D>, EntryId, &T)>

Return all (point, id, payload) triples — used by spatial_join implementations that need to iterate over the other backend’s entries.
Source§

fn is_empty(&self) -> bool

Return true if the backend contains no entries.

Auto Trait Implementations§

§

impl<T, C, const D: usize> Freeze for RTree<T, C, D>

§

impl<T, C, const D: usize> RefUnwindSafe for RTree<T, C, D>

§

impl<T, C, const D: usize> Send for RTree<T, C, D>
where C: Send, T: Send,

§

impl<T, C, const D: usize> Sync for RTree<T, C, D>
where C: Sync, T: Sync,

§

impl<T, C, const D: usize> Unpin for RTree<T, C, D>
where C: Unpin,

§

impl<T, C, const D: usize> UnsafeUnpin for RTree<T, C, D>

§

impl<T, C, const D: usize> UnwindSafe for RTree<T, C, D>
where C: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.