Struct geo::Coordinate [−][src]
pub struct Coordinate<T> 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 Coordinate
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
Create a coordinate at the origin.
Examples
use geo_types::Coordinate;
use num_traits::Zero;
let p: Coordinate<f64> = Zero::zero();
assert_eq!(p.x, 0.);
assert_eq!(p.y, 0.);
Trait Implementations
impl<T> AbsDiffEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + AbsDiffEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
impl<T> AbsDiffEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + AbsDiffEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
The default tolerance to use when testing values that are close together. Read more
pub fn abs_diff_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon
) -> bool
pub fn abs_diff_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon
) -> bool
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
The inverse of AbsDiffEq::abs_diff_eq
.
Add two coordinates.
Examples
use geo_types::Coordinate;
let p: Coordinate<_> = (1.25, 2.5).into();
let q: Coordinate<_> = (1.5, 2.5).into();
let sum = p + q;
assert_eq!(sum.x, 2.75);
assert_eq!(sum.y, 5.0);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the +
operator.
Performs the +
operation. Read more
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
_boundary_count: &mut usize
)
Returns the “default value” for a type. Read more
Divide coordinate wise by a scalar.
Examples
use geo_types::Coordinate;
let p: Coordinate<_> = (5., 10.).into();
let q: Coordinate<_> = p / 4.;
assert_eq!(q.x, 1.25);
assert_eq!(q.y, 2.5);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the /
operator.
Performs the /
operation. Read more
Minimum distance between two Coordinate
s
Minimum distance from a Line
to a Coordinate
Minimum distance from a Coordinate
to a Line
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
impl<T> Intersects<Geometry<T>> for Coordinate<T> where
Geometry<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Coordinate<T> where
Geometry<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Coordinate<T> where
GeometryCollection<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Coordinate<T> where
GeometryCollection<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Line<T>> for Coordinate<T> where
Line<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Line<T>> for Coordinate<T> where
Line<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Coordinate<T> where
LineString<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Coordinate<T> where
LineString<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<MultiPoint<T>> for Coordinate<T> where
MultiPoint<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<MultiPoint<T>> for Coordinate<T> where
MultiPoint<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Polygon<T>> for Coordinate<T> where
Polygon<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Polygon<T>> for Coordinate<T> where
Polygon<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Rect<T>> for Coordinate<T> where
Rect<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Rect<T>> for Coordinate<T> where
Rect<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Coordinate<T> where
Triangle<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Coordinate<T> where
Triangle<T>: Intersects<Coordinate<T>>,
T: CoordNum,
Multiply coordinate wise by a scalar.
Examples
use geo_types::Coordinate;
let p: Coordinate<_> = (1.25, 2.5).into();
let q: Coordinate<_> = p * 4.;
assert_eq!(q.x, 5.0);
assert_eq!(q.y, 10.0);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the *
operator.
Performs the *
operation. Read more
Negate a coordinate.
Examples
use geo_types::Coordinate;
let p: Coordinate<_> = (1.25, 2.5).into();
let q = -p;
assert_eq!(q.x, -p.x);
assert_eq!(q.y, -p.y);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the -
operator.
Performs the unary -
operation. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
type Scalar = T
type Scalar = T
The number type used by this point type.
The number of dimensions of this point type.
pub fn generate(
generator: impl Fn(usize) -> <Coordinate<T> as Point>::Scalar
) -> Coordinate<T>
pub fn generate(
generator: impl Fn(usize) -> <Coordinate<T> as Point>::Scalar
) -> Coordinate<T>
Creates a new point value with given values for each dimension. Read more
Returns a single coordinate of this point. Read more
impl<T> RelativeEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + RelativeEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
impl<T> RelativeEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + RelativeEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
The default relative tolerance for testing values that are far-apart. Read more
pub fn relative_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_relative: <T as AbsDiffEq<T>>::Epsilon
) -> bool
pub fn relative_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_relative: <T as AbsDiffEq<T>>::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
The inverse of RelativeEq::relative_eq
.
Subtract a coordinate from another.
Examples
use geo_types::Coordinate;
let p: Coordinate<_> = (1.5, 2.5).into();
let q: Coordinate<_> = (1.25, 2.5).into();
let diff = p - q;
assert_eq!(diff.x, 0.25);
assert_eq!(diff.y, 0.);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the -
operator.
Performs the -
operation. Read more
impl<T> UlpsEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + UlpsEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
impl<T> UlpsEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + UlpsEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
Auto Trait Implementations
impl<T> RefUnwindSafe for Coordinate<T> where
T: RefUnwindSafe,
impl<T> Send for Coordinate<T> where
T: Send,
impl<T> Sync for Coordinate<T> where
T: Sync,
impl<T> Unpin for Coordinate<T> where
T: Unpin,
impl<T> UnwindSafe for Coordinate<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Returns the squared euclidean distance of an object to a point.
pub fn contains_point(
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
pub 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
pub 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>
pub 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