Enum geo::Geometry [−][src]
pub enum Geometry<T> 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>), }
An enum representing any possible geometry type.
All Geo
types can be converted to a Geometry
member using .into()
(as part of the
std::convert::Into
pattern), and Geo
types implement the TryFrom
trait in order to
convert back from 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<f64> = 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
impl<T> Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn into_point(self) -> Option<Point<T>>
[src]
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::*; let g = Geometry::Point(Point::new(0., 0.)); let p2: Point<f32> = g.into_point().unwrap(); assert_eq!(p2, Point::new(0., 0.,));
pub fn into_line_string(self) -> Option<LineString<T>>
[src]
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.
pub fn into_line(self) -> Option<Line<T>>
[src]
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.
pub fn into_polygon(self) -> Option<Polygon<T>>
[src]
Will be removed in an upcoming version. Switch to std::convert::TryInto<Polygon>
If this Geometry is a Polygon, then return that, else None.
pub fn into_multi_point(self) -> Option<MultiPoint<T>>
[src]
Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPoint>
If this Geometry is a MultiPoint, then return that, else None.
pub fn into_multi_line_string(self) -> Option<MultiLineString<T>>
[src]
Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiLineString>
If this Geometry is a MultiLineString, then return that, else None.
pub fn into_multi_polygon(self) -> Option<MultiPolygon<T>>
[src]
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
impl<T> AbsDiffEq<Geometry<T>> for Geometry<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
[src]
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
type Epsilon = T
Used for specifying relative comparisons.
pub fn default_epsilon() -> <Geometry<T> as AbsDiffEq<Geometry<T>>>::Epsilon
[src]
pub fn abs_diff_eq(
&self,
other: &Geometry<T>,
epsilon: <Geometry<T> as AbsDiffEq<Geometry<T>>>::Epsilon
) -> bool
[src]
&self,
other: &Geometry<T>,
epsilon: <Geometry<T> as AbsDiffEq<Geometry<T>>>::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);
pub fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
impl<T> Area<T> for Geometry<T> where
T: CoordFloat,
[src]
T: CoordFloat,
fn signed_area(&self) -> T
[src]
fn unsigned_area(&self) -> T
[src]
impl<T> BoundingRect<T> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> Centroid for Geometry<T> where
T: GeoFloat,
[src]
T: GeoFloat,
impl<T> Clone for Geometry<T> where
T: Clone + CoordNum,
[src]
T: Clone + CoordNum,
impl<T> Contains<Coordinate<T>> for Geometry<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Point<T>> for Geometry<T> where
T: GeoNum,
[src]
T: GeoNum,
impl<T> CoordinatePosition for Geometry<T> where
T: GeoNum,
[src]
T: GeoNum,
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
[src]
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos
[src]
impl<'a, T: CoordNum + 'a> CoordsIter<'a> for Geometry<T>
[src]
type Iter = GeometryCoordsIter<'a, T>
type ExteriorIter = GeometryExteriorCoordsIter<'a, T>
type Scalar = T
fn coords_iter(&'a self) -> Self::Iter
[src]
fn coords_count(&'a self) -> usize
[src]
Return the number of coordinates in the Geometry
.
fn exterior_coords_iter(&'a self) -> Self::ExteriorIter
[src]
impl<T> Debug for Geometry<T> where
T: Debug + CoordNum,
[src]
T: Debug + CoordNum,
impl<T> Eq for Geometry<T> where
T: Eq + CoordNum,
[src]
T: Eq + CoordNum,
impl<T> From<Line<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> From<LineString<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn from(x: LineString<T>) -> Geometry<T>
[src]
impl<T> From<MultiLineString<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn from(x: MultiLineString<T>) -> Geometry<T>
[src]
impl<T> From<MultiPoint<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn from(x: MultiPoint<T>) -> Geometry<T>
[src]
impl<T> From<MultiPolygon<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn from(x: MultiPolygon<T>) -> Geometry<T>
[src]
impl<T> From<Point<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> From<Polygon<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> From<Rect<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> From<Triangle<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<C: GeoNum> HasDimensions for Geometry<C>
[src]
fn is_empty(&self) -> bool
[src]
fn dimensions(&self) -> Dimensions
[src]
fn boundary_dimensions(&self) -> Dimensions
[src]
impl<T> Hash for Geometry<T> where
T: Hash + CoordNum,
[src]
T: Hash + CoordNum,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, G> Intersects<G> for Geometry<T> where
T: CoordNum,
Point<T>: Intersects<G>,
MultiPoint<T>: Intersects<G>,
Line<T>: Intersects<G>,
LineString<T>: Intersects<G>,
MultiLineString<T>: Intersects<G>,
Triangle<T>: Intersects<G>,
Rect<T>: Intersects<G>,
Polygon<T>: Intersects<G>,
MultiPolygon<T>: Intersects<G>,
[src]
T: CoordNum,
Point<T>: Intersects<G>,
MultiPoint<T>: Intersects<G>,
Line<T>: Intersects<G>,
LineString<T>: Intersects<G>,
MultiLineString<T>: Intersects<G>,
Triangle<T>: Intersects<G>,
Rect<T>: Intersects<G>,
Polygon<T>: Intersects<G>,
MultiPolygon<T>: Intersects<G>,
fn intersects(&self, rhs: &G) -> bool
[src]
impl<T> Intersects<Geometry<T>> for Coordinate<T> where
Geometry<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
Geometry<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
[src]
impl<T> Intersects<Geometry<T>> for Line<T> where
Geometry<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
Geometry<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
[src]
impl<T> Intersects<Geometry<T>> for Rect<T> where
Geometry<T>: Intersects<Rect<T>>,
T: CoordNum,
[src]
Geometry<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
[src]
impl<T> Intersects<Geometry<T>> for Polygon<T> where
Geometry<T>: Intersects<Polygon<T>>,
T: CoordNum,
[src]
Geometry<T>: Intersects<Polygon<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
[src]
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Geometry<T>
[src]
type Output = Geometry<NT>
fn map_coords(&self, func: impl Fn(&(T, T)) -> (NT, NT) + Copy) -> Self::Output
[src]
impl<T: CoordNum> MapCoordsInplace<T> for Geometry<T>
[src]
impl<T> PartialEq<Geometry<T>> for Geometry<T> where
T: PartialEq<T> + CoordNum,
[src]
T: PartialEq<T> + CoordNum,
pub fn eq(&self, other: &Geometry<T>) -> bool
[src]
pub fn ne(&self, other: &Geometry<T>) -> bool
[src]
impl<F: GeoFloat> Relate<F, Geometry<F>> for Geometry<F>
[src]
fn relate(&self, other: &Geometry<F>) -> IntersectionMatrix
[src]
impl<T> RelativeEq<Geometry<T>> for Geometry<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
[src]
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
pub fn default_max_relative(
) -> <Geometry<T> as AbsDiffEq<Geometry<T>>>::Epsilon
[src]
) -> <Geometry<T> as AbsDiffEq<Geometry<T>>>::Epsilon
pub fn relative_eq(
&self,
other: &Geometry<T>,
epsilon: <Geometry<T> as AbsDiffEq<Geometry<T>>>::Epsilon,
max_relative: <Geometry<T> as AbsDiffEq<Geometry<T>>>::Epsilon
) -> bool
[src]
&self,
other: &Geometry<T>,
epsilon: <Geometry<T> as AbsDiffEq<Geometry<T>>>::Epsilon,
max_relative: <Geometry<T> as AbsDiffEq<Geometry<T>>>::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);
pub fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
impl<T> StructuralEq for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> StructuralPartialEq for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> TryFrom<Geometry<T>> for MultiPolygon<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<MultiPolygon<T>, <MultiPolygon<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<MultiPolygon<T>, <MultiPolygon<T> as TryFrom<Geometry<T>>>::Error>
impl<T> TryFrom<Geometry<T>> for LineString<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<LineString<T>, <LineString<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<LineString<T>, <LineString<T> as TryFrom<Geometry<T>>>::Error>
impl<T> TryFrom<Geometry<T>> for Polygon<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<Polygon<T>, <Polygon<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<Polygon<T>, <Polygon<T> as TryFrom<Geometry<T>>>::Error>
impl<T> TryFrom<Geometry<T>> for Line<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<Line<T>, <Line<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<Line<T>, <Line<T> as TryFrom<Geometry<T>>>::Error>
impl<T> TryFrom<Geometry<T>> for MultiLineString<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<MultiLineString<T>, <MultiLineString<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<MultiLineString<T>, <MultiLineString<T> as TryFrom<Geometry<T>>>::Error>
impl<T> TryFrom<Geometry<T>> for MultiPoint<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<MultiPoint<T>, <MultiPoint<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<MultiPoint<T>, <MultiPoint<T> as TryFrom<Geometry<T>>>::Error>
impl<T> TryFrom<Geometry<T>> for Triangle<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<Triangle<T>, <Triangle<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<Triangle<T>, <Triangle<T> as TryFrom<Geometry<T>>>::Error>
impl<T> TryFrom<Geometry<T>> for Rect<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<Rect<T>, <Rect<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<Rect<T>, <Rect<T> as TryFrom<Geometry<T>>>::Error>
impl<T> TryFrom<Geometry<T>> for Point<T> where
T: CoordNum,
[src]
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.
type Error = Error
The type returned in the event of a conversion error.
pub 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: CoordNum, NT: CoordNum> TryMapCoords<T, NT> for Geometry<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Geometry<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Geometry<T> where
T: Send,
T: Send,
impl<T> Sync for Geometry<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Geometry<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Geometry<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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T, G> Extremes<'a, T> for G where
T: CoordNum,
G: CoordsIter<'a, Scalar = T>,
[src]
T: CoordNum,
G: CoordsIter<'a, Scalar = T>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
[src]
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
pub 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.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
[src]
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
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.
pub 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>,