[−][src]Struct geo_types::Coordinate
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: CoordinateType,
[src]
T: CoordinateType,
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);
Trait Implementations
impl<T> Add<Coordinate<T>> for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
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.
fn add(self, rhs: Coordinate<T>) -> Coordinate<T>
[src]
impl<T: Clone> Clone for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn clone(&self) -> Coordinate<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Copy> Copy for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T: Debug> Debug for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Div<T> for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
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.
fn div(self, rhs: T) -> Coordinate<T>
[src]
impl<T: Eq> Eq for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T: CoordinateType> From<[T; 2]> for Coordinate<T>
[src]
impl<T: CoordinateType> From<(T, T)> for Coordinate<T>
[src]
impl<T: CoordinateType> From<Coordinate<T>> for Point<T>
[src]
fn from(x: Coordinate<T>) -> Point<T>
[src]
impl<T: CoordinateType> From<Point<T>> for Coordinate<T>
[src]
impl<T: Hash> Hash for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Mul<T> for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
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.
fn mul(self, rhs: T) -> Coordinate<T>
[src]
impl<T> Neg for Coordinate<T> where
T: CoordinateType + Neg<Output = T>,
[src]
T: CoordinateType + 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.
fn neg(self) -> Coordinate<T>
[src]
impl<T: PartialEq> PartialEq<Coordinate<T>> for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn eq(&self, other: &Coordinate<T>) -> bool
[src]
fn ne(&self, other: &Coordinate<T>) -> bool
[src]
impl<T> StructuralEq for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> StructuralPartialEq for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Sub<Coordinate<T>> for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
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.
fn sub(self, rhs: Coordinate<T>) -> Coordinate<T>
[src]
impl<T: CoordinateType> Zero for Coordinate<T>
[src]
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.);
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,
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<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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.
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>,