Struct rstar::primitives::GeomWithData
source · [−]pub struct GeomWithData<R: RTreeObject, T> {
pub data: T,
/* private fields */
}
Expand description
An RTreeObject with a geometry and some associated data that can be inserted into an r-tree.
Often, adding metadata (like a database ID) to a geometry is required before adding it into an r-tree. This struct removes some of the boilerplate required to do so.
Note: while the container itself implements RTreeObject, you will have to go through its
geom
method in order to access geometry-specific methods.
Example
use rstar::{RTree, PointDistance};
use rstar::primitives::GeomWithData;
type RestaurantLocation = GeomWithData<[f64; 2], &'static str>;
let mut restaurants = RTree::new();
restaurants.insert(RestaurantLocation::new([0.3, 0.2], "Pete's Pizza Place"));
restaurants.insert(RestaurantLocation::new([-0.8, 0.0], "The Great Steak"));
restaurants.insert(RestaurantLocation::new([0.2, -0.2], "Fishy Fortune"));
let my_location = [0.0, 0.0];
// Now find the closest restaurant!
let place = restaurants.nearest_neighbor(&my_location).unwrap();
println!("Let's go to {}", place.data);
println!("It's really close, only {} miles", place.distance_2(&my_location));
Fields
data: T
Data to be associated with the geometry being stored in the RTree
.
Implementations
sourceimpl<R: RTreeObject, T> GeomWithData<R, T>
impl<R: RTreeObject, T> GeomWithData<R, T>
Trait Implementations
sourceimpl<R: Clone + RTreeObject, T: Clone> Clone for GeomWithData<R, T>
impl<R: Clone + RTreeObject, T: Clone> Clone for GeomWithData<R, T>
sourcefn clone(&self) -> GeomWithData<R, T>
fn clone(&self) -> GeomWithData<R, T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<R: Debug + RTreeObject, T: Debug> Debug for GeomWithData<R, T>
impl<R: Debug + RTreeObject, T: Debug> Debug for GeomWithData<R, T>
sourceimpl<R: Default + RTreeObject, T: Default> Default for GeomWithData<R, T>
impl<R: Default + RTreeObject, T: Default> Default for GeomWithData<R, T>
sourcefn default() -> GeomWithData<R, T>
fn default() -> GeomWithData<R, T>
Returns the “default value” for a type. Read more
sourceimpl<R: Hash + RTreeObject, T: Hash> Hash for GeomWithData<R, T>
impl<R: Hash + RTreeObject, T: Hash> Hash for GeomWithData<R, T>
sourceimpl<R: Ord + RTreeObject, T: Ord> Ord for GeomWithData<R, T>
impl<R: Ord + RTreeObject, T: Ord> Ord for GeomWithData<R, T>
sourceimpl<R: PartialEq + RTreeObject, T: PartialEq> PartialEq<GeomWithData<R, T>> for GeomWithData<R, T>
impl<R: PartialEq + RTreeObject, T: PartialEq> PartialEq<GeomWithData<R, T>> for GeomWithData<R, T>
sourcefn eq(&self, other: &GeomWithData<R, T>) -> bool
fn eq(&self, other: &GeomWithData<R, T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &GeomWithData<R, T>) -> bool
fn ne(&self, other: &GeomWithData<R, T>) -> bool
This method tests for !=
.
sourceimpl<R: PartialOrd + RTreeObject, T: PartialOrd> PartialOrd<GeomWithData<R, T>> for GeomWithData<R, T>
impl<R: PartialOrd + RTreeObject, T: PartialOrd> PartialOrd<GeomWithData<R, T>> for GeomWithData<R, T>
sourcefn partial_cmp(&self, other: &GeomWithData<R, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &GeomWithData<R, T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<R: PointDistance, T> PointDistance for GeomWithData<R, T>
impl<R: PointDistance, T> PointDistance for GeomWithData<R, T>
sourcefn distance_2(
&self,
point: &<Self::Envelope as Envelope>::Point
) -> <<Self::Envelope as Envelope>::Point as Point>::Scalar
fn distance_2(
&self,
point: &<Self::Envelope as Envelope>::Point
) -> <<Self::Envelope as Envelope>::Point as Point>::Scalar
Returns the squared euclidean distance between an object to a point.
sourcefn contains_point(&self, p: &<Self::Envelope as Envelope>::Point) -> bool
fn contains_point(&self, p: &<Self::Envelope as Envelope>::Point) -> bool
Returns true
if a point is contained within this object. Read more
sourcefn distance_2_if_less_or_equal(
&self,
point: &<Self::Envelope as Envelope>::Point,
max_distance_2: <<Self::Envelope as Envelope>::Point as Point>::Scalar
) -> Option<<<Self::Envelope as Envelope>::Point as Point>::Scalar>
fn distance_2_if_less_or_equal(
&self,
point: &<Self::Envelope as Envelope>::Point,
max_distance_2: <<Self::Envelope as Envelope>::Point as Point>::Scalar
) -> Option<<<Self::Envelope as Envelope>::Point as Point>::Scalar>
Returns the squared distance to this object, or None
if the distance
is larger than a given maximum value. Read more
sourceimpl<R: RTreeObject, T> RTreeObject for GeomWithData<R, T>
impl<R: RTreeObject, T> RTreeObject for GeomWithData<R, T>
impl<R: Copy + RTreeObject, T: Copy> Copy for GeomWithData<R, T>
impl<R: Eq + RTreeObject, T: Eq> Eq for GeomWithData<R, T>
impl<R: RTreeObject, T> StructuralEq for GeomWithData<R, T>
impl<R: RTreeObject, T> StructuralPartialEq for GeomWithData<R, T>
Auto Trait Implementations
impl<R, T> RefUnwindSafe for GeomWithData<R, T> where
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<R, T> Send for GeomWithData<R, T> where
R: Send,
T: Send,
impl<R, T> Sync for GeomWithData<R, T> where
R: Sync,
T: Sync,
impl<R, T> Unpin for GeomWithData<R, T> where
R: Unpin,
T: Unpin,
impl<R, T> UnwindSafe for GeomWithData<R, T> where
R: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more