Enum Geometry

Source
pub enum Geometry<T = f64>
where T: CoordNum,
{ Point(Point<T>), Line(Line<T>), LineString(LineString<T>), Polygon(Polygon<T>), MultiPoint(MultiPoint<T>), MultiLineString(MultiLineString<T>), MultiPolygon(MultiPolygon<T>), GeometryCollection(GeometryCollection<T>), Rect(Rect<T>), Triangle(Triangle<T>), }
Expand description

An enum representing any possible geometry type.

All geometry variants (Point, LineString, etc.) can be converted to a Geometry using Into::into. Conversely, TryFrom::try_from can be used to convert a Geometry back to one of it’s specific enum members.

§Example

use std::convert::TryFrom;
use geo_types::{Point, point, Geometry, GeometryCollection};
let p = point!(x: 1.0, y: 1.0);
let pe: Geometry = p.into();
let pn = Point::try_from(pe).unwrap();

Variants§

§

Point(Point<T>)

§

Line(Line<T>)

§

LineString(LineString<T>)

§

Polygon(Polygon<T>)

§

MultiPoint(MultiPoint<T>)

§

MultiLineString(MultiLineString<T>)

§

MultiPolygon(MultiPolygon<T>)

§

GeometryCollection(GeometryCollection<T>)

§

Rect(Rect<T>)

§

Triangle(Triangle<T>)

Implementations§

Source§

impl<T> Geometry<T>
where T: CoordNum,

Source

pub fn into_point(self) -> Option<Point<T>>

👎Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Point>

If this Geometry is a Point, then return that, else None.

§Examples
use geo_types::*;
use std::convert::TryInto;

let g = Geometry::Point(Point::new(0., 0.));
let p2: Point<f32> = g.try_into().unwrap();
assert_eq!(p2, Point::new(0., 0.,));
Source

pub fn into_line_string(self) -> Option<LineString<T>>

👎Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<LineString>

If this Geometry is a LineString, then return that LineString, else None.

Source

pub fn into_line(self) -> Option<Line<T>>

👎Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Line>

If this Geometry is a Line, then return that Line, else None.

Source

pub fn into_polygon(self) -> Option<Polygon<T>>

👎Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Polygon>

If this Geometry is a Polygon, then return that, else None.

Source

pub fn into_multi_point(self) -> Option<MultiPoint<T>>

👎Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPoint>

If this Geometry is a MultiPoint, then return that, else None.

Source

pub fn into_multi_line_string(self) -> Option<MultiLineString<T>>

👎Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiLineString>

If this Geometry is a MultiLineString, then return that, else None.

Source

pub fn into_multi_polygon(self) -> Option<MultiPolygon<T>>

👎Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPolygon>

If this Geometry is a MultiPolygon, then return that, else None.

Trait Implementations§

Source§

impl<T> AbsDiffEq for Geometry<T>
where T: CoordNum + AbsDiffEq<Epsilon = T>,

Source§

fn abs_diff_eq( &self, other: &Geometry<T>, epsilon: <Geometry<T> as AbsDiffEq>::Epsilon, ) -> bool

Equality assertion with an absolute limit.

§Examples
use geo_types::{Geometry, polygon};

let a: Geometry<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7., y: 9.), (x: 0., y: 0.)].into();
let b: Geometry<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7.01, y: 9.), (x: 0., y: 0.)].into();

approx::assert_abs_diff_eq!(a, b, epsilon=0.1);
approx::assert_abs_diff_ne!(a, b, epsilon=0.001);
Source§

type Epsilon = T

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> <Geometry<T> as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl<T> Area<T> for Geometry<T>
where T: CoordFloat,

Source§

fn signed_area(&self) -> T

Source§

fn unsigned_area(&self) -> T

Source§

impl<T> BoundingRect<T> for Geometry<T>
where T: CoordNum,

Source§

type Output = Option<Rect<T>>

Source§

fn bounding_rect(&self) -> Self::Output

Return the bounding rectangle of a geometry Read more
Source§

impl<T> Centroid for Geometry<T>
where T: GeoFloat,

Source§

fn centroid(&self) -> Self::Output

The Centroid of a Geometry is the centroid of its enum variant

§Examples
use geo::Centroid;
use geo::{Geometry, Rect, point};

let rect = Rect::new(
  point!(x: 0.0f32, y: 0.0),
  point!(x: 1.0, y: 1.0),
);
let geometry = Geometry::from(rect.clone());

assert_eq!(
    Some(rect.centroid()),
    geometry.centroid(),
);

assert_eq!(
    Some(point!(x: 0.5, y: 0.5)),
    geometry.centroid(),
);
Source§

type Output = Option<Point<T>>

Source§

impl<T> ChamberlainDuquetteArea<T> for Geometry<T>
where T: CoordFloat,

Source§

impl<T> Clone for Geometry<T>
where T: Clone + CoordNum,

Source§

fn clone(&self) -> Geometry<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: GeoFloat> ClosestPoint<F> for Geometry<F>

Source§

fn closest_point(&self, p: &Point<F>) -> Closest<F>

Find the closest point between self and p.
Source§

impl<T> Contains<Coord<T>> for Geometry<T>
where T: GeoNum,

Source§

fn contains(&self, coord: &Coord<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for GeometryCollection<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for Line<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for LineString<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for MultiLineString<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for Point<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for Polygon<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for Rect<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<Geometry<T>> for Triangle<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry: &Geometry<T>) -> bool

Source§

impl<T> Contains<GeometryCollection<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, geometry_collection: &GeometryCollection<T>) -> bool

Source§

impl<T> Contains<Line<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, line: &Line<T>) -> bool

Source§

impl<T> Contains<LineString<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, line_string: &LineString<T>) -> bool

Source§

impl<T> Contains<MultiLineString<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, multi_line_string: &MultiLineString<T>) -> bool

Source§

impl<T> Contains<MultiPoint<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, multi_point: &MultiPoint<T>) -> bool

Source§

impl<T> Contains<MultiPolygon<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, multi_line_string: &MultiPolygon<T>) -> bool

Source§

impl<T> Contains<Point<T>> for Geometry<T>
where T: GeoNum,

Source§

fn contains(&self, point: &Point<T>) -> bool

Source§

impl<T> Contains<Polygon<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, polygon: &Polygon<T>) -> bool

Source§

impl<T> Contains<Rect<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, rect: &Rect<T>) -> bool

Source§

impl<T> Contains<Triangle<T>> for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, triangle: &Triangle<T>) -> bool

Source§

impl<T> Contains for Geometry<T>
where T: GeoFloat,

Source§

fn contains(&self, other: &Geometry<T>) -> bool

Source§

impl<T> CoordinatePosition for Geometry<T>
where T: GeoNum,

Source§

type Scalar = T

Source§

fn calculate_coordinate_position( &self, coord: &Coord<T>, is_inside: &mut bool, boundary_count: &mut usize, )

Source§

fn coordinate_position(&self, coord: &Coord<Self::Scalar>) -> CoordPos

Source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for Geometry<T>

Source§

fn coords_count(&'a self) -> usize

Return the number of coordinates in the Geometry.

Source§

type Iter = GeometryCoordsIter<'a, T>

Source§

type ExteriorIter = GeometryExteriorCoordsIter<'a, T>

Source§

type Scalar = T

Source§

fn coords_iter(&'a self) -> Self::Iter

Iterate over all exterior and (if any) interior coordinates of a geometry. Read more
Source§

fn exterior_coords_iter(&'a self) -> Self::ExteriorIter

Iterate over all exterior coordinates of a geometry. Read more
Source§

impl<T> Debug for Geometry<T>
where T: CoordNum,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> From<Line<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: Line<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T> From<LineString<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: LineString<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T> From<MultiLineString<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: MultiLineString<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T> From<MultiPoint<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: MultiPoint<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T> From<MultiPolygon<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: MultiPolygon<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T> From<Point<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: Point<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T> From<Polygon<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: Polygon<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T> From<Rect<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: Rect<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T> From<Triangle<T>> for Geometry<T>
where T: CoordNum,

Source§

fn from(x: Triangle<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl GeodesicArea<f64> for Geometry<f64>

Source§

fn geodesic_perimeter(&self) -> f64

Determine the perimeter of a geometry on an ellipsoidal model of the earth. Read more
Source§

fn geodesic_area_signed(&self) -> f64

Determine the area of a geometry on an ellipsoidal model of the earth. Read more
Source§

fn geodesic_area_unsigned(&self) -> f64

Determine the area of a geometry on an ellipsoidal model of the earth. Supports very large geometries that cover a significant portion of the earth. Read more
Source§

fn geodesic_perimeter_area_signed(&self) -> (f64, f64)

Determine the perimeter and area of a geometry on an ellipsoidal model of the earth, all in one operation. Read more
Source§

fn geodesic_perimeter_area_unsigned(&self) -> (f64, f64)

Determine the perimeter and area of a geometry on an ellipsoidal model of the earth, all in one operation. Supports very large geometries that cover a significant portion of the earth. Read more
Source§

impl<C: GeoNum> HasDimensions for Geometry<C>

Source§

fn is_empty(&self) -> bool

Some geometries, like a MultiPoint, can have zero coordinates - we call these empty. Read more
Source§

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 Rects are 2-dimensional, but it’s possible to create degenerate Rects which have either 1 or 0 dimensions. Read more
Source§

fn boundary_dimensions(&self) -> Dimensions

The dimensions of the Geometry’s boundary, as used by OGC-SFA. Read more
Source§

impl<T> Hash for Geometry<T>
where T: Hash + CoordNum,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> InteriorPoint for Geometry<T>
where T: GeoFloat,

Source§

type Output = Option<Point<T>>

Source§

fn interior_point(&self) -> Self::Output

Calculates a representative point inside the Geometry Read more
Source§

impl<T, G> Intersects<G> for Geometry<T>

Source§

fn intersects(&self, rhs: &G) -> bool

Source§

impl<T> Intersects<Geometry<T>> for Coord<T>
where Geometry<T>: Intersects<Coord<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &Geometry<T>) -> bool

Source§

impl<T> Intersects<Geometry<T>> for Line<T>
where Geometry<T>: Intersects<Line<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &Geometry<T>) -> bool

Source§

impl<T> Intersects<Geometry<T>> for Polygon<T>
where Geometry<T>: Intersects<Polygon<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &Geometry<T>) -> bool

Source§

impl<T> Intersects<Geometry<T>> for Rect<T>
where Geometry<T>: Intersects<Rect<T>>, T: CoordNum,

Source§

fn intersects(&self, rhs: &Geometry<T>) -> bool

Source§

impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Geometry<T>

Source§

type Output = Geometry<NT>

Source§

fn map_coords( &self, func: impl Fn(Coord<T>) -> Coord<NT> + Copy, ) -> Self::Output

Apply a function to all the coordinates in a geometric object, returning a new object. Read more
Source§

fn try_map_coords<E>( &self, func: impl Fn(Coord<T>) -> Result<Coord<NT>, E> + Copy, ) -> Result<Self::Output, E>

Map a fallible function over all the coordinates in a geometry, returning a Result Read more
Source§

impl<T: CoordNum> MapCoordsInPlace<T> for Geometry<T>

Source§

fn map_coords_in_place(&mut self, func: impl Fn(Coord<T>) -> Coord<T> + Copy)

Apply a function to all the coordinates in a geometric object, in place Read more
Source§

fn try_map_coords_in_place<E>( &mut self, func: impl Fn(Coord<T>) -> Result<Coord<T>, E>, ) -> Result<(), E>

Map a fallible function over all the coordinates in a geometry, in place, returning a Result. Read more
Source§

impl<T: CoordNum> MapCoordsInplace<T> for Geometry<T>

Source§

fn 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 Coord 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);
Source§

impl<T> PartialEq for Geometry<T>
where T: PartialEq + CoordNum,

Source§

fn eq(&self, other: &Geometry<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F: GeoFloat> Relate<F, Geometry<F>> for Geometry<F>

Source§

fn relate(&self, other: &Geometry<F>) -> IntersectionMatrix

Source§

impl<T> RelativeEq for Geometry<T>
where T: CoordNum + RelativeEq<Epsilon = T>,

Source§

fn relative_eq( &self, other: &Geometry<T>, epsilon: <Geometry<T> as AbsDiffEq>::Epsilon, max_relative: <Geometry<T> as AbsDiffEq>::Epsilon, ) -> bool

Equality assertion within a relative limit.

§Examples
use geo_types::{Geometry, polygon};

let a: Geometry<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7., y: 9.), (x: 0., y: 0.)].into();
let b: Geometry<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7.01, y: 9.), (x: 0., y: 0.)].into();

approx::assert_relative_eq!(a, b, max_relative=0.1);
approx::assert_relative_ne!(a, b, max_relative=0.001);
Source§

fn default_max_relative() -> <Geometry<T> as AbsDiffEq>::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl<T> RemoveRepeatedPoints<T> for Geometry<T>

Source§

fn remove_repeated_points(&self) -> Self

Create a Geometry with consecutive repeated points removed.

Source§

fn remove_repeated_points_mut(&mut self)

Remove consecutive repeated points from a Geometry inplace.

Source§

impl<T> TryFrom<Geometry<T>> for Line<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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<Line<T>, <Line<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Geometry<T>> for LineString<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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<LineString<T>, <LineString<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Geometry<T>> for MultiLineString<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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<MultiLineString<T>, <MultiLineString<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Geometry<T>> for MultiPoint<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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<MultiPoint<T>, <MultiPoint<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Geometry<T>> for MultiPolygon<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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<MultiPolygon<T>, <MultiPolygon<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<Point<T>, <Point<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Geometry<T>> for Polygon<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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<Polygon<T>, <Polygon<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Geometry<T>> for Rect<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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<Rect<T>, <Rect<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Geometry<T>> for Triangle<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.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( geom: Geometry<T>, ) -> Result<Triangle<T>, <Triangle<T> as TryFrom<Geometry<T>>>::Error>

Performs the conversion.
Source§

impl<T: CoordNum, NT: CoordNum, E> TryMapCoords<T, NT, E> for Geometry<T>

Source§

type Output = Geometry<NT>

👎Deprecated since 0.21.0: use MapCoords::try_map_coords which takes a Coord instead of an (x,y) tuple
Source§

fn try_map_coords( &self, func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy, ) -> Result<Self::Output, E>

👎Deprecated since 0.21.0: use MapCoords::try_map_coords which takes a Coord instead of an (x,y) tuple
Map a fallible function over all the coordinates in a geometry, returning a Result Read more
Source§

impl<T: CoordNum, E> TryMapCoordsInplace<T, E> for Geometry<T>

Source§

fn try_map_coords_inplace( &mut self, func: impl Fn((T, T)) -> Result<(T, T), E>, ) -> Result<(), E>

👎Deprecated since 0.21.0: use MapCoordsInPlace::try_map_coords_in_place which takes a Coord instead of an (x,y) tuple
Map a fallible function over all the coordinates in a geometry, in place, returning a Result. Read more
Source§

impl<T> UlpsEq for Geometry<T>
where T: CoordNum + UlpsEq<Epsilon = T>,

Source§

fn ulps_eq( &self, other: &Geometry<T>, epsilon: <Geometry<T> as AbsDiffEq>::Epsilon, max_ulps: u32, ) -> bool

Approximate equality assertion for floating point geometries based on the number of representable floats that fit between the two numbers being compared.

“relative_eq” might be more intuitive, but it does floating point math in its error calculation, introducing its own error into the error calculation.

Working with ulps avoids this problem. max_ulps means “how many floating points are representable that fit between these two numbers”, which lets us tune how “sloppy” we’re willing to be while avoiding any danger of floating point rounding in the comparison itself.

§Examples
use geo_types::{Geometry, Point};

let a: Geometry = Point::new(1.0, 1.0).into();
let b: Geometry = Point::new(1.0 + 4.0 * f64::EPSILON, 1.0 + 4.0 * f64::EPSILON).into();

approx::assert_ulps_eq!(a, b);
approx::assert_ulps_ne!(a, b, max_ulps=3);
approx::assert_ulps_eq!(a, b, max_ulps=5);
§References

https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.
Source§

impl<T> Eq for Geometry<T>
where T: Eq + CoordNum,

Source§

impl<T> StructuralPartialEq for Geometry<T>
where T: CoordNum,

Auto Trait Implementations§

§

impl<T> Freeze for Geometry<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Geometry<T>
where T: RefUnwindSafe,

§

impl<T> Send for Geometry<T>
where T: Send,

§

impl<T> Sync for Geometry<T>
where T: Sync,

§

impl<T> Unpin for Geometry<T>
where T: Unpin,

§

impl<T> UnwindSafe for Geometry<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T, M> AffineOps<T> for M
where T: CoordNum, M: MapCoordsInPlace<T> + MapCoords<T, T, Output = M>,

Source§

fn affine_transform(&self, transform: &AffineTransform<T>) -> M

Apply transform immutably, outputting a new geometry.
Source§

fn affine_transform_mut(&mut self, transform: &AffineTransform<T>)

Apply transform to mutate self.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<G, T, U> Convert<T, U> for G
where T: CoordNum, U: CoordNum + From<T>, G: MapCoords<T, U>,

Source§

type Output = <G as MapCoords<T, U>>::Output

Source§

fn convert(&self) -> <G as Convert<T, U>>::Output

Source§

impl<'a, T, G> ConvexHull<'a, T> for G
where T: GeoNum, G: CoordsIter<'a, Scalar = T>,

Source§

type Scalar = T

Source§

fn convex_hull(&'a self) -> Polygon<T>

Source§

impl<'a, T, G> Extremes<'a, T> for G
where G: CoordsIter<'a, Scalar = T>, T: CoordNum,

Source§

fn extremes(&'a self) -> Option<Outcome<T>>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'a, T, G> MinimumRotatedRect<'a, T> for G
where T: CoordFloat + GeoFloat + GeoNum, G: CoordsIter<'a, Scalar = T>,

Source§

impl<G, IP, IR, T> Rotate<T> for G
where T: CoordFloat, IP: Into<Option<Point<T>>>, IR: Into<Option<Rect<T>>>, G: Clone + Centroid<Output = IP> + BoundingRect<T, Output = IR> + AffineOps<T>,

Source§

fn rotate_around_centroid(&self, degrees: T) -> G

Rotate a geometry around its centroid by an angle, in degrees Read more
Source§

fn rotate_around_centroid_mut(&mut self, degrees: T)

Mutable version of Self::rotate_around_centroid
Source§

fn rotate_around_center(&self, degrees: T) -> G

Rotate a geometry around the center of its bounding box by an angle, in degrees. Read more
Source§

fn rotate_around_center_mut(&mut self, degrees: T)

Mutable version of Self::rotate_around_center
Source§

fn rotate_around_point(&self, degrees: T, point: Point<T>) -> G

Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more
Source§

fn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)

Mutable version of Self::rotate_around_point
Source§

impl<T, IR, G> Scale<T> for G
where T: CoordFloat, IR: Into<Option<Rect<T>>>, G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,

Source§

fn scale(&self, scale_factor: T) -> G

Scale a geometry from it’s bounding box center. Read more
Source§

fn scale_mut(&mut self, scale_factor: T)

Mutable version of scale
Source§

fn scale_xy(&self, x_factor: T, y_factor: T) -> G

Scale a geometry from it’s bounding box center, using different values for x_factor and y_factor to distort the geometry’s aspect ratio. Read more
Source§

fn scale_xy_mut(&mut self, x_factor: T, y_factor: T)

Mutable version of scale_xy.
Source§

fn scale_around_point( &self, x_factor: T, y_factor: T, origin: impl Into<Coord<T>>, ) -> G

Scale a geometry around a point of origin. Read more
Source§

fn scale_around_point_mut( &mut self, x_factor: T, y_factor: T, origin: impl Into<Coord<T>>, )

Mutable version of scale_around_point.
Source§

impl<T, IR, G> Skew<T> for G
where T: CoordFloat, IR: Into<Option<Rect<T>>>, G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,

Source§

fn skew(&self, degrees: T) -> G

An affine transformation which skews a geometry, sheared by a uniform angle along the x and y dimensions. Read more
Source§

fn skew_mut(&mut self, degrees: T)

Mutable version of skew.
Source§

fn skew_xy(&self, degrees_x: T, degrees_y: T) -> G

An affine transformation which skews a geometry, sheared by an angle along the x and y dimensions. Read more
Source§

fn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)

Mutable version of skew_xy.
Source§

fn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coord<T>>) -> G

An affine transformation which skews a geometry around a point of origin, sheared by an angle along the x and y dimensions. Read more
Source§

fn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coord<T>>)

Mutable version of skew_around_point.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, G> Translate<T> for G
where T: CoordNum, G: AffineOps<T>,

Source§

fn translate(&self, x_offset: T, y_offset: T) -> G

Translate a Geometry along its axes by the given offsets Read more
Source§

fn translate_mut(&mut self, x_offset: T, y_offset: T)

Translate a Geometry along its axes, but in place.
Source§

fn translate_in_place(&mut self, x_offset: T, y_offset: T)

Source§

fn translate_inplace(&mut self, x_offset: T, y_offset: T)

Source§

impl<G, T, U> TryConvert<T, U> for G
where T: CoordNum, U: CoordNum + TryFrom<T>, G: MapCoords<T, U>,

Source§

type Output = Result<<G as MapCoords<T, U>>::Output, <U as TryFrom<T>>::Error>

Source§

fn try_convert(&self) -> <G as TryConvert<T, U>>::Output

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool