Skip to main content

Rtree

Struct Rtree 

Source
pub struct Rtree<T: Indexable, Params: SplitParameters = Quadratic> { /* private fields */ }
Expand description

A spatial index over Indexable values, parameterised by a split strategy.

Mirrors boost::geometry::index::rtree<Value, Parameters> (index/rtree.hpp). The default split is Quadratic; pass Linear as Params for cheaper inserts.

§Examples

use geometry_cs::Cartesian;
use geometry_model::Point2D;
use geometry_rtree::Rtree;

type P = Point2D<f64, Cartesian>;
let mut tree: Rtree<P> = Rtree::new();
tree.insert(P::new(1.0, 1.0));
tree.insert(P::new(5.0, 5.0));
assert_eq!(tree.len(), 2);

Implementations§

Source§

impl<T: Indexable, Params: SplitParameters> Rtree<T, Params>

Source

pub fn new() -> Self

An empty tree.

Source

pub fn len(&self) -> usize

Number of values in the tree.

Source

pub fn is_empty(&self) -> bool

Whether the tree holds no values.

Source

pub fn height(&self) -> usize

The height of the tree (a single-leaf tree is height 1).

Source

pub fn insert(&mut self, value: T)

Insert one value.

Descends by least-enlargement to a leaf, inserts, and splits and propagates upward if a node overflows. Mirrors visitors/insert.hpp.

Source

pub fn query(&self, predicate: Predicate) -> Vec<&T>

Iterate every value whose bounds satisfy predicate.

Prunes subtrees whose bounds cannot match. Mirrors visitors/spatial_query.hpp.

Source

pub fn nearest(&self, query: [f64; 2], k: usize) -> Vec<&T>

The k values nearest to the query point, closest first.

Best-first search over node bounding boxes by minimum distance. Mirrors visitors/distance_query.hpp.

Trait Implementations§

Source§

impl<T: Debug + Indexable, Params: Debug + SplitParameters> Debug for Rtree<T, Params>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Indexable, Params: SplitParameters> Default for Rtree<T, Params>

Source§

fn default() -> Self

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

impl<T: Indexable, Params: SplitParameters> FromIterator<T> for Rtree<T, Params>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Bulk-load with Sort-Tile-Recursive packing: sort by x-centroid, slice into vertical strips, sort each strip by y-centroid, and pack leaves. Produces a balanced tree in one pass, the analogue of Boost’s pack_create (index/detail/rtree/pack_create.hpp).

Auto Trait Implementations§

§

impl<T, Params> Freeze for Rtree<T, Params>

§

impl<T, Params> RefUnwindSafe for Rtree<T, Params>
where Params: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, Params> Send for Rtree<T, Params>
where Params: Send, T: Send,

§

impl<T, Params> Sync for Rtree<T, Params>
where Params: Sync, T: Sync,

§

impl<T, Params> Unpin for Rtree<T, Params>
where Params: Unpin, T: Unpin,

§

impl<T, Params> UnsafeUnpin for Rtree<T, Params>

§

impl<T, Params> UnwindSafe for Rtree<T, Params>
where Params: 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> SameAs<T> for T

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.