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§
§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,
§fn default_epsilon() -> <T as AbsDiffEq>::Epsilon
fn default_epsilon() -> <T as AbsDiffEq>::Epsilon
The default tolerance to use when testing values that are close together. Read more
§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
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
§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
].§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);
§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);
§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);
§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);
§impl<T> Point for Coord<T>where
T: Float + RTreeNum,
impl<T> Point for Coord<T>where
T: Float + RTreeNum,
§const DIMENSIONS: usize = 2usize
const DIMENSIONS: usize = 2usize
The number of dimensions of this point type.
§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>
Creates a new point value with given values for each dimension. Read more
§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,
§fn default_max_relative() -> <T as AbsDiffEq>::Epsilon
fn default_max_relative() -> <T as AbsDiffEq>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
§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
A test for equality that uses a relative comparison if the values are far apart.
§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
].§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.);
§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,
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
Mutably borrows from an owned value. Read more
§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
§impl<P> PointDistance for Pwhere
P: Point,
impl<P> PointDistance for Pwhere
P: Point,
§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.
§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 more§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