Struct geo::Coordinate [−][src]
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
impl<T> Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn x_y(&self) -> (T, T)
[src]
Returns a tuple that contains the x/horizontal & y/vertical component of the coordinate.
Examples
use geo_types::Coordinate; let c = Coordinate { x: 40.02f64, y: 116.34, }; let (x, y) = c.x_y(); assert_eq!(y, 116.34); assert_eq!(x, 40.02f64);
impl<T> Coordinate<T> where
T: CoordNum,
[src]
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>
[src]
Trait Implementations
impl<T> AbsDiffEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + AbsDiffEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
[src]
T: CoordNum + AbsDiffEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
type Epsilon = <T as AbsDiffEq<T>>::Epsilon
Used for specifying relative comparisons.
pub fn default_epsilon() -> <T as AbsDiffEq<T>>::Epsilon
[src]
pub fn abs_diff_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon
) -> bool
[src]
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon
) -> bool
pub fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
impl<T> Add<Coordinate<T>> for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
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>
The resulting type after applying the +
operator.
pub fn add(self, rhs: Coordinate<T>) -> Coordinate<T>
[src]
impl<T> Clone for Coordinate<T> where
T: Clone + CoordNum,
[src]
T: Clone + CoordNum,
pub fn clone(&self) -> Coordinate<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Contains<Coordinate<T>> for Geometry<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Coordinate<T>> for GeometryCollection<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Coordinate<T>> for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Coordinate<T>> for LineString<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Coordinate<T>> for Point<T> where
T: CoordNum,
[src]
T: CoordNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Coordinate<T>> for Polygon<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Coordinate<T>> for Rect<T> where
T: CoordNum,
[src]
T: CoordNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Coordinate<T>> for Triangle<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> CoordinatePosition for Coordinate<T> where
T: GeoNum,
[src]
T: GeoNum,
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
_boundary_count: &mut usize
)
[src]
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
_boundary_count: &mut usize
)
fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos
[src]
impl<T> Copy for Coordinate<T> where
T: Copy + CoordNum,
[src]
T: Copy + CoordNum,
impl<T> Debug for Coordinate<T> where
T: Debug + CoordNum,
[src]
T: Debug + CoordNum,
impl<T> Default for Coordinate<T> where
T: CoordNum + Default,
[src]
T: CoordNum + Default,
pub fn default() -> Coordinate<T>
[src]
impl<T> Div<T> for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
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>
The resulting type after applying the /
operator.
pub fn div(self, rhs: T) -> Coordinate<T>
[src]
impl<T> Eq for Coordinate<T> where
T: Eq + CoordNum,
[src]
T: Eq + CoordNum,
impl<T> EuclideanDistance<T, Coordinate<T>> for Coordinate<T> where
T: GeoFloat,
[src]
T: GeoFloat,
fn euclidean_distance(&self, c: &Coordinate<T>) -> T
[src]
Minimum distance between two Coordinate
s
impl<T> EuclideanDistance<T, Coordinate<T>> for Line<T> where
T: GeoFloat,
[src]
T: GeoFloat,
fn euclidean_distance(&self, coord: &Coordinate<T>) -> T
[src]
Minimum distance from a Line
to a Coordinate
impl<T> EuclideanDistance<T, Line<T>> for Coordinate<T> where
T: GeoFloat,
[src]
T: GeoFloat,
fn euclidean_distance(&self, line: &Line<T>) -> T
[src]
Minimum distance from a Coordinate
to a Line
impl<T> From<[T; 2]> for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn from(coords: [T; 2]) -> Coordinate<T>
[src]
impl<T> From<(T, T)> for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn from(coords: (T, T)) -> Coordinate<T>
[src]
impl<T> From<Coordinate<T>> for Point<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn from(x: Coordinate<T>) -> Point<T>
[src]
impl<T> From<Point<T>> for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn from(point: Point<T>) -> Coordinate<T>
[src]
impl<T> Hash for Coordinate<T> where
T: Hash + CoordNum,
[src]
T: Hash + CoordNum,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Intersects<Coordinate<T>> for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
[src]
impl<T> Intersects<Coordinate<T>> for Line<T> where
T: GeoNum,
[src]
T: GeoNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
[src]
impl<T> Intersects<Coordinate<T>> for Polygon<T> where
T: GeoNum,
[src]
T: GeoNum,
fn intersects(&self, p: &Coordinate<T>) -> bool
[src]
impl<T> Intersects<Coordinate<T>> for Rect<T> where
T: CoordNum,
[src]
T: CoordNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
[src]
impl<T> Intersects<Geometry<T>> for Coordinate<T> where
Geometry<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
Geometry<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
[src]
impl<T> Intersects<GeometryCollection<T>> for Coordinate<T> where
GeometryCollection<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
GeometryCollection<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &GeometryCollection<T>) -> bool
[src]
impl<T> Intersects<Line<T>> for Coordinate<T> where
Line<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
Line<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Line<T>) -> bool
[src]
impl<T> Intersects<LineString<T>> for Coordinate<T> where
LineString<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
LineString<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
[src]
impl<T> Intersects<MultiPoint<T>> for Coordinate<T> where
MultiPoint<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
MultiPoint<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiPoint<T>) -> bool
[src]
impl<T> Intersects<Point<T>> for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
[src]
impl<T> Intersects<Polygon<T>> for Coordinate<T> where
Polygon<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
Polygon<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Polygon<T>) -> bool
[src]
impl<T> Intersects<Rect<T>> for Coordinate<T> where
Rect<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
Rect<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Rect<T>) -> bool
[src]
impl<T> Intersects<Triangle<T>> for Coordinate<T> where
Triangle<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
Triangle<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
[src]
impl<T> Mul<T> for Coordinate<T> where
T: CoordNum,
[src]
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>
The resulting type after applying the *
operator.
pub fn mul(self, rhs: T) -> Coordinate<T>
[src]
impl<T> Neg for Coordinate<T> where
T: CoordNum + Neg<Output = T>,
[src]
T: CoordNum + Neg<Output = T>,
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>
The resulting type after applying the -
operator.
pub fn neg(self) -> Coordinate<T>
[src]
impl<T> PartialEq<Coordinate<T>> for Coordinate<T> where
T: PartialEq<T> + CoordNum,
[src]
T: PartialEq<T> + CoordNum,
pub fn eq(&self, other: &Coordinate<T>) -> bool
[src]
pub fn ne(&self, other: &Coordinate<T>) -> bool
[src]
impl<T> Point for Coordinate<T> where
T: Float + RTreeNum,
[src]
T: Float + RTreeNum,
type Scalar = T
The number type used by this point type.
pub const DIMENSIONS: usize
[src]
pub fn generate(
generator: impl Fn(usize) -> <Coordinate<T> as Point>::Scalar
) -> Coordinate<T>
[src]
generator: impl Fn(usize) -> <Coordinate<T> as Point>::Scalar
) -> Coordinate<T>
pub fn nth(&self, index: usize) -> <Coordinate<T> as Point>::Scalar
[src]
pub fn nth_mut(&mut self, index: usize) -> &mut <Coordinate<T> as Point>::Scalar
[src]
impl<T> RelativeEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + RelativeEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
[src]
T: CoordNum + RelativeEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
pub fn default_max_relative() -> <T as AbsDiffEq<T>>::Epsilon
[src]
pub fn relative_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_relative: <T as AbsDiffEq<T>>::Epsilon
) -> bool
[src]
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_relative: <T as AbsDiffEq<T>>::Epsilon
) -> bool
pub fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
impl<T> StructuralEq for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> StructuralPartialEq for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> Sub<Coordinate<T>> for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
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>
The resulting type after applying the -
operator.
pub fn sub(self, rhs: Coordinate<T>) -> Coordinate<T>
[src]
impl<T> UlpsEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum + UlpsEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
[src]
T: CoordNum + UlpsEq<T>,
<T as AbsDiffEq<T>>::Epsilon: Copy,
pub fn default_max_ulps() -> u32
[src]
pub fn ulps_eq(
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_ulps: u32
) -> bool
[src]
&self,
other: &Coordinate<T>,
epsilon: <T as AbsDiffEq<T>>::Epsilon,
max_ulps: u32
) -> bool
pub fn ulps_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_ulps: u32
) -> bool
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_ulps: u32
) -> bool
impl<T> Zero for Coordinate<T> where
T: CoordNum,
[src]
T: CoordNum,
Auto Trait Implementations
impl<T> RefUnwindSafe for Coordinate<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Coordinate<T> where
T: Send,
T: Send,
impl<T> Sync for Coordinate<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Coordinate<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Coordinate<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<P> PointDistance for P where
P: Point,
[src]
P: Point,
pub fn distance_2(&self, point: &P) -> <P as Point>::Scalar
[src]
pub fn contains_point(
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
[src]
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
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>
[src]
&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>
impl<P> RTreeObject for P where
P: Point,
[src]
P: Point,
type Envelope = AABB<P>
The object’s envelope type. Usually, AABB will be the right choice. This type also defines the objects dimensionality. Read more
pub fn envelope(&self) -> AABB<P>
[src]
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,