Struct geohash::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
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
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
Performs the conversion.
Performs the conversion.
Performs the conversion.
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 !=
.
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
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