Struct geo::Coordinate
source · [−]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
sourceimpl<T> Coordinate<T> where
T: CoordNum,
impl<T> Coordinate<T> where
T: CoordNum,
sourceimpl<T> Coordinate<T> where
T: CoordNum,
impl<T> Coordinate<T> where
T: CoordNum,
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.);
pub fn zero() -> Coordinate<T>
Trait Implementations
sourceimpl<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,
type Epsilon = <T as AbsDiffEq<T>>::Epsilon
type Epsilon = <T as AbsDiffEq<T>>::Epsilon
Used for specifying relative comparisons.
sourcefn default_epsilon() -> <T as AbsDiffEq<T>>::Epsilon
fn default_epsilon() -> <T as AbsDiffEq<T>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
sourcefn abs_diff_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon
) -> bool
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
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
].
sourceimpl<T> Add<Coordinate<T>> for Coordinate<T> where
T: CoordNum,
impl<T> Add<Coordinate<T>> for Coordinate<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);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the +
operator.
sourcefn add(self, rhs: Coordinate<T>) -> Coordinate<T>
fn add(self, rhs: Coordinate<T>) -> Coordinate<T>
Performs the +
operation. Read more
sourceimpl<T> BoundingRect<T> for Coordinate<T> where
T: CoordNum,
impl<T> BoundingRect<T> for Coordinate<T> where
T: CoordNum,
sourcefn bounding_rect(&self) -> Self::Output
fn bounding_rect(&self) -> Self::Output
Return the bounding rectangle for a Coordinate
. It will have zero width
and zero height.
type Output = Rect<T>
sourceimpl<T> Clone for Coordinate<T> where
T: Clone + CoordNum,
impl<T> Clone for Coordinate<T> where
T: Clone + CoordNum,
sourcefn clone(&self) -> Coordinate<T>
fn clone(&self) -> Coordinate<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Coordinate<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Coordinate<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<T> Contains<Coordinate<T>> for Geometry<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for Geometry<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Coordinate<T>> for GeometryCollection<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for GeometryCollection<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Coordinate<T>> for Line<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for Line<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Coordinate<T>> for LineString<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for LineString<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Coordinate<T>> for Point<T> where
T: CoordNum,
impl<T> Contains<Coordinate<T>> for Point<T> where
T: CoordNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Coordinate<T>> for Polygon<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for Polygon<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Coordinate<T>> for MultiPolygon<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for MultiPolygon<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Coordinate<T>> for Rect<T> where
T: CoordNum,
impl<T> Contains<Coordinate<T>> for Rect<T> where
T: CoordNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Coordinate<T>> for Triangle<T> where
T: GeoNum,
impl<T> Contains<Coordinate<T>> for Triangle<T> where
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> CoordinatePosition for Coordinate<T> where
T: GeoNum,
impl<T> CoordinatePosition for Coordinate<T> where
T: GeoNum,
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
_boundary_count: &mut usize
)
fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos
sourceimpl<T> Debug for Coordinate<T> where
T: Debug + CoordNum,
impl<T> Debug for Coordinate<T> where
T: Debug + CoordNum,
sourceimpl<T> Default for Coordinate<T> where
T: Default + CoordNum,
impl<T> Default for Coordinate<T> where
T: Default + CoordNum,
sourcefn default() -> Coordinate<T>
fn default() -> Coordinate<T>
Returns the “default value” for a type. Read more
sourceimpl<T> Div<T> for Coordinate<T> where
T: CoordNum,
impl<T> Div<T> for Coordinate<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);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the /
operator.
sourcefn div(self, rhs: T) -> Coordinate<T>
fn div(self, rhs: T) -> Coordinate<T>
Performs the /
operation. Read more
sourceimpl<T> EuclideanDistance<T, Coordinate<T>> for Coordinate<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Coordinate<T>> for Coordinate<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, c: &Coordinate<T>) -> T
fn euclidean_distance(&self, c: &Coordinate<T>) -> T
Minimum distance between two Coordinate
s
sourceimpl<T> EuclideanDistance<T, Coordinate<T>> for Line<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Coordinate<T>> for Line<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, coord: &Coordinate<T>) -> T
fn euclidean_distance(&self, coord: &Coordinate<T>) -> T
Minimum distance from a Line
to a Coordinate
sourceimpl<T> EuclideanDistance<T, Line<T>> for Coordinate<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Line<T>> for Coordinate<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, line: &Line<T>) -> T
fn euclidean_distance(&self, line: &Line<T>) -> T
Minimum distance from a Coordinate
to a Line
sourceimpl<T> From<[T; 2]> for Coordinate<T> where
T: CoordNum,
impl<T> From<[T; 2]> for Coordinate<T> where
T: CoordNum,
sourcefn from(coords: [T; 2]) -> Coordinate<T>
fn from(coords: [T; 2]) -> Coordinate<T>
Converts to this type from the input type.
sourceimpl<T> From<(T, T)> for Coordinate<T> where
T: CoordNum,
impl<T> From<(T, T)> for Coordinate<T> where
T: CoordNum,
sourcefn from(coords: (T, T)) -> Coordinate<T>
fn from(coords: (T, T)) -> Coordinate<T>
Converts to this type from the input type.
sourceimpl<T> From<Coordinate<T>> for Point<T> where
T: CoordNum,
impl<T> From<Coordinate<T>> for Point<T> where
T: CoordNum,
sourcefn from(x: Coordinate<T>) -> Point<T>
fn from(x: Coordinate<T>) -> Point<T>
Converts to this type from the input type.
sourceimpl<T: GeoNum> From<Coordinate<T>> for LineOrPoint<T>
impl<T: GeoNum> From<Coordinate<T>> for LineOrPoint<T>
Convert from a Coordinate
sourcefn from(c: Coordinate<T>) -> Self
fn from(c: Coordinate<T>) -> Self
Converts to this type from the input type.
sourceimpl<T> From<Point<T>> for Coordinate<T> where
T: CoordNum,
impl<T> From<Point<T>> for Coordinate<T> where
T: CoordNum,
sourcefn from(point: Point<T>) -> Coordinate<T>
fn from(point: Point<T>) -> Coordinate<T>
Converts to this type from the input type.
sourceimpl<T> Hash for Coordinate<T> where
T: Hash + CoordNum,
impl<T> Hash for Coordinate<T> where
T: Hash + CoordNum,
sourceimpl<T> Intersects<Coordinate<T>> for Coordinate<T> where
T: CoordNum,
impl<T> Intersects<Coordinate<T>> for Coordinate<T> where
T: CoordNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
sourceimpl<T> Intersects<Coordinate<T>> for Line<T> where
T: GeoNum,
impl<T> Intersects<Coordinate<T>> for Line<T> where
T: GeoNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
sourceimpl<T> Intersects<Coordinate<T>> for Polygon<T> where
T: GeoNum,
impl<T> Intersects<Coordinate<T>> for Polygon<T> where
T: GeoNum,
fn intersects(&self, p: &Coordinate<T>) -> bool
sourceimpl<T> Intersects<Coordinate<T>> for Rect<T> where
T: CoordNum,
impl<T> Intersects<Coordinate<T>> for Rect<T> where
T: CoordNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
sourceimpl<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,
fn intersects(&self, rhs: &Geometry<T>) -> bool
sourceimpl<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,
fn intersects(&self, rhs: &GeometryCollection<T>) -> bool
sourceimpl<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,
fn intersects(&self, rhs: &Line<T>) -> bool
sourceimpl<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,
fn intersects(&self, rhs: &LineString<T>) -> bool
sourceimpl<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,
fn intersects(&self, rhs: &MultiPoint<T>) -> bool
sourceimpl<T> Intersects<Point<T>> for Coordinate<T> where
T: CoordNum,
impl<T> Intersects<Point<T>> for Coordinate<T> where
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
sourceimpl<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,
fn intersects(&self, rhs: &Polygon<T>) -> bool
sourceimpl<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,
fn intersects(&self, rhs: &Rect<T>) -> bool
sourceimpl<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,
fn intersects(&self, rhs: &Triangle<T>) -> bool
sourceimpl<T> Mul<T> for Coordinate<T> where
T: CoordNum,
impl<T> Mul<T> for Coordinate<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);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: T) -> Coordinate<T>
fn mul(self, rhs: T) -> Coordinate<T>
Performs the *
operation. Read more
sourceimpl<T> Neg for Coordinate<T> where
T: CoordNum + Neg<Output = T>,
impl<T> Neg for Coordinate<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);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the -
operator.
sourcefn neg(self) -> Coordinate<T>
fn neg(self) -> Coordinate<T>
Performs the unary -
operation. Read more
sourceimpl<T> PartialEq<Coordinate<T>> for Coordinate<T> where
T: PartialEq<T> + CoordNum,
impl<T> PartialEq<Coordinate<T>> for Coordinate<T> where
T: PartialEq<T> + CoordNum,
sourcefn eq(&self, other: &Coordinate<T>) -> bool
fn eq(&self, other: &Coordinate<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Coordinate<T>) -> bool
fn ne(&self, other: &Coordinate<T>) -> bool
This method tests for !=
.
sourceimpl<T> Point for Coordinate<T> where
T: Float + RTreeNum,
impl<T> Point for Coordinate<T> where
T: Float + RTreeNum,
type Scalar = T
type Scalar = T
The number type used by this point type.
sourceconst DIMENSIONS: usize = 2usize
const DIMENSIONS: usize = 2usize
The number of dimensions of this point type.
sourcefn generate(
generator: impl FnMut(usize) -> <Coordinate<T> as Point>::Scalar
) -> Coordinate<T>
fn generate(
generator: impl FnMut(usize) -> <Coordinate<T> as Point>::Scalar
) -> Coordinate<T>
Creates a new point value with given values for each dimension. Read more
sourceimpl<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,
sourcefn default_max_relative() -> <T as AbsDiffEq<T>>::Epsilon
fn default_max_relative() -> <T as AbsDiffEq<T>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
sourcefn relative_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_relative: <T as AbsDiffEq<T>>::Epsilon
) -> bool
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.
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
].
sourceimpl<T> Sub<Coordinate<T>> for Coordinate<T> where
T: CoordNum,
impl<T> Sub<Coordinate<T>> for Coordinate<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.);
type Output = Coordinate<T>
type Output = Coordinate<T>
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: Coordinate<T>) -> Coordinate<T>
fn sub(self, rhs: Coordinate<T>) -> Coordinate<T>
Performs the -
operation. Read more
sourceimpl<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,
sourcefn default_max_ulps() -> u32
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
sourcefn ulps_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_ulps: u32
) -> bool
fn ulps_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_ulps: u32
) -> bool
A test for equality that uses units in the last place (ULP) if the values are far apart.
sourceimpl<T> Zero for Coordinate<T> where
T: CoordNum,
impl<T> Zero for Coordinate<T> where
T: CoordNum,
impl<T> Copy for Coordinate<T> where
T: Copy + CoordNum,
impl<T> Eq for Coordinate<T> where
T: Eq + CoordNum,
impl<T> StructuralEq for Coordinate<T> where
T: CoordNum,
impl<T> StructuralPartialEq for Coordinate<T> where
T: CoordNum,
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<P> PointDistance for P where
P: Point,
impl<P> PointDistance for P where
P: Point,
sourcefn 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.
sourcefn 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
sourcefn 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