Struct geo::Point [−][src]
pub struct Point<T>(pub Coordinate<T>)
where
T: CoordinateType;
A single Point in 2D space.
Points can be created using the new(x, y) constructor, or from a Coordinate or pair of points.
use geo_types::{Point, Coordinate}; 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 + ToPrimitive, [src]
impl<T> Point<T> where
T: CoordinateType + ToPrimitive, pub fn new(x: T, y: T) -> Point<T>[src]
pub fn new(x: T, y: T) -> Point<T>Creates a new point.
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]
pub fn x(&self) -> TReturns the x/horizontal component of the point.
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]
pub fn set_x(&mut self, x: T) -> &mut Point<T>Sets the x/horizontal component of the point.
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]
pub fn y(&self) -> TReturns the y/vertical component of the point.
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]
pub fn set_y(&mut self, y: T) -> &mut Point<T>Sets the y/vertical component of the point.
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 lng(&self) -> T[src]
pub fn lng(&self) -> TReturns the longitude/horizontal component of the point.
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]
pub fn set_lng(&mut self, lng: T) -> &mut Point<T>Sets the longitude/horizontal component of the point.
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]
pub fn lat(&self) -> TReturns the latitude/vertical component of the point.
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]
pub fn set_lat(&mut self, lat: T) -> &mut Point<T>Sets the latitude/vertical component of the point.
use geo_types::Point; let mut p = Point::new(1.234, 2.345); p.set_lat(9.876); assert_eq!(p.lat(), 9.876);
pub fn dot(&self, point: &Point<T>) -> T[src]
pub fn dot(&self, point: &Point<T>) -> TReturns the dot product of the two points:
dot = x1 * x2 + y1 * y2
use geo_types::Point; let p = Point::new(1.5, 0.5); let dot = p.dot(&Point::new(2.0, 4.5)); assert_eq!(dot, 5.25);
pub fn cross_prod(&self, point_b: &Point<T>, point_c: &Point<T>) -> T where
T: Float, [src]
pub fn cross_prod(&self, point_b: &Point<T>, point_c: &Point<T>) -> T where
T: Float, 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::Point; let p_a = Point::new(1.0, 2.0); let p_b = Point::new(3.0,5.0); let p_c = Point::new(7.0,12.0); let cross = p_a.cross_prod(&p_b, &p_c); assert_eq!(cross, 2.0)
Trait Implementations
impl<T> Add<Point<T>> for Point<T> where
T: CoordinateType + ToPrimitive, [src]
impl<T> Add<Point<T>> for Point<T> where
T: CoordinateType + ToPrimitive, type Output = Point<T>
The resulting type after applying the + operator.
fn add(self, rhs: Point<T>) -> Point<T>[src]
fn add(self, rhs: Point<T>) -> Point<T>Add a point to the given point.
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> TwoDimensional for Point<T> where
T: Float + SpadeNum + Debug, [src]
impl<T> TwoDimensional for Point<T> where
T: Float + SpadeNum + Debug, impl<T> Sub<Point<T>> for Point<T> where
T: CoordinateType + ToPrimitive, [src]
impl<T> Sub<Point<T>> for Point<T> where
T: CoordinateType + ToPrimitive, type Output = Point<T>
The resulting type after applying the - operator.
fn sub(self, rhs: Point<T>) -> Point<T>[src]
fn sub(self, rhs: Point<T>) -> Point<T>Subtract a point from the given point.
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> Clone for Point<T> where
T: Clone + CoordinateType, [src]
impl<T> Clone for Point<T> where
T: Clone + CoordinateType, fn clone(&self) -> Point<T>[src]
fn clone(&self) -> Point<T>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<T> Debug for Point<T> where
T: Debug + CoordinateType, [src]
impl<T> Debug for Point<T> where
T: Debug + CoordinateType, fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl<T> Copy for Point<T> where
T: Copy + CoordinateType, [src]
impl<T> Copy for Point<T> where
T: Copy + CoordinateType, impl<T> Neg for Point<T> where
T: CoordinateType + Neg<Output = T> + ToPrimitive, [src]
impl<T> Neg for Point<T> where
T: CoordinateType + Neg<Output = T> + ToPrimitive, type Output = Point<T>
The resulting type after applying the - operator.
fn neg(self) -> Point<T>[src]
fn neg(self) -> Point<T>Returns a point with the x and y components negated.
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]
impl<T> PartialEq<Point<T>> for Point<T> where
T: PartialEq<T> + CoordinateType, fn eq(&self, other: &Point<T>) -> bool[src]
fn eq(&self, other: &Point<T>) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Point<T>) -> bool[src]
fn ne(&self, other: &Point<T>) -> boolThis method tests for !=.
impl<T> PointN for Point<T> where
T: Float + SpadeNum + Debug, [src]
impl<T> PointN for Point<T> where
T: Float + SpadeNum + Debug, type Scalar = T
The points's internal scalar type.
fn dimensions() -> usize[src]
fn dimensions() -> usizeThe (fixed) number of dimensions of this point type.
fn from_value(value: <Point<T> as PointN>::Scalar) -> Point<T>[src]
fn from_value(value: <Point<T> as PointN>::Scalar) -> Point<T>Creates a new point with all components set to a certain value.
fn nth(&self, index: usize) -> &<Point<T> as PointN>::Scalar[src]
fn nth(&self, index: usize) -> &<Point<T> as PointN>::ScalarReturns the nth element of this point.
fn nth_mut(&mut self, index: usize) -> &mut <Point<T> as PointN>::Scalar[src]
fn nth_mut(&mut self, index: usize) -> &mut <Point<T> as PointN>::ScalarReturns a mutable reference to the nth element of this point.
impl<T> From<Point<T>> for Geometry<T> where
T: CoordinateType, [src]
impl<T> From<Point<T>> for Geometry<T> where
T: CoordinateType, impl<T> From<(T, T)> for Point<T> where
T: CoordinateType, [src]
impl<T> From<(T, T)> for Point<T> where
T: CoordinateType, impl<T> From<Coordinate<T>> for Point<T> where
T: CoordinateType, [src]
impl<T> From<Coordinate<T>> for Point<T> where
T: CoordinateType, fn from(x: Coordinate<T>) -> Point<T>[src]
fn from(x: Coordinate<T>) -> Point<T>Performs the conversion.
impl<T> From<[T; 2]> for Point<T> where
T: CoordinateType, [src]
impl<T> From<[T; 2]> for Point<T> where
T: CoordinateType, impl<T> Centroid<T> for Point<T> where
T: Float, [src]
impl<T> Centroid<T> for Point<T> where
T: Float, type Output = Point<T>
fn centroid(&self) -> Self::Output[src]
fn centroid(&self) -> Self::OutputSee: https://en.wikipedia.org/wiki/Centroid Read more
impl<T> Contains<Point<T>> for Point<T> where
T: Float + ToPrimitive, [src]
impl<T> Contains<Point<T>> for Point<T> where
T: Float + ToPrimitive, fn contains(&self, p: &Point<T>) -> bool[src]
fn contains(&self, p: &Point<T>) -> boolChecks if rhs is completely contained within self. Read more
impl<T> Contains<Point<T>> for LineString<T> where
T: Float, [src]
impl<T> Contains<Point<T>> for LineString<T> where
T: Float, fn contains(&self, p: &Point<T>) -> bool[src]
fn contains(&self, p: &Point<T>) -> boolChecks if rhs is completely contained within self. Read more
impl<T> Contains<Point<T>> for Line<T> where
T: Float, [src]
impl<T> Contains<Point<T>> for Line<T> where
T: Float, fn contains(&self, p: &Point<T>) -> bool[src]
fn contains(&self, p: &Point<T>) -> boolChecks if rhs is completely contained within self. Read more
impl<T> Contains<Point<T>> for Polygon<T> where
T: Float, [src]
impl<T> Contains<Point<T>> for Polygon<T> where
T: Float, fn contains(&self, p: &Point<T>) -> bool[src]
fn contains(&self, p: &Point<T>) -> boolChecks if rhs is completely contained within self. Read more
impl<T> Contains<Point<T>> for MultiPolygon<T> where
T: Float, [src]
impl<T> Contains<Point<T>> for MultiPolygon<T> where
T: Float, fn contains(&self, p: &Point<T>) -> bool[src]
fn contains(&self, p: &Point<T>) -> boolChecks if rhs is completely contained within self. Read more
impl<T> Contains<Point<T>> for Bbox<T> where
T: CoordinateType, [src]
impl<T> Contains<Point<T>> for Bbox<T> where
T: CoordinateType, fn contains(&self, p: &Point<T>) -> bool[src]
fn contains(&self, p: &Point<T>) -> boolChecks if rhs is completely contained within self. Read more
impl<T> Intersects<Point<T>> for Line<T> where
T: Float, [src]
impl<T> Intersects<Point<T>> for Line<T> where
T: Float, fn intersects(&self, p: &Point<T>) -> bool[src]
fn intersects(&self, p: &Point<T>) -> boolChecks if the geometry A intersects the geometry B. Read more
impl<T> Intersects<Line<T>> for Point<T> where
T: Float, [src]
impl<T> Intersects<Line<T>> for Point<T> where
T: Float, fn intersects(&self, line: &Line<T>) -> bool[src]
fn intersects(&self, line: &Line<T>) -> boolChecks if the geometry A intersects the geometry B. Read more
impl<T> Bearing<T> for Point<T> where
T: Float + FromPrimitive, [src]
impl<T> Bearing<T> for Point<T> where
T: Float + FromPrimitive, fn bearing(&self, point: Point<T>) -> T[src]
fn bearing(&self, point: Point<T>) -> TReturns the bearing to another Point in degrees, where North is 0° and East is 45°. Read more
impl<T> EuclideanDistance<T, Point<T>> for Point<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Point<T>> for Point<T> where
T: Float, fn euclidean_distance(&self, p: &Point<T>) -> T[src]
fn euclidean_distance(&self, p: &Point<T>) -> TMinimum distance between two Points
impl<T> EuclideanDistance<T, MultiPoint<T>> for Point<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, MultiPoint<T>> for Point<T> where
T: Float, fn euclidean_distance(&self, points: &MultiPoint<T>) -> T[src]
fn euclidean_distance(&self, points: &MultiPoint<T>) -> TMinimum distance from a Point to a MultiPoint
impl<T> EuclideanDistance<T, Point<T>> for MultiPoint<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Point<T>> for MultiPoint<T> where
T: Float, fn euclidean_distance(&self, point: &Point<T>) -> T[src]
fn euclidean_distance(&self, point: &Point<T>) -> TMinimum distance from a MultiPoint to a Point
impl<T> EuclideanDistance<T, Polygon<T>> for Point<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Polygon<T>> for Point<T> where
T: Float, fn euclidean_distance(&self, polygon: &Polygon<T>) -> T[src]
fn euclidean_distance(&self, polygon: &Polygon<T>) -> TMinimum distance from a Point to a Polygon
impl<T> EuclideanDistance<T, Point<T>> for Polygon<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Point<T>> for Polygon<T> where
T: Float, fn euclidean_distance(&self, point: &Point<T>) -> T[src]
fn euclidean_distance(&self, point: &Point<T>) -> TMinimum distance from a Polygon to a Point
impl<T> EuclideanDistance<T, MultiPolygon<T>> for Point<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, MultiPolygon<T>> for Point<T> where
T: Float, fn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> T[src]
fn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> TMinimum distance from a Point to a MultiPolygon
impl<T> EuclideanDistance<T, Point<T>> for MultiPolygon<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Point<T>> for MultiPolygon<T> where
T: Float, fn euclidean_distance(&self, point: &Point<T>) -> T[src]
fn euclidean_distance(&self, point: &Point<T>) -> TMinimum distance from a MultiPolygon to a Point
impl<T> EuclideanDistance<T, MultiLineString<T>> for Point<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, MultiLineString<T>> for Point<T> where
T: Float, fn euclidean_distance(&self, mls: &MultiLineString<T>) -> T[src]
fn euclidean_distance(&self, mls: &MultiLineString<T>) -> TMinimum distance from a Point to a MultiLineString
impl<T> EuclideanDistance<T, Point<T>> for MultiLineString<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Point<T>> for MultiLineString<T> where
T: Float, fn euclidean_distance(&self, point: &Point<T>) -> T[src]
fn euclidean_distance(&self, point: &Point<T>) -> TMinimum distance from a MultiLineString to a Point
impl<T> EuclideanDistance<T, LineString<T>> for Point<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, LineString<T>> for Point<T> where
T: Float, fn euclidean_distance(&self, linestring: &LineString<T>) -> T[src]
fn euclidean_distance(&self, linestring: &LineString<T>) -> TMinimum distance from a Point to a LineString
impl<T> EuclideanDistance<T, Point<T>> for LineString<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Point<T>> for LineString<T> where
T: Float, fn euclidean_distance(&self, point: &Point<T>) -> T[src]
fn euclidean_distance(&self, point: &Point<T>) -> TMinimum distance from a LineString to a Point
impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: Float, fn euclidean_distance(&self, point: &Point<T>) -> T[src]
fn euclidean_distance(&self, point: &Point<T>) -> TMinimum distance from a Line to a Point
impl<T> EuclideanDistance<T, Line<T>> for Point<T> where
T: Float, [src]
impl<T> EuclideanDistance<T, Line<T>> for Point<T> where
T: Float, fn euclidean_distance(&self, line: &Line<T>) -> T[src]
fn euclidean_distance(&self, line: &Line<T>) -> TMinimum distance from a Line to a Point
impl<T> HaversineIntermediate<T> for Point<T> where
T: Float + FromPrimitive, [src]
impl<T> HaversineIntermediate<T> for Point<T> where
T: Float + FromPrimitive, fn haversine_intermediate(&self, other: &Point<T>, f: T) -> Point<T>[src]
fn haversine_intermediate(&self, other: &Point<T>, f: T) -> Point<T>Returns a new Point along a great circle route between two existing points. Read more
fn haversine_intermediate_fill(
&self,
other: &Point<T>,
max_dist: T,
include_ends: bool
) -> Vec<Point<T>>[src]
fn haversine_intermediate_fill(
&self,
other: &Point<T>,
max_dist: T,
include_ends: bool
) -> Vec<Point<T>>impl<T> HaversineDestination<T> for Point<T> where
T: Float + FromPrimitive, [src]
impl<T> HaversineDestination<T> for Point<T> where
T: Float + FromPrimitive, fn haversine_destination(&self, bearing: T, distance: T) -> Point<T>[src]
fn haversine_destination(&self, bearing: T, distance: T) -> Point<T>Returns a new Point using distance to the existing Point and a bearing for the direction Read more
impl<T> HaversineDistance<T, Point<T>> for Point<T> where
T: Float + FromPrimitive, [src]
impl<T> HaversineDistance<T, Point<T>> for Point<T> where
T: Float + FromPrimitive, fn haversine_distance(&self, rhs: &Point<T>) -> T[src]
fn haversine_distance(&self, rhs: &Point<T>) -> TReturns the Haversine distance between two points: Read more
impl<T> Rotate<T> for Point<T> where
T: Float, [src]
impl<T> Rotate<T> for Point<T> where
T: Float, fn rotate(&self, angle: T) -> Self[src]
fn rotate(&self, angle: T) -> SelfRotate the Point about itself by the given number of degrees This operation leaves the point coordinates unchanged
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Point<T>[src]
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Point<T>type Output = Point<NT>
fn map_coords(&self, func: &Fn(&(T, T)) -> (NT, NT)) -> Self::Output[src]
fn map_coords(&self, func: &Fn(&(T, T)) -> (NT, NT)) -> Self::OutputApply a function to all the coordinates in a geometric object, returning a new object. Read more
impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for Point<T>[src]
impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for Point<T>type Output = Point<NT>
fn try_map_coords(
&self,
func: &Fn(&(T, T)) -> Result<(NT, NT), Error>
) -> Result<Self::Output, Error>[src]
fn try_map_coords(
&self,
func: &Fn(&(T, T)) -> Result<(NT, NT), Error>
) -> Result<Self::Output, Error>Map a fallible function over all the coordinates in a geometry, returning a Result Read more
impl<T: CoordinateType> MapCoordsInplace<T> for Point<T>[src]
impl<T: CoordinateType> MapCoordsInplace<T> for Point<T>fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T))[src]
fn map_coords_inplace(&mut self, func: &Fn(&(T, T)) -> (T, T))Apply a function to all the coordinates in a geometric object, in place Read more
impl<F: Float> ClosestPoint<F> for Point<F>[src]
impl<F: Float> ClosestPoint<F> for Point<F>fn closest_point(&self, p: &Self) -> Closest<F>[src]
fn closest_point(&self, p: &Self) -> Closest<F>Find the closest point between self and p.
impl<T> VincentyDistance<T, Point<T>> for Point<T> where
T: Float + FromPrimitive, [src]
impl<T> VincentyDistance<T, Point<T>> for Point<T> where
T: Float + FromPrimitive, fn vincenty_distance(&self, rhs: &Point<T>) -> Result<T, FailedToConvergeError>[src]
fn vincenty_distance(&self, rhs: &Point<T>) -> Result<T, FailedToConvergeError>The units of the returned value is meters.