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: CoordNum + AbsDiffEq> AbsDiffEq<Coord<T>> for Coord<T>where
T::Epsilon: Copy,
impl<T: CoordNum + AbsDiffEq> AbsDiffEq<Coord<T>> for Coord<T>where
T::Epsilon: Copy,
source§fn default_epsilon() -> T::Epsilon
fn default_epsilon() -> T::Epsilon
The default tolerance to use when testing values that are close together. Read more
source§fn abs_diff_eq(&self, other: &Self, epsilon: T::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: T::Epsilon) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers. Read more
source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq
.source§impl<T: CoordNum> Add<Coord<T>> for Coord<T>
impl<T: CoordNum> Add<Coord<T>> for Coord<T>
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<'de, T> Deserialize<'de> for Coord<T>where
T: Deserialize<'de> + CoordNum,
impl<'de, T> Deserialize<'de> for Coord<T>where
T: Deserialize<'de> + CoordNum,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<T: CoordNum> Div<T> for Coord<T>
impl<T: CoordNum> Div<T> for Coord<T>
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: CoordNum> Mul<T> for Coord<T>
impl<T: CoordNum> Mul<T> for Coord<T>
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 + CoordNum> PartialEq<Coord<T>> for Coord<T>
impl<T: PartialEq + CoordNum> PartialEq<Coord<T>> for Coord<T>
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
The number of dimensions of this point type.
source§fn generate(generator: impl FnMut(usize) -> Self::Scalar) -> Self
fn generate(generator: impl FnMut(usize) -> Self::Scalar) -> Self
Creates a new point value with given values for each dimension. Read more
source§impl<T: CoordNum + RelativeEq> RelativeEq<Coord<T>> for Coord<T>where
T::Epsilon: Copy,
impl<T: CoordNum + RelativeEq> RelativeEq<Coord<T>> for Coord<T>where
T::Epsilon: Copy,
source§fn default_max_relative() -> T::Epsilon
fn default_max_relative() -> T::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
source§fn relative_eq(
&self,
other: &Self,
epsilon: T::Epsilon,
max_relative: T::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Self,
epsilon: T::Epsilon,
max_relative: T::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
source§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
The inverse of
RelativeEq::relative_eq
.source§impl<T: CoordNum> Sub<Coord<T>> for Coord<T>
impl<T: CoordNum> Sub<Coord<T>> for Coord<T>
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: CoordNum + UlpsEq> UlpsEq<Coord<T>> for Coord<T>where
T::Epsilon: Copy,
impl<T: CoordNum + UlpsEq> UlpsEq<Coord<T>> for Coord<T>where
T::Epsilon: Copy,
impl<T: Copy + CoordNum> Copy for Coord<T>
impl<T: Eq + CoordNum> Eq for Coord<T>
impl<T: CoordNum> StructuralEq for Coord<T>
impl<T: CoordNum> StructuralPartialEq for Coord<T>
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<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
Returns the squared euclidean distance between an object to a point.
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
Returns
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>
Returns the squared distance to this object, or
None
if the distance
is larger than a given maximum value. Read more