[−][src]Struct geo::Point
A single point in 2D space.
Points can be created using the new(x, y)
constructor, the point!
macro, a Coordinate
, or from
two-element tuples or arrays – see the From
impl section for a complete list.
Examples
use geo_types::{Coordinate, Point}; let p1: Point<f64> = (0., 1.).into(); let c = Coordinate { x: 10., y: 20. }; let p2: Point<f64> = c.into();
Methods
impl<T> Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
pub fn new(x: T, y: T) -> Point<T>
[src]
Creates a new point.
Examples
use geo_types::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.x(), 1.234); assert_eq!(p.y(), 2.345);
pub fn x(self) -> T
[src]
Returns the x/horizontal component of the point.
Examples
use geo_types::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.x(), 1.234);
pub fn set_x(&mut self, x: T) -> &mut Point<T>
[src]
Sets the x/horizontal component of the point.
Examples
use geo_types::Point; let mut p = Point::new(1.234, 2.345); p.set_x(9.876); assert_eq!(p.x(), 9.876);
pub fn y(self) -> T
[src]
Returns the y/vertical component of the point.
Examples
use geo_types::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.y(), 2.345);
pub fn set_y(&mut self, y: T) -> &mut Point<T>
[src]
Sets the y/vertical component of the point.
Examples
use geo_types::Point; let mut p = Point::new(1.234, 2.345); p.set_y(9.876); assert_eq!(p.y(), 9.876);
pub fn x_y(self) -> (T, T)
[src]
Returns a tuple that contains the x/horizontal & y/vertical component of the point.
Examples
use geo_types::Point; let mut p = Point::new(1.234, 2.345); let (x, y) = p.x_y(); assert_eq!(y, 2.345); assert_eq!(x, 1.234);
pub fn lng(self) -> T
[src]
Returns the longitude/horizontal component of the point.
Examples
use geo_types::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.lng(), 1.234);
pub fn set_lng(&mut self, lng: T) -> &mut Point<T>
[src]
Sets the longitude/horizontal component of the point.
Examples
use geo_types::Point; let mut p = Point::new(1.234, 2.345); p.set_lng(9.876); assert_eq!(p.lng(), 9.876);
pub fn lat(self) -> T
[src]
Returns the latitude/vertical component of the point.
Examples
use geo_types::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.lat(), 2.345);
pub fn set_lat(&mut self, lat: T) -> &mut Point<T>
[src]
Sets the latitude/vertical component of the point.
Examples
use geo_types::Point; let mut p = Point::new(1.234, 2.345); p.set_lat(9.876); assert_eq!(p.lat(), 9.876);
impl<T> Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
pub fn dot(self, other: Point<T>) -> T
[src]
Returns the dot product of the two points:
dot = x1 * x2 + y1 * y2
Examples
use geo_types::{Coordinate, Point}; let point = Point(Coordinate { x: 1.5, y: 0.5 }); let dot = point.dot(Point(Coordinate { x: 2.0, y: 4.5 })); assert_eq!(dot, 5.25);
pub fn cross_prod(self, point_b: Point<T>, point_c: Point<T>) -> T
[src]
Returns the cross product of 3 points. A positive value implies
self
→ point_b
→ point_c
is counter-clockwise, negative implies
clockwise.
Examples
use geo_types::{Coordinate, Point}; let point_a = Point(Coordinate { x: 1., y: 2. }); let point_b = Point(Coordinate { x: 3., y: 5. }); let point_c = Point(Coordinate { x: 7., y: 12. }); let cross = point_a.cross_prod(point_b, point_c); assert_eq!(cross, 2.0)
impl<T> Point<T> where
T: CoordinateType + Float,
[src]
T: CoordinateType + Float,
pub fn to_degrees(self) -> Point<T>
[src]
Converts the (x,y) components of Point to degrees
Example
use geo_types::Point; let p = Point::new(1.234, 2.345); let (x, y): (f32, f32) = p.to_degrees().x_y(); assert_eq!(x.round(), 71.0); assert_eq!(y.round(), 134.0);
pub fn to_radians(self) -> Point<T>
[src]
Converts the (x,y) components of Point to radians
Example
use geo_types::Point; let p = Point::new(180.0, 341.5); let (x, y): (f32, f32) = p.to_radians().x_y(); assert_eq!(x.round(), 3.0); assert_eq!(y.round(), 6.0);
Trait Implementations
impl<T> Add<Point<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
type Output = Point<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Point<T>) -> Point<T>
[src]
Add a point to the given point.
Examples
use geo_types::Point; let p = Point::new(1.25, 2.5) + Point::new(1.5, 2.5); assert_eq!(p.x(), 2.75); assert_eq!(p.y(), 5.0);
impl<T> Bearing<T> for Point<T> where
T: Float,
[src]
T: Float,
impl<T> Centroid<T> for Point<T> where
T: Float,
[src]
T: Float,
impl<T> Clone for Point<T> where
T: Clone + CoordinateType,
[src]
T: Clone + CoordinateType,
impl<'a, F, C> ClosestPoint<F, Point<F>> for &'a C where
C: ClosestPoint<F>,
F: Float,
[src]
C: ClosestPoint<F>,
F: Float,
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<F: Float> ClosestPoint<F, Point<F>> for Point<F>
[src]
fn closest_point(&self, p: &Self) -> Closest<F>
[src]
impl<F: Float> ClosestPoint<F, Point<F>> for Line<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<F: Float> ClosestPoint<F, Point<F>> for LineString<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<F: Float> ClosestPoint<F, Point<F>> for Polygon<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<F: Float> ClosestPoint<F, Point<F>> for MultiPolygon<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<F: Float> ClosestPoint<F, Point<F>> for MultiPoint<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<F: Float> ClosestPoint<F, Point<F>> for MultiLineString<F>
[src]
fn closest_point(&self, p: &Point<F>) -> Closest<F>
[src]
impl<T> Contains<Point<T>> for Point<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<Point<T>> for LineString<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<Point<T>> for Line<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<Point<T>> for Polygon<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<Point<T>> for MultiPolygon<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<Point<T>> for Rect<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Contains<Point<T>> for Triangle<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Copy for Point<T> where
T: Copy + CoordinateType,
[src]
T: Copy + CoordinateType,
impl<T> Debug for Point<T> where
T: Debug + CoordinateType,
[src]
T: Debug + CoordinateType,
impl<T> EuclideanDistance<T, Line<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, line: &Line<T>) -> T
[src]
Minimum distance from a Line to a Point
impl<T> EuclideanDistance<T, LineString<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, linestring: &LineString<T>) -> T
[src]
Minimum distance from a Point to a LineString
impl<T> EuclideanDistance<T, MultiLineString<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, mls: &MultiLineString<T>) -> T
[src]
Minimum distance from a Point to a MultiLineString
impl<T> EuclideanDistance<T, MultiPoint<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, points: &MultiPoint<T>) -> T
[src]
Minimum distance from a Point to a MultiPoint
impl<T> EuclideanDistance<T, MultiPolygon<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> T
[src]
Minimum distance from a Point to a MultiPolygon
impl<T> EuclideanDistance<T, Point<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, p: &Point<T>) -> T
[src]
Minimum distance between two Points
impl<T> EuclideanDistance<T, Point<T>> for MultiPoint<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a MultiPoint to a Point
impl<T> EuclideanDistance<T, Point<T>> for Polygon<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a Polygon to a Point
impl<T> EuclideanDistance<T, Point<T>> for MultiPolygon<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a MultiPolygon to a Point
impl<T> EuclideanDistance<T, Point<T>> for MultiLineString<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a MultiLineString to a Point
impl<T> EuclideanDistance<T, Point<T>> for LineString<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a LineString to a Point
impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
Minimum distance from a Line to a Point
impl<T> EuclideanDistance<T, Point<T>> for Triangle<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
impl<T> EuclideanDistance<T, Polygon<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn euclidean_distance(&self, polygon: &Polygon<T>) -> T
[src]
Minimum distance from a Point to a Polygon
impl<T> From<[T; 2]> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> From<(T, T)> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> From<Coordinate<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn from(x: Coordinate<T>) -> Point<T>
[src]
impl<T> From<Point<T>> for Coordinate<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn from(point: Point<T>) -> Coordinate<T>
[src]
impl<T> From<Point<T>> for Geometry<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Hash for Point<T> where
T: Hash + CoordinateType,
[src]
T: Hash + CoordinateType,
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> HaversineDestination<T> for Point<T> where
T: Float + FromPrimitive,
[src]
T: Float + FromPrimitive,
fn haversine_destination(&self, bearing: T, distance: T) -> Point<T>
[src]
impl<T> HaversineDistance<T, Point<T>> for Point<T> where
T: Float + FromPrimitive,
[src]
T: Float + FromPrimitive,
fn haversine_distance(&self, rhs: &Point<T>) -> T
[src]
impl<T> HaversineIntermediate<T> for Point<T> where
T: Float + FromPrimitive,
[src]
T: Float + FromPrimitive,
fn haversine_intermediate(&self, other: &Point<T>, f: T) -> Point<T>
[src]
fn haversine_intermediate_fill(
&self,
other: &Point<T>,
max_dist: T,
include_ends: bool
) -> Vec<Point<T>>
[src]
&self,
other: &Point<T>,
max_dist: T,
include_ends: bool
) -> Vec<Point<T>>
impl<T> Intersects<Line<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, line: &Line<T>) -> bool
[src]
impl<T> Intersects<Point<T>> for Line<T> where
T: Float,
[src]
T: Float,
fn intersects(&self, p: &Point<T>) -> bool
[src]
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Point<T>
[src]
type Output = Point<NT>
fn map_coords(&self, func: impl Fn(&(T, T)) -> (NT, NT) + Copy) -> Self::Output
[src]
impl<T: CoordinateType> MapCoordsInplace<T> for Point<T>
[src]
impl<T> Neg for Point<T> where
T: CoordinateType + Neg<Output = T>,
[src]
T: CoordinateType + Neg<Output = T>,
type Output = Point<T>
The resulting type after applying the -
operator.
fn neg(self) -> Point<T>
[src]
Returns a point with the x and y components negated.
Examples
use geo_types::Point; let p = -Point::new(-1.25, 2.5); assert_eq!(p.x(), 1.25); assert_eq!(p.y(), -2.5);
impl<T> PartialEq<Point<T>> for Point<T> where
T: PartialEq<T> + CoordinateType,
[src]
T: PartialEq<T> + CoordinateType,
impl<T> Point for Point<T> where
T: Float + RTreeNum,
[src]
T: Float + RTreeNum,
type Scalar = T
The number type used by this point type.
const DIMENSIONS: usize
[src]
fn generate(
generator: impl Fn(usize) -> <Point<T> as Point>::Scalar
) -> Point<T>
[src]
generator: impl Fn(usize) -> <Point<T> as Point>::Scalar
) -> Point<T>
fn nth(&self, index: usize) -> <Point<T> as Point>::Scalar
[src]
fn nth_mut(&mut self, index: usize) -> &mut <Point<T> as Point>::Scalar
[src]
impl<T> Rotate<T> for Point<T> where
T: Float,
[src]
T: Float,
fn rotate(&self, _angle: T) -> Self
[src]
Rotate the Point about itself by the given number of degrees This operation leaves the point coordinates unchanged
impl<T> StructuralPartialEq for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Sub<Point<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
type Output = Point<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Point<T>) -> Point<T>
[src]
Subtract a point from the given point.
Examples
use geo_types::Point; let p = Point::new(1.25, 3.0) - Point::new(1.5, 2.5); assert_eq!(p.x(), -0.25); assert_eq!(p.y(), 0.5);
impl<T> TryFrom<Geometry<T>> for Point<T> where
T: Float,
[src]
T: Float,
type Error = FailedToConvertError
The type returned in the event of a conversion error.
fn try_from(
geom: Geometry<T>
) -> Result<Point<T>, <Point<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<Point<T>, <Point<T> as TryFrom<Geometry<T>>>::Error>
impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for Point<T>
[src]
type Output = Point<NT>
fn try_map_coords(
&self,
func: impl Fn(&(T, T)) -> Result<(NT, NT), Box<dyn Error + Send + Sync>>
) -> Result<Self::Output, Box<dyn Error + Send + Sync>>
[src]
&self,
func: impl Fn(&(T, T)) -> Result<(NT, NT), Box<dyn Error + Send + Sync>>
) -> Result<Self::Output, Box<dyn Error + Send + Sync>>
impl<T> VincentyDistance<T, Point<T>> for Point<T> where
T: Float + FromPrimitive,
[src]
T: Float + FromPrimitive,
fn vincenty_distance(&self, rhs: &Point<T>) -> Result<T, FailedToConvergeError>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Point<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Point<T> where
T: Send,
T: Send,
impl<T> Sync for Point<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Point<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Point<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<P> PointDistance for P where
P: Point,
[src]
P: Point,
fn distance_2(&self, point: &P) -> <P as Point>::Scalar
[src]
fn contains_point(
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
[src]
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
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
fn envelope(&self) -> AABB<P>
[src]
impl<T, G> RotatePoint<T> for G where
G: MapCoords<T, T, Output = G>,
T: Float,
[src]
G: MapCoords<T, T, Output = G>,
T: Float,
fn rotate_around_point(&Self, T, Point<T>) -> G
[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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, G> Translate<T> for G where
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
T: CoordinateType,
[src]
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
T: CoordinateType,
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>,