pub struct Point<T = f64>(pub Coordinate<T>)
where
T: CoordNum;
Expand description
A single point in 2D space.
Points can be created using the Point::new
constructor,
the point!
macro, or from a Coordinate
, two-element
tuples, or arrays – see the From
impl section for a
complete list.
Semantics
The interior of the point is itself (a singleton set),
and its boundary is empty. A point is valid if and
only if the Coordinate
is valid.
Examples
use geo_types::{coord, Point};
let p1: Point = (0., 1.).into();
let c = coord! { x: 10., y: 20. };
let p2: Point = c.into();
Tuple Fields
0: Coordinate<T>
Implementations
sourceimpl<T> Point<T> where
T: CoordNum,
impl<T> Point<T> where
T: CoordNum,
sourcepub fn new(x: T, y: T) -> Point<T>
pub fn new(x: T, y: T) -> Point<T>
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);
sourcepub fn x(self) -> T
pub fn x(self) -> T
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);
sourcepub fn set_x(&mut self, x: T) -> &mut Point<T>
pub fn set_x(&mut self, x: T) -> &mut Point<T>
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);
sourcepub fn y(self) -> T
pub fn y(self) -> T
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);
sourcepub fn set_y(&mut self, y: T) -> &mut Point<T>
pub fn set_y(&mut self, y: T) -> &mut Point<T>
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);
sourcepub fn x_y(self) -> (T, T)
pub fn x_y(self) -> (T, T)
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);
sourcepub fn lng(self) -> T
👎 Deprecated: use Point::x
instead, it’s less ambiguous
pub fn lng(self) -> T
use Point::x
instead, it’s less ambiguous
Returns the longitude/horizontal component of the point.
Examples
use geo_types::Point;
let p = Point::new(1.234, 2.345);
assert_eq!(p.x(), 1.234);
sourcepub fn set_lng(&mut self, lng: T) -> &mut Point<T>
👎 Deprecated: use Point::set_x
instead, it’s less ambiguous
pub fn set_lng(&mut self, lng: T) -> &mut Point<T>
use Point::set_x
instead, it’s less ambiguous
Sets the longitude/horizontal component of the point.
Examples
use geo_types::Point;
let mut p = Point::new(1.234, 2.345);
#[allow(deprecated)]
p.set_lng(9.876);
assert_eq!(p.x(), 9.876);
sourcepub fn lat(self) -> T
👎 Deprecated: use Point::y
instead, it’s less ambiguous
pub fn lat(self) -> T
use Point::y
instead, it’s less ambiguous
Returns the latitude/vertical component of the point.
Examples
use geo_types::Point;
let p = Point::new(1.234, 2.345);
assert_eq!(p.y(), 2.345);
sourcepub fn set_lat(&mut self, lat: T) -> &mut Point<T>
👎 Deprecated: use Point::set_y
instead, it’s less ambiguous
pub fn set_lat(&mut self, lat: T) -> &mut Point<T>
use Point::set_y
instead, it’s less ambiguous
Sets the latitude/vertical component of the point.
Examples
use geo_types::Point;
let mut p = Point::new(1.234, 2.345);
#[allow(deprecated)]
p.set_lat(9.876);
assert_eq!(p.y(), 9.876);
sourceimpl<T> Point<T> where
T: CoordNum,
impl<T> Point<T> where
T: CoordNum,
sourcepub fn dot(self, other: Point<T>) -> T
pub fn dot(self, other: Point<T>) -> T
Returns the dot product of the two points:
dot = x1 * x2 + y1 * y2
Examples
use geo_types::{point, Point};
let point = point! { x: 1.5, y: 0.5 };
let dot = point.dot(point! { x: 2.0, y: 4.5 });
assert_eq!(dot, 5.25);
sourcepub fn cross_prod(self, point_b: Point<T>, point_c: Point<T>) -> T
pub fn cross_prod(self, point_b: Point<T>, point_c: Point<T>) -> T
Returns the cross product of 3 points. A positive value implies
self
→ point_b
→ point_c
is counter-clockwise, negative implies
clockwise.
Note on Robustness
This function is not robust against floating-point errors.
The geo
crate
offers robust predicates for standard numeric types using the
Kernel
trait, and these should be preferred if possible.
Examples
use geo_types::point;
let point_a = point! { x: 1., y: 2. };
let point_b = point! { x: 3., y: 5. };
let point_c = point! { x: 7., y: 12. };
let cross = point_a.cross_prod(point_b, point_c);
assert_eq!(cross, 2.0)
sourceimpl<T> Point<T> where
T: CoordFloat,
impl<T> Point<T> where
T: CoordFloat,
sourcepub fn to_degrees(self) -> Point<T>
pub fn to_degrees(self) -> Point<T>
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);
sourcepub fn to_radians(self) -> Point<T>
pub fn to_radians(self) -> Point<T>
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
sourceimpl<T> AbsDiffEq<Point<T>> for Point<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
<T as AbsDiffEq<T>>::Epsilon: Copy,
impl<T> AbsDiffEq<Point<T>> for Point<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
<T as AbsDiffEq<T>>::Epsilon: Copy,
sourcefn abs_diff_eq(
&self,
other: &Point<T>,
epsilon: <Point<T> as AbsDiffEq<Point<T>>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &Point<T>,
epsilon: <Point<T> as AbsDiffEq<Point<T>>>::Epsilon
) -> bool
Equality assertion with an absolute limit.
Examples
use geo_types::Point;
let a = Point::new(2.0, 3.0);
let b = Point::new(2.0, 3.0000001);
approx::assert_relative_eq!(a, b, epsilon=0.1)
type Epsilon = <T as AbsDiffEq<T>>::Epsilon
type Epsilon = <T as AbsDiffEq<T>>::Epsilon
Used for specifying relative comparisons.
sourcefn default_epsilon() -> <Point<T> as AbsDiffEq<Point<T>>>::Epsilon
fn default_epsilon() -> <Point<T> as AbsDiffEq<Point<T>>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of [AbsDiffEq::abs_diff_eq
].
sourceimpl<T> Add<Point<T>> for Point<T> where
T: CoordNum,
impl<T> Add<Point<T>> for Point<T> where
T: CoordNum,
sourceimpl<T> AddAssign<Point<T>> for Point<T> where
T: CoordNum,
impl<T> AddAssign<Point<T>> for Point<T> where
T: CoordNum,
sourcefn add_assign(&mut self, rhs: Point<T>)
fn add_assign(&mut self, rhs: Point<T>)
Add a point to the given point and assign it to the original point.
Examples
use geo_types::Point;
let mut p = Point::new(1.25, 2.5);
p += Point::new(1.5, 2.5);
assert_eq!(p.x(), 2.75);
assert_eq!(p.y(), 5.0);
sourceimpl<T> Area<T> for Point<T> where
T: CoordNum,
impl<T> Area<T> for Point<T> where
T: CoordNum,
fn signed_area(&self) -> T
fn unsigned_area(&self) -> T
sourceimpl<T> Bearing<T> for Point<T> where
T: CoordFloat,
impl<T> Bearing<T> for Point<T> where
T: CoordFloat,
sourceimpl<T> BoundingRect<T> for Point<T> where
T: CoordNum,
impl<T> BoundingRect<T> for Point<T> where
T: CoordNum,
sourcefn bounding_rect(&self) -> Self::Output
fn bounding_rect(&self) -> Self::Output
Return the bounding rectangle for a Point
. It will have zero width
and zero height.
type Output = Rect<T>
sourceimpl<T> ChamberlainDuquetteArea<T> for Point<T> where
T: CoordFloat,
impl<T> ChamberlainDuquetteArea<T> for Point<T> where
T: CoordFloat,
fn chamberlain_duquette_signed_area(&self) -> T
fn chamberlain_duquette_unsigned_area(&self) -> T
sourceimpl<'a, F, C> ClosestPoint<F, Point<F>> for &'a C where
C: ClosestPoint<F>,
F: GeoFloat,
impl<'a, F, C> ClosestPoint<F, Point<F>> for &'a C where
C: ClosestPoint<F>,
F: GeoFloat,
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Point<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Point<F>
sourcefn closest_point(&self, p: &Self) -> Closest<F>
fn closest_point(&self, p: &Self) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for MultiLineString<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for MultiLineString<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for GeometryCollection<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for GeometryCollection<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Geometry<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Geometry<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Line<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Line<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for LineString<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for LineString<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Polygon<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Polygon<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Coordinate<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Coordinate<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Triangle<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Triangle<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Rect<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Rect<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for MultiPolygon<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for MultiPolygon<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for MultiPoint<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for MultiPoint<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<T> Contains<Coordinate<T>> for Point<T> where
T: CoordNum,
impl<T> Contains<Coordinate<T>> for Point<T> where
T: CoordNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<T> Contains<Point<T>> for GeometryCollection<T> where
T: GeoNum,
impl<T> Contains<Point<T>> for GeometryCollection<T> where
T: GeoNum,
sourceimpl<T> Contains<Point<T>> for LineString<T> where
T: GeoNum,
impl<T> Contains<Point<T>> for LineString<T> where
T: GeoNum,
sourceimpl<T> Contains<Point<T>> for MultiPolygon<T> where
T: GeoNum,
impl<T> Contains<Point<T>> for MultiPolygon<T> where
T: GeoNum,
sourceimpl<T> CoordinatePosition for Point<T> where
T: GeoNum,
impl<T> CoordinatePosition for Point<T> where
T: GeoNum,
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
_boundary_count: &mut usize
)
fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos
sourceimpl<'a, T: CoordNum> CoordsIter<'a> for Point<T>
impl<'a, T: CoordNum> CoordsIter<'a> for Point<T>
sourcefn coords_count(&'a self) -> usize
fn coords_count(&'a self) -> usize
Return the number of coordinates in the Point
.
type Iter = Once<Coordinate<T>>
type ExteriorIter = <Point<T> as CoordsIter<'a>>::Iter
type Scalar = T
sourcefn coords_iter(&'a self) -> Self::Iter
fn coords_iter(&'a self) -> Self::Iter
Iterate over all exterior and (if any) interior coordinates of a geometry. Read more
sourcefn exterior_coords_iter(&'a self) -> Self::ExteriorIter
fn exterior_coords_iter(&'a self) -> Self::ExteriorIter
Iterate over all exterior coordinates of a geometry. Read more
sourceimpl<T> DivAssign<T> for Point<T> where
T: CoordNum,
impl<T> DivAssign<T> for Point<T> where
T: CoordNum,
sourcefn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Scaler division of a point in place
Examples
use geo_types::Point;
let mut p = Point::new(2.0, 3.0);
p /= 2.0;
assert_eq!(p.x(), 1.0);
assert_eq!(p.y(), 1.5);
sourceimpl<T> EuclideanDistance<T, Line<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Line<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, line: &Line<T>) -> T
fn euclidean_distance(&self, line: &Line<T>) -> T
Minimum distance from a Line to a Point
sourceimpl<T> EuclideanDistance<T, LineString<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, LineString<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, linestring: &LineString<T>) -> T
fn euclidean_distance(&self, linestring: &LineString<T>) -> T
Minimum distance from a Point to a LineString
sourceimpl<T> EuclideanDistance<T, MultiLineString<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, MultiLineString<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, mls: &MultiLineString<T>) -> T
fn euclidean_distance(&self, mls: &MultiLineString<T>) -> T
Minimum distance from a Point to a MultiLineString
sourceimpl<T> EuclideanDistance<T, MultiPoint<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, MultiPoint<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, points: &MultiPoint<T>) -> T
fn euclidean_distance(&self, points: &MultiPoint<T>) -> T
Minimum distance from a Point to a MultiPoint
sourceimpl<T> EuclideanDistance<T, MultiPolygon<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, MultiPolygon<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> T
fn euclidean_distance(&self, mpolygon: &MultiPolygon<T>) -> T
Minimum distance from a Point to a MultiPolygon
sourceimpl<T> EuclideanDistance<T, Point<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, p: &Point<T>) -> T
fn euclidean_distance(&self, p: &Point<T>) -> T
Minimum distance between two Points
sourceimpl<T> EuclideanDistance<T, Point<T>> for MultiPoint<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for MultiPoint<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a MultiPoint to a Point
sourceimpl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a Line to a Point
sourceimpl<T> EuclideanDistance<T, Point<T>> for LineString<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for LineString<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a LineString to a Point
sourceimpl<T> EuclideanDistance<T, Point<T>> for MultiLineString<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for MultiLineString<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a MultiLineString to a Point
sourceimpl<T> EuclideanDistance<T, Point<T>> for Polygon<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for Polygon<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a Polygon to a Point
sourceimpl<T> EuclideanDistance<T, Point<T>> for MultiPolygon<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for MultiPolygon<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Minimum distance from a MultiPolygon to a Point
sourceimpl<T> EuclideanDistance<T, Point<T>> for Triangle<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for Triangle<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, point: &Point<T>) -> T
fn euclidean_distance(&self, point: &Point<T>) -> T
Returns the distance between two geometries Read more
sourceimpl<T> EuclideanDistance<T, Polygon<T>> for Point<T> where
T: GeoFloat,
impl<T> EuclideanDistance<T, Polygon<T>> for Point<T> where
T: GeoFloat,
sourcefn euclidean_distance(&self, polygon: &Polygon<T>) -> T
fn euclidean_distance(&self, polygon: &Polygon<T>) -> T
Minimum distance from a Point to a Polygon
sourceimpl<T> From<Coordinate<T>> for Point<T> where
T: CoordNum,
impl<T> From<Coordinate<T>> for Point<T> where
T: CoordNum,
sourcefn from(x: Coordinate<T>) -> Point<T>
fn from(x: Coordinate<T>) -> Point<T>
Converts to this type from the input type.
sourceimpl<T> From<Point<T>> for Coordinate<T> where
T: CoordNum,
impl<T> From<Point<T>> for Coordinate<T> where
T: CoordNum,
sourcefn from(point: Point<T>) -> Coordinate<T>
fn from(point: Point<T>) -> Coordinate<T>
Converts to this type from the input type.
sourceimpl GeodesicDistance<f64, Point<f64>> for Point
impl GeodesicDistance<f64, Point<f64>> for Point
sourcefn geodesic_distance(&self, rhs: &Point) -> f64
fn geodesic_distance(&self, rhs: &Point) -> f64
Determine the distance between two geometries on an ellipsoidal model of the earth. Read more
sourceimpl GeodesicIntermediate<f64> for Point
impl GeodesicIntermediate<f64> for Point
sourceimpl<C: CoordNum> HasDimensions for Point<C>
impl<C: CoordNum> HasDimensions for Point<C>
sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Some geometries, like a MultiPoint
, can have zero coordinates - we call these empty
. Read more
sourcefn dimensions(&self) -> Dimensions
fn dimensions(&self) -> Dimensions
The dimensions of some geometries are fixed, e.g. a Point always has 0 dimensions. However
for others, the dimensionality depends on the specific geometry instance - for example
typical Rect
s are 2-dimensional, but it’s possible to create degenerate Rect
s which
have either 1 or 0 dimensions. Read more
sourcefn boundary_dimensions(&self) -> Dimensions
fn boundary_dimensions(&self) -> Dimensions
The dimensions of the Geometry
’s boundary, as used by OGC-SFA. Read more
sourceimpl<T> HaversineDestination<T> for Point<T> where
T: CoordFloat + FromPrimitive,
impl<T> HaversineDestination<T> for Point<T> where
T: CoordFloat + FromPrimitive,
sourcefn haversine_destination(&self, bearing: T, distance: T) -> Point<T>
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
sourceimpl<T> HaversineDistance<T, Point<T>> for Point<T> where
T: CoordFloat + FromPrimitive,
impl<T> HaversineDistance<T, Point<T>> for Point<T> where
T: CoordFloat + FromPrimitive,
sourcefn haversine_distance(&self, rhs: &Point<T>) -> T
fn haversine_distance(&self, rhs: &Point<T>) -> T
Determine the distance between two geometries using the haversine formula. Read more
sourceimpl<T> HaversineIntermediate<T> for Point<T> where
T: CoordFloat + FromPrimitive,
impl<T> HaversineIntermediate<T> for Point<T> where
T: CoordFloat + FromPrimitive,
sourceimpl<T, G> Intersects<G> for Point<T> where
T: CoordNum,
Coordinate<T>: Intersects<G>,
impl<T, G> Intersects<G> for Point<T> where
T: CoordNum,
Coordinate<T>: Intersects<G>,
fn intersects(&self, rhs: &G) -> bool
sourceimpl<T> Intersects<MultiLineString<T>> for Point<T> where
MultiLineString<T>: Intersects<Point<T>>,
T: CoordNum,
impl<T> Intersects<MultiLineString<T>> for Point<T> where
MultiLineString<T>: Intersects<Point<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiLineString<T>) -> bool
sourceimpl<T> Intersects<MultiPolygon<T>> for Point<T> where
MultiPolygon<T>: Intersects<Point<T>>,
T: CoordNum,
impl<T> Intersects<MultiPolygon<T>> for Point<T> where
MultiPolygon<T>: Intersects<Point<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiPolygon<T>) -> bool
sourceimpl<T> Intersects<Point<T>> for Coordinate<T> where
T: CoordNum,
impl<T> Intersects<Point<T>> for Coordinate<T> where
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
sourceimpl<T> Intersects<Point<T>> for Line<T> where
Point<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Point<T>> for Line<T> where
Point<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
sourceimpl<T> Intersects<Point<T>> for Polygon<T> where
Point<T>: Intersects<Polygon<T>>,
T: CoordNum,
impl<T> Intersects<Point<T>> for Polygon<T> where
Point<T>: Intersects<Polygon<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
sourceimpl<T> Intersects<Point<T>> for Rect<T> where
Point<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Point<T>> for Rect<T> where
Point<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
sourceimpl<T> LineLocatePoint<T, Point<T>> for Line<T> where
T: CoordFloat,
impl<T> LineLocatePoint<T, Point<T>> for Line<T> where
T: CoordFloat,
sourceimpl<T> LineLocatePoint<T, Point<T>> for LineString<T> where
T: CoordFloat + AddAssign,
Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
impl<T> LineLocatePoint<T, Point<T>> for LineString<T> where
T: CoordFloat + AddAssign,
Line<T>: EuclideanDistance<T, Point<T>> + EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
sourceimpl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Point<T>
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Point<T>
type Output = Point<NT>
sourcefn map_coords(
&self,
func: impl Fn(Coordinate<T>) -> Coordinate<NT> + Copy
) -> Self::Output
fn map_coords(
&self,
func: impl Fn(Coordinate<T>) -> Coordinate<NT> + Copy
) -> Self::Output
Apply a function to all the coordinates in a geometric object, returning a new object. Read more
sourcefn try_map_coords<E>(
&self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<NT>, E>
) -> Result<Self::Output, E>
fn try_map_coords<E>(
&self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<NT>, E>
) -> Result<Self::Output, E>
Map a fallible function over all the coordinates in a geometry, returning a Result Read more
sourceimpl<T: CoordNum> MapCoordsInPlace<T> for Point<T>
impl<T: CoordNum> MapCoordsInPlace<T> for Point<T>
sourcefn map_coords_in_place(&mut self, func: impl Fn(Coordinate<T>) -> Coordinate<T>)
fn map_coords_in_place(&mut self, func: impl Fn(Coordinate<T>) -> Coordinate<T>)
Apply a function to all the coordinates in a geometric object, in place Read more
sourcefn try_map_coords_in_place<E>(
&mut self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<T>, E>
) -> Result<(), E>
fn try_map_coords_in_place<E>(
&mut self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<T>, E>
) -> Result<(), E>
Map a fallible function over all the coordinates in a geometry, in place, returning a Result
. Read more
sourceimpl<T: CoordNum> MapCoordsInplace<T> for Point<T>
impl<T: CoordNum> MapCoordsInplace<T> for Point<T>
sourcefn map_coords_inplace(&mut self, func: impl Fn((T, T)) -> (T, T) + Copy) where
T: CoordNum,
👎 Deprecated since 0.21.0: use MapCoordsInPlace::map_coords_in_place
instead which takes a Coordinate
instead of an (x,y) tuple
fn map_coords_inplace(&mut self, func: impl Fn((T, T)) -> (T, T) + Copy) where
T: CoordNum,
use MapCoordsInPlace::map_coords_in_place
instead which takes a Coordinate
instead of an (x,y) tuple
Apply a function to all the coordinates in a geometric object, in place
Examples
#[allow(deprecated)]
use geo::MapCoordsInplace;
use geo::Point;
use approx::assert_relative_eq;
let mut p = Point::new(10., 20.);
#[allow(deprecated)]
p.map_coords_inplace(|(x, y)| (x + 1000., y * 2.));
assert_relative_eq!(p, Point::new(1010., 40.), epsilon = 1e-6);
sourceimpl<T> MulAssign<T> for Point<T> where
T: CoordNum,
impl<T> MulAssign<T> for Point<T> where
T: CoordNum,
sourcefn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Scaler multiplication of a point in place
Examples
use geo_types::Point;
let mut p = Point::new(2.0, 3.0);
p *= 2.0;
assert_eq!(p.x(), 4.0);
assert_eq!(p.y(), 6.0);
sourceimpl<T> Point for Point<T> where
T: Float + RTreeNum,
impl<T> Point for Point<T> where
T: Float + RTreeNum,
type Scalar = T
type Scalar = T
The number type used by this point type.
sourceconst DIMENSIONS: usize = 2usize
const DIMENSIONS: usize = 2usize
The number of dimensions of this point type.
sourcefn generate(
generator: impl FnMut(usize) -> <Point<T> as Point>::Scalar
) -> Point<T>
fn generate(
generator: impl FnMut(usize) -> <Point<T> as Point>::Scalar
) -> Point<T>
Creates a new point value with given values for each dimension. Read more
sourceimpl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Point<F>
impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Point<F>
fn relate(&self, other: &GeometryCollection<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for Point<F>
impl<F: GeoFloat> Relate<F, Line<F>> for Point<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, LineString<F>> for Point<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for Point<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, MultiLineString<F>> for Point<F>
impl<F: GeoFloat> Relate<F, MultiLineString<F>> for Point<F>
fn relate(&self, other: &MultiLineString<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, MultiPoint<F>> for Point<F>
impl<F: GeoFloat> Relate<F, MultiPoint<F>> for Point<F>
fn relate(&self, other: &MultiPoint<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, MultiPolygon<F>> for Point<F>
impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for Point<F>
fn relate(&self, other: &MultiPolygon<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for Point<F>
impl<F: GeoFloat> Relate<F, Point<F>> for Point<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for Line<F>
impl<F: GeoFloat> Relate<F, Point<F>> for Line<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, Point<F>> for LineString<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for Polygon<F>
impl<F: GeoFloat> Relate<F, Point<F>> for Polygon<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for MultiPoint<F>
impl<F: GeoFloat> Relate<F, Point<F>> for MultiPoint<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for MultiLineString<F>
impl<F: GeoFloat> Relate<F, Point<F>> for MultiLineString<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for MultiPolygon<F>
impl<F: GeoFloat> Relate<F, Point<F>> for MultiPolygon<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, Point<F>> for Rect<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for Triangle<F>
impl<F: GeoFloat> Relate<F, Point<F>> for Triangle<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for GeometryCollection<F>
impl<F: GeoFloat> Relate<F, Point<F>> for GeometryCollection<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Polygon<F>> for Point<F>
impl<F: GeoFloat> Relate<F, Polygon<F>> for Point<F>
fn relate(&self, other: &Polygon<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for Point<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for Point<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Triangle<F>> for Point<F>
impl<F: GeoFloat> Relate<F, Triangle<F>> for Point<F>
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
sourceimpl<T> RelativeEq<Point<T>> for Point<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
impl<T> RelativeEq<Point<T>> for Point<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
sourcefn relative_eq(
&self,
other: &Point<T>,
epsilon: <Point<T> as AbsDiffEq<Point<T>>>::Epsilon,
max_relative: <Point<T> as AbsDiffEq<Point<T>>>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Point<T>,
epsilon: <Point<T> as AbsDiffEq<Point<T>>>::Epsilon,
max_relative: <Point<T> as AbsDiffEq<Point<T>>>::Epsilon
) -> bool
Equality assertion within a relative limit.
Examples
use geo_types::Point;
let a = Point::new(2.0, 3.0);
let b = Point::new(2.0, 3.01);
approx::assert_relative_eq!(a, b, max_relative=0.1)
sourcefn default_max_relative() -> <Point<T> as AbsDiffEq<Point<T>>>::Epsilon
fn default_max_relative() -> <Point<T> as AbsDiffEq<Point<T>>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of [RelativeEq::relative_eq
].
sourceimpl<T> Rotate<T> for Point<T> where
T: CoordFloat,
impl<T> Rotate<T> for Point<T> where
T: CoordFloat,
sourcefn rotate(&self, _angle: T) -> Self
👎 Deprecated: Equivalent to rotate_around_centroid
except for Polygon<T>
,
where it is equivalent to rotating around the polygon’s outer ring.
Call that instead, or rotate_around_center
if you’d like to rotate
around the geometry’s bounding box center.
fn rotate(&self, _angle: T) -> Self
Equivalent to rotate_around_centroid
except for Polygon<T>
,
where it is equivalent to rotating around the polygon’s outer ring.
Call that instead, or rotate_around_center
if you’d like to rotate
around the geometry’s bounding box center.
Rotate the Point about itself by the given number of degrees This operation leaves the point coordinates unchanged
sourcefn rotate_around_centroid(&self, _angle: T) -> Self
fn rotate_around_centroid(&self, _angle: T) -> Self
sourcefn rotate_around_center(&self, _angle: T) -> Self
fn rotate_around_center(&self, _angle: T) -> Self
Rotate a geometry around the center of its bounding box by an angle, in degrees. Read more
sourceimpl<T> Sub<Point<T>> for Point<T> where
T: CoordNum,
impl<T> Sub<Point<T>> for Point<T> where
T: CoordNum,
sourceimpl<T> SubAssign<Point<T>> for Point<T> where
T: CoordNum,
impl<T> SubAssign<Point<T>> for Point<T> where
T: CoordNum,
sourcefn sub_assign(&mut self, rhs: Point<T>)
fn sub_assign(&mut self, rhs: Point<T>)
Subtract a point from the given point and assign it to the original point.
Examples
use geo_types::Point;
let mut p = Point::new(1.25, 2.5);
p -= Point::new(1.5, 2.5);
assert_eq!(p.x(), -0.25);
assert_eq!(p.y(), 0.0);
sourceimpl<T> TryFrom<Geometry<T>> for Point<T> where
T: CoordNum,
impl<T> TryFrom<Geometry<T>> for Point<T> where
T: CoordNum,
Convert a Geometry enum into its inner type.
Fails if the enum case does not match the type you are trying to convert it to.
sourceimpl<T: CoordNum, NT: CoordNum, E> TryMapCoords<T, NT, E> for Point<T>
impl<T: CoordNum, NT: CoordNum, E> TryMapCoords<T, NT, E> for Point<T>
type Output = Point<NT>
type Output = Point<NT>
use MapCoords::try_map_coords
which takes a Coordinate
instead of an (x,y) tuple
sourcefn try_map_coords(
&self,
func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy
) -> Result<Self::Output, E>
fn try_map_coords(
&self,
func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy
) -> Result<Self::Output, E>
use MapCoords::try_map_coords
which takes a Coordinate
instead of an (x,y) tuple
Map a fallible function over all the coordinates in a geometry, returning a Result Read more
sourceimpl<T: CoordNum, E> TryMapCoordsInplace<T, E> for Point<T>
impl<T: CoordNum, E> TryMapCoordsInplace<T, E> for Point<T>
sourcefn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>
fn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>
use MapCoordsInPlace::try_map_coords_in_place
which takes a Coordinate
instead of an (x,y) tuple
Map a fallible function over all the coordinates in a geometry, in place, returning a Result
. Read more
sourceimpl<T> VincentyDistance<T, Point<T>> for Point<T> where
T: CoordFloat + FromPrimitive,
impl<T> VincentyDistance<T, Point<T>> for Point<T> where
T: CoordFloat + FromPrimitive,
sourcefn vincenty_distance(&self, rhs: &Point<T>) -> Result<T, FailedToConvergeError>
fn vincenty_distance(&self, rhs: &Point<T>) -> Result<T, FailedToConvergeError>
Determine the distance between two geometries using Vincenty’s formulae. Read more
impl<T> Copy for Point<T> where
T: Copy + CoordNum,
impl<T> Eq for Point<T> where
T: Eq + CoordNum,
impl<T> StructuralEq for Point<T> where
T: CoordNum,
impl<T> StructuralPartialEq for Point<T> where
T: CoordNum,
Auto Trait Implementations
impl<T> RefUnwindSafe for Point<T> where
T: RefUnwindSafe,
impl<T> Send for Point<T> where
T: Send,
impl<T> Sync for Point<T> where
T: Sync,
impl<T> Unpin for Point<T> where
T: Unpin,
impl<T> UnwindSafe for Point<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 · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<G, T, U> Convert<T, U> for G where
T: CoordNum,
U: CoordNum + From<T>,
G: MapCoords<T, U>,
impl<G, T, U> Convert<T, U> for G where
T: CoordNum,
U: CoordNum + From<T>,
G: MapCoords<T, U>,
sourceimpl<'a, T, G> Extremes<'a, T> for G where
G: CoordsIter<'a, Scalar = T>,
T: CoordNum,
impl<'a, T, G> Extremes<'a, T> for G where
G: CoordsIter<'a, Scalar = T>,
T: CoordNum,
sourceimpl<P> PointDistance for P where
P: Point,
impl<P> PointDistance for P where
P: Point,
sourcefn distance_2(&self, point: &P) -> <P as Point>::Scalar
fn distance_2(&self, point: &P) -> <P as Point>::Scalar
Returns the squared euclidean distance between an object to a point.
sourcefn contains_point(
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
fn contains_point(
&self,
point: &<<P as RTreeObject>::Envelope as Envelope>::Point
) -> bool
Returns true
if a point is contained within this object. Read more
sourcefn 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>
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>
Returns the squared distance to this object, or None
if the distance
is larger than a given maximum value. Read more
sourceimpl<P> RTreeObject for P where
P: Point,
impl<P> RTreeObject for P where
P: Point,
sourceimpl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
impl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
sourcefn rotate_around_point(&self, angle: T, point: Point<T>) -> G
fn rotate_around_point(&self, angle: T, point: Point<T>) -> G
Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more
sourceimpl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInPlace<T>,
impl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInPlace<T>,
sourcefn translate(&self, xoff: T, yoff: T) -> G
fn translate(&self, xoff: T, yoff: T) -> G
Translate a Geometry along its axes by the given offsets Read more
sourcefn translate_in_place(&mut self, xoff: T, yoff: T)
fn translate_in_place(&mut self, xoff: T, yoff: T)
Translate a Geometry along its axes, but in place.
sourcefn translate_inplace(&mut self, xoff: T, yoff: T)
fn translate_inplace(&mut self, xoff: T, yoff: T)
renamed to translate_in_place
Translate a Geometry along its axes, but in place.