[−][src]Struct spaceindex::rtree::RTree
Methods
impl<ND> RTree<ND>
[src]
pub fn new(dimension: usize) -> Self
[src]
Creates a new RTree
with the given number of dimensions.
Example
use spaceindex::rtree::RTree; let mut tree = RTree::new(2); tree.insert(((0.0, 0.0), (2.0, 4.0)), 1);
pub fn insert<'a, IR: IntoRegion<'a>>(
&mut self,
region: IR,
data: ND
) -> Result<(), ShapelikeError>
[src]
&mut self,
region: IR,
data: ND
) -> Result<(), ShapelikeError>
Attempts to insert a given object into the tree.
Errors
This function will return an error if region
does not have the same dimension as this tree.
Example
use spaceindex::rtree::RTree; let mut tree = RTree::new(2); tree.insert(((-1.0, 0.0), (3.0, 3.0)), 0);
pub fn validate_consistency(&self)
[src]
Validates the consistency of the tree. In particular, this function checks that:
- Every child is contained in the minimum bounding region of its parent, and
- The total number of descendants of the root node is equal to the number of nodes in the tree minus one.
pub fn get_node(&self, index: Index) -> &Node<ND>
[src]
Returns a reference to the Node
with index index
.
Panics
This function will panic if index
does not refer to a node in this tree.
pub fn get_node_mut(&mut self, index: Index) -> &mut Node<ND>
[src]
Returns a mutable reference to the Node
with index `index.
Panics
This function will panic if index
does not refer to a node in this tree.
pub fn root_node(&self) -> &Node<ND>
[src]
Returns a reference to the root Node
in this tree.
pub fn root_index(&self) -> Index
[src]
Returns the index of the root node in this tree.
pub fn shape_lookup(&self, shape: &Shape) -> Vec<Index>
[src]
Returns a Vec<Index>
of those elements in the tree whose bounding box contains the
minimum bounding box of the input shape
.
pub fn point_lookup<IP: IntoPoint>(&self, point: IP) -> Vec<Index>
[src]
Returns a Vec<Index>
of those regions in the tree containing the given point point
.
Example
use spaceindex::rtree::RTree; let mut tree = RTree::new(2); // insert a couple of regions tree.insert(((0.0, 0.0), (2.0, 2.0)), ()); tree.insert(((1.0, 0.0), (3.0, 3.0)), ()); // Both rectangles contain the point (1.0, 1.0) assert_eq!(tree.point_lookup((1.0, 1.0)).len(), 2); // No rectangle should contain the point (-1.0, 0.0) assert!(tree.point_lookup((-1.0, 0.0)).is_empty()); // Only one hit for (0.5, 0.5) assert_eq!(tree.point_lookup((0.5, 0.5)).len(), 1); // Two hits at (2.0, 2.0) assert_eq!(tree.point_lookup((2.0, 2.0)).len(), 2); // Only one hit at (2.5, 2.5) assert_eq!(tree.point_lookup((2.5, 2.5)).len(), 1);
pub fn region_intersection_lookup<'a, IC: IntoRegion<'a>>(
&self,
region: IC
) -> Vec<Index>
[src]
&self,
region: IC
) -> Vec<Index>
Returns a Vec<Index>
of those elements in the tree whose minimum bounding box
intersects the given region.
Example
use spaceindex::rtree::RTree; let mut tree = RTree::new(2); // insert a couple of regions tree.insert(((0.0, 0.0), (5.0, 5.0)), ()); tree.insert(((-1.0, 1.0), (1.0, 3.0)), ()); // Nothing should intersect with the box ((-3.0, 0.0), (-2.0, 2.0)) assert!(tree.region_intersection_lookup(((-3.0, 0.0), (-2.0, 2.0))).is_empty()); // The region ((-3.0, 0.0), (-0.5, 4.0)) should intersect the second region. assert_eq!(tree.region_intersection_lookup(((-3.0, 0.0), (-0.5, 4.0))).len(), 1); // The skinny box ((-2.0, 1.5), (8.0, 1.5)) should intersect both regions. assert_eq!(tree.region_intersection_lookup(((-2.0, 1.5), (8.0, 1.5))).len(), 2); // The region ((3.0, 2.0), (4.0, 4.0)) should only intersect the first region. assert_eq!(tree.region_intersection_lookup(((3.0, 2.0), (4.0, 4.0))).len(), 1);
pub fn region_lookup<'a, IC: IntoRegion<'a>>(&self, region: IC) -> Vec<Index>
[src]
Returns a Vec<Index>
of those elements in the tree whose minimum bounding box
contains the given region.
Example
use spaceindex::rtree::RTree; let mut tree = RTree::new(2); // insert a couple of regions tree.insert(((0.0, 0.0), (2.0, 2.0)), ()); tree.insert(((1.0, 0.0), (3.0, 3.0)), ()); // Both regions contain the box ((1.25, 1.0), (1.75, 1.75)) assert_eq!(tree.region_lookup(((1.25, 1.0), (1.75, 1.75))).len(), 2); // While the box ((-0.5, -0.5), (0.5, 0.5)) does intersect our first region, // it is not contained in any region, so we should get no results. assert!(tree.region_lookup(((-0.5, -0.5), (0.5, 0.5))).is_empty()); /// The box ((0.0, 0.5), (0.75, 1.99)) is only contained in the first region. assert_eq!(tree.region_lookup(((0.0, 0.5), (0.75, 1.99))).len(), 1);
pub fn line_lookup(&self, line: &LineSegment) -> Vec<Index>
[src]
Returns a Vec<Index>
of those elements in the tree whose minimum bounding box
contains the given line.
Trait Implementations
impl<ND: Debug> Debug for RTree<ND>
[src]
impl<'a, ND> GraphWalk<'a> for RTree<ND>
[src]
type Node = Index
type Edge = (Index, Index)
fn nodes(&'a self) -> Cow<'a, [Self::Node]>
[src]
fn edges(&'a self) -> Cow<'a, [Self::Edge]>
[src]
fn source(&'a self, edge: &Self::Edge) -> Self::Node
[src]
fn target(&'a self, edge: &Self::Edge) -> Self::Node
[src]
impl<'a, ND> Labeller<'a> for RTree<ND>
[src]
type Node = Index
type Edge = (Index, Index)
fn graph_id(&'a self) -> Id<'a>
[src]
fn node_id(&'a self, n: &Self::Node) -> Id<'a>
[src]
fn node_shape(&'a self, _node: &Self::Node) -> Option<LabelText<'a>>
[src]
fn node_label(&'a self, n: &Self::Node) -> LabelText<'a>
[src]
fn edge_label(&'a self, _e: &Self::Edge) -> LabelText<'a>
[src]
fn node_style(&'a self, _n: &Self::Node) -> Style
[src]
fn edge_style(&'a self, _e: &Self::Edge) -> Style
[src]
Auto Trait Implementations
impl<ND> RefUnwindSafe for RTree<ND> where
ND: RefUnwindSafe,
ND: RefUnwindSafe,
impl<ND> Send for RTree<ND> where
ND: Send,
ND: Send,
impl<ND> Sync for RTree<ND> where
ND: Sync,
ND: Sync,
impl<ND> Unpin for RTree<ND> where
ND: Unpin,
ND: Unpin,
impl<ND> UnwindSafe for RTree<ND> where
ND: UnwindSafe,
ND: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
Scheme: ApproxScheme,
type Err = NoError
The error type produced by a failed conversion.
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, Dst> ConvAsUtil<Dst> for T
fn approx(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Self: ApproxInto<Dst, DefaultApprox>,
fn approx_by<Scheme>(self) -> Result<Dst, Self::Err> where
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
impl<T> ConvUtil for T
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Self: ApproxInto<Dst, DefaultApprox>,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
fn into_as<Dst>(self) -> Dst where
Self: Into<Dst>,
Self: Into<Dst>,
fn try_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: TryInto<Dst>,
Self: TryInto<Dst>,
fn value_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ValueInto<Dst>,
Self: ValueInto<Dst>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<Src> TryFrom<Src> for Src
type Err = NoError
The error type produced by a failed conversion.
fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<Src, Dst> TryInto<Dst> for Src where
Dst: TryFrom<Src>,
Dst: TryFrom<Src>,
type Err = <Dst as TryFrom<Src>>::Err
The error type produced by a failed conversion.
fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<Src> ValueFrom<Src> for Src
type Err = NoError
The error type produced by a failed conversion.
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
Dst: ValueFrom<Src>,
type Err = <Dst as ValueFrom<Src>>::Err
The error type produced by a failed conversion.