Struct geo_types::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: Ty: TImplementations
sourceimpl<T> Coordinate<T> where
T: CoordNum,
impl<T> Coordinate<T> where
T: CoordNum,
sourceimpl<T: CoordNum> Coordinate<T>
impl<T: CoordNum> Coordinate<T>
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
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::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.
sourcefn add(self, rhs: Coordinate<T>) -> Coordinate<T>
fn add(self, rhs: Coordinate<T>) -> Coordinate<T>
Performs the + operation. Read more
sourceimpl<T: Clone> Clone for Coordinate<T> where
T: CoordNum,
impl<T: Clone> Clone for Coordinate<T> where
T: 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<T: Debug> Debug for Coordinate<T> where
T: CoordNum,
impl<T: Debug> Debug for Coordinate<T> where
T: CoordNum,
sourceimpl<T: Default + CoordNum> Default for Coordinate<T>
impl<T: Default + CoordNum> Default for Coordinate<T>
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::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.
sourcefn div(self, rhs: T) -> Coordinate<T>
fn div(self, rhs: T) -> Coordinate<T>
Performs the / operation. Read more
sourceimpl<T: CoordNum> From<Coordinate<T>> for (T, T)
impl<T: CoordNum> From<Coordinate<T>> for (T, T)
sourcefn from(coord: Coordinate<T>) -> Self
fn from(coord: Coordinate<T>) -> Self
Performs the conversion.
sourceimpl<T: CoordNum> From<Coordinate<T>> for [T; 2]
impl<T: CoordNum> From<Coordinate<T>> for [T; 2]
sourcefn from(coord: Coordinate<T>) -> Self
fn from(coord: Coordinate<T>) -> Self
Performs the conversion.
sourceimpl<T: CoordNum> From<Coordinate<T>> for Point<T>
impl<T: CoordNum> From<Coordinate<T>> for Point<T>
sourcefn from(x: Coordinate<T>) -> Point<T>
fn from(x: Coordinate<T>) -> Point<T>
Performs the conversion.
sourceimpl<T: CoordNum> From<Point<T>> for Coordinate<T>
impl<T: CoordNum> From<Point<T>> for Coordinate<T>
sourceimpl<T: Hash> Hash for Coordinate<T> where
T: CoordNum,
impl<T: Hash> Hash for Coordinate<T> where
T: CoordNum,
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::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.
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::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.
sourcefn neg(self) -> Coordinate<T>
fn neg(self) -> Coordinate<T>
Performs the unary - operation. Read more
sourceimpl<T: PartialEq> PartialEq<Coordinate<T>> for Coordinate<T> where
T: CoordNum,
impl<T: PartialEq> PartialEq<Coordinate<T>> for Coordinate<T> where
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> 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::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.
sourcefn sub(self, rhs: Coordinate<T>) -> Coordinate<T>
fn sub(self, rhs: Coordinate<T>) -> Coordinate<T>
Performs the - operation. Read more
sourceimpl<T: CoordNum> Zero for Coordinate<T>
impl<T: CoordNum> Zero for Coordinate<T>
impl<T: Copy> Copy for Coordinate<T> where
T: CoordNum,
impl<T: Eq> Eq for Coordinate<T> where
T: 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 · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
