pub struct Coord<T = f64>where
T: CoordNum,{
pub x: T,
pub y: T,
}
Expand description
A lightweight struct used to store coordinates on the 2-dimensional Cartesian plane.
Unlike Point
(which in the future may contain additional information such
as an envelope, a precision model, and spatial reference system
information), a Coord
only contains ordinate values and accessor
methods.
This type implements the vector space operations:
Add
, Sub
, Neg
, Zero
,
Mul<T>
, and Div<T>
traits.
Semantics
This type does not represent any geospatial primitive,
but is used in their definitions. The only requirement
is that the coordinates it contains are valid numbers
(for eg. not f64::NAN
).
Fields§
§x: T
§y: T
Implementations§
Trait Implementations§
source§impl<T> AbsDiffEq for Coord<T>where
T: CoordNum + AbsDiffEq,
<T as AbsDiffEq>::Epsilon: Copy,
impl<T> AbsDiffEq for Coord<T>where T: CoordNum + AbsDiffEq, <T as AbsDiffEq>::Epsilon: Copy,
source§fn default_epsilon() -> <T as AbsDiffEq>::Epsilon
fn default_epsilon() -> <T as AbsDiffEq>::Epsilon
source§fn abs_diff_eq(
&self,
other: &Coord<T>,
epsilon: <T as AbsDiffEq>::Epsilon
) -> bool
fn abs_diff_eq( &self, other: &Coord<T>, epsilon: <T as AbsDiffEq>::Epsilon ) -> bool
§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
].source§impl<T> Add for Coord<T>where
T: CoordNum,
impl<T> Add for Coord<T>where T: CoordNum,
Add two coordinates.
Examples
use geo_types::coord;
let p = coord! { x: 1.25, y: 2.5 };
let q = coord! { x: 1.5, y: 2.5 };
let sum = p + q;
assert_eq!(sum.x, 2.75);
assert_eq!(sum.y, 5.0);
source§impl<T> BoundingRect<T> for Coord<T>where
T: CoordNum,
impl<T> BoundingRect<T> for Coord<T>where T: CoordNum,
source§impl<F: GeoFloat> ClosestPoint<F> for Coord<F>
impl<F: GeoFloat> ClosestPoint<F> for Coord<F>
source§fn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
self
and p
.source§impl<T> CoordinatePosition for Coord<T>where
T: GeoNum,
impl<T> CoordinatePosition for Coord<T>where T: GeoNum,
source§impl<T> Div<T> for Coord<T>where
T: CoordNum,
impl<T> Div<T> for Coord<T>where T: CoordNum,
Divide coordinate wise by a scalar.
Examples
use geo_types::coord;
let p = coord! { x: 5., y: 10. };
let q = p / 4.;
assert_eq!(q.x, 1.25);
assert_eq!(q.y, 2.5);
source§impl<T> EuclideanDistance<T> for Coord<T>where
T: GeoFloat,
impl<T> EuclideanDistance<T> for Coord<T>where T: GeoFloat,
source§fn euclidean_distance(&self, c: &Coord<T>) -> T
fn euclidean_distance(&self, c: &Coord<T>) -> T
Minimum distance between two Coord
s
source§impl<T> EuclideanDistance<T, Coord<T>> for Line<T>where
T: GeoFloat,
impl<T> EuclideanDistance<T, Coord<T>> for Line<T>where T: GeoFloat,
source§fn euclidean_distance(&self, coord: &Coord<T>) -> T
fn euclidean_distance(&self, coord: &Coord<T>) -> T
Minimum distance from a Line
to a Coord
source§impl<T> EuclideanDistance<T, Line<T>> for Coord<T>where
T: GeoFloat,
impl<T> EuclideanDistance<T, Line<T>> for Coord<T>where T: GeoFloat,
source§fn euclidean_distance(&self, line: &Line<T>) -> T
fn euclidean_distance(&self, line: &Line<T>) -> T
Minimum distance from a Coord
to a Line
source§impl<T> HausdorffDistance<T> for Coord<T>where
T: GeoFloat,
impl<T> HausdorffDistance<T> for Coord<T>where T: GeoFloat,
fn hausdorff_distance<Rhs>(&self, rhs: &Rhs) -> Twhere Rhs: CoordsIter<Scalar = T>,
source§impl<T> HaversineClosestPoint<T> for Coord<T>where
T: GeoFloat + FromPrimitive,
impl<T> HaversineClosestPoint<T> for Coord<T>where T: GeoFloat + FromPrimitive,
fn haversine_closest_point(&self, pt: &Point<T>) -> Closest<T>
source§impl<T> Intersects<Coord<T>> for Line<T>where
T: GeoNum,
impl<T> Intersects<Coord<T>> for Line<T>where T: GeoNum,
fn intersects(&self, rhs: &Coord<T>) -> bool
source§impl<T: GeoNum> Intersects<Coord<T>> for MonoPoly<T>
impl<T: GeoNum> Intersects<Coord<T>> for MonoPoly<T>
fn intersects(&self, other: &Coord<T>) -> bool
source§impl<T: GeoNum> Intersects<Coord<T>> for MonotonicPolygons<T>
impl<T: GeoNum> Intersects<Coord<T>> for MonotonicPolygons<T>
fn intersects(&self, other: &Coord<T>) -> bool
source§impl<T> Intersects<Coord<T>> for Polygon<T>where
T: GeoNum,
impl<T> Intersects<Coord<T>> for Polygon<T>where T: GeoNum,
fn intersects(&self, p: &Coord<T>) -> bool
source§impl<T> Intersects<Coord<T>> for Rect<T>where
T: CoordNum,
impl<T> Intersects<Coord<T>> for Rect<T>where T: CoordNum,
fn intersects(&self, rhs: &Coord<T>) -> bool
source§impl<T> Intersects<Geometry<T>> for Coord<T>where
Geometry<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Coord<T>where Geometry<T>: Intersects<Coord<T>>, T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
source§impl<T> Intersects<GeometryCollection<T>> for Coord<T>where
GeometryCollection<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Coord<T>where GeometryCollection<T>: Intersects<Coord<T>>, T: CoordNum,
fn intersects(&self, rhs: &GeometryCollection<T>) -> bool
source§impl<T> Intersects<Line<T>> for Coord<T>where
Line<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<Line<T>> for Coord<T>where Line<T>: Intersects<Coord<T>>, T: CoordNum,
fn intersects(&self, rhs: &Line<T>) -> bool
source§impl<T> Intersects<LineString<T>> for Coord<T>where
LineString<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Coord<T>where LineString<T>: Intersects<Coord<T>>, T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
source§impl<T> Intersects<MultiPoint<T>> for Coord<T>where
MultiPoint<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<MultiPoint<T>> for Coord<T>where MultiPoint<T>: Intersects<Coord<T>>, T: CoordNum,
fn intersects(&self, rhs: &MultiPoint<T>) -> bool
source§impl<T> Intersects<Point<T>> for Coord<T>where
T: CoordNum,
impl<T> Intersects<Point<T>> for Coord<T>where T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
source§impl<T> Intersects<Polygon<T>> for Coord<T>where
Polygon<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<Polygon<T>> for Coord<T>where Polygon<T>: Intersects<Coord<T>>, T: CoordNum,
fn intersects(&self, rhs: &Polygon<T>) -> bool
source§impl<T> Intersects<Rect<T>> for Coord<T>where
Rect<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<Rect<T>> for Coord<T>where Rect<T>: Intersects<Coord<T>>, T: CoordNum,
fn intersects(&self, rhs: &Rect<T>) -> bool
source§impl<T> Intersects<Triangle<T>> for Coord<T>where
Triangle<T>: Intersects<Coord<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Coord<T>where Triangle<T>: Intersects<Coord<T>>, T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
source§impl<T> Intersects for Coord<T>where
T: CoordNum,
impl<T> Intersects for Coord<T>where T: CoordNum,
fn intersects(&self, rhs: &Coord<T>) -> bool
source§impl<T> Mul<T> for Coord<T>where
T: CoordNum,
impl<T> Mul<T> for Coord<T>where T: CoordNum,
Multiply coordinate wise by a scalar.
Examples
use geo_types::coord;
let p = coord! { x: 1.25, y: 2.5 };
let q = p * 4.;
assert_eq!(q.x, 5.0);
assert_eq!(q.y, 10.0);
source§impl<T> Neg for Coord<T>where
T: CoordNum + Neg<Output = T>,
impl<T> Neg for Coord<T>where T: CoordNum + Neg<Output = T>,
Negate a coordinate.
Examples
use geo_types::coord;
let p = coord! { x: 1.25, y: 2.5 };
let q = -p;
assert_eq!(q.x, -p.x);
assert_eq!(q.y, -p.y);
source§impl<T> PartialEq for Coord<T>where
T: PartialEq + CoordNum,
impl<T> PartialEq for Coord<T>where T: PartialEq + CoordNum,
source§impl<T> Point for Coord<T>where
T: Float + RTreeNum,
impl<T> Point for Coord<T>where T: Float + RTreeNum,
source§const DIMENSIONS: usize = 2usize
const DIMENSIONS: usize = 2usize
source§fn generate(
generator: impl FnMut(usize) -> <Coord<T> as Point>::Scalar
) -> Coord<T>
fn generate( generator: impl FnMut(usize) -> <Coord<T> as Point>::Scalar ) -> Coord<T>
source§impl<T> RelativeEq for Coord<T>where
T: CoordNum + RelativeEq,
<T as AbsDiffEq>::Epsilon: Copy,
impl<T> RelativeEq for Coord<T>where T: CoordNum + RelativeEq, <T as AbsDiffEq>::Epsilon: Copy,
source§fn default_max_relative() -> <T as AbsDiffEq>::Epsilon
fn default_max_relative() -> <T as AbsDiffEq>::Epsilon
source§fn relative_eq(
&self,
other: &Coord<T>,
epsilon: <T as AbsDiffEq>::Epsilon,
max_relative: <T as AbsDiffEq>::Epsilon
) -> bool
fn relative_eq( &self, other: &Coord<T>, epsilon: <T as AbsDiffEq>::Epsilon, max_relative: <T as AbsDiffEq>::Epsilon ) -> bool
§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool
RelativeEq::relative_eq
].source§impl<T> Sub for Coord<T>where
T: CoordNum,
impl<T> Sub for Coord<T>where T: CoordNum,
Subtract a coordinate from another.
Examples
use geo_types::coord;
let p = coord! { x: 1.5, y: 2.5 };
let q = coord! { x: 1.25, y: 2.5 };
let diff = p - q;
assert_eq!(diff.x, 0.25);
assert_eq!(diff.y, 0.);
source§impl<T> UlpsEq for Coord<T>where
T: CoordNum + UlpsEq,
<T as AbsDiffEq>::Epsilon: Copy,
impl<T> UlpsEq for Coord<T>where T: CoordNum + UlpsEq, <T as AbsDiffEq>::Epsilon: Copy,
source§fn default_max_ulps() -> u32
fn default_max_ulps() -> u32
source§impl<T> Vector2DOps for Coord<T>where
T: CoordFloat,
impl<T> Vector2DOps for Coord<T>where T: CoordFloat,
type Scalar = T
source§fn wedge_product(self, other: Coord<T>) -> Self::Scalar
fn wedge_product(self, other: Coord<T>) -> Self::Scalar
wedge product
between two vectors. Read moresource§fn dot_product(self, other: Self) -> Self::Scalar
fn dot_product(self, other: Self) -> Self::Scalar
source§fn magnitude(self) -> Self::Scalar
fn magnitude(self) -> Self::Scalar
source§fn magnitude_squared(self) -> Self::Scalar
fn magnitude_squared(self) -> Self::Scalar
source§fn left(self) -> Self
fn left(self) -> Self
source§fn right(self) -> Self
fn right(self) -> Self
source§fn try_normalize(self) -> Option<Self>
fn try_normalize(self) -> Option<Self>
impl<T> Copy for Coord<T>where T: Copy + CoordNum,
impl<T> Eq for Coord<T>where T: Eq + CoordNum,
impl<T> StructuralEq for Coord<T>where T: CoordNum,
impl<T> StructuralPartialEq for Coord<T>where T: CoordNum,
Auto Trait Implementations§
impl<T> RefUnwindSafe for Coord<T>where T: RefUnwindSafe,
impl<T> Send for Coord<T>where T: Send,
impl<T> Sync for Coord<T>where T: Sync,
impl<T> Unpin for Coord<T>where T: Unpin,
impl<T> UnwindSafe for Coord<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<P> PointDistance for Pwhere
P: Point,
impl<P> PointDistance for Pwhere P: Point,
source§fn distance_2(&self, point: &P) -> <P as Point>::Scalar
fn distance_2(&self, point: &P) -> <P as Point>::Scalar
source§fn contains_point(
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
fn contains_point( &self, point: &<<P as RTreeObject>::Envelope as Envelope>::Point ) -> bool
true
if a point is contained within this object. Read moresource§fn distance_2_if_less_or_equal(
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point,
max_distance_2: <<<P as RTreeObject>::Envelope as Envelope>::Point as Point>::Scalar
) -> Option<<P as Point>::Scalar>
fn distance_2_if_less_or_equal( &self, point: &<<P as RTreeObject>::Envelope as Envelope>::Point, max_distance_2: <<<P as RTreeObject>::Envelope as Envelope>::Point as Point>::Scalar ) -> Option<<P as Point>::Scalar>
None
if the distance
is larger than a given maximum value. Read more