use crate::{Point, PointDistance, RTreeObject, AABB};
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PointWithData<T, P> {
pub data: T,
point: P, }
impl<T, P> PointWithData<T, P> {
#[deprecated(note = "`PointWithData` is deprecated. Please switch to `GeomWithData`")]
pub fn new(data: T, point: P) -> Self {
PointWithData { data, point }
}
pub fn position(&self) -> &P {
&self.point
}
}
impl<T, P> RTreeObject for PointWithData<T, P>
where
P: Point,
{
type Envelope = AABB<P>;
fn envelope(&self) -> Self::Envelope {
self.point.envelope()
}
}
impl<T, P> PointDistance for PointWithData<T, P>
where
P: Point,
{
fn distance_2(&self, point: &P) -> <P as Point>::Scalar {
self.point.distance_2(point)
}
fn contains_point(&self, point: &P) -> bool {
self.point.contains_point(point)
}
}