pub enum Geometry<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 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
sourceimpl<T: CoordNum> Geometry<T>
impl<T: CoordNum> Geometry<T>
sourcepub fn into_point(self) -> Option<Point<T>>
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Point>
pub fn into_point(self) -> Option<Point<T>>
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.,));
sourcepub fn into_line_string(self) -> Option<LineString<T>>
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<LineString>
pub fn into_line_string(self) -> Option<LineString<T>>
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.
sourcepub fn into_line(self) -> Option<Line<T>>
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Line>
pub fn into_line(self) -> Option<Line<T>>
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.
sourcepub fn into_polygon(self) -> Option<Polygon<T>>
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Polygon>
pub fn into_polygon(self) -> Option<Polygon<T>>
Will be removed in an upcoming version. Switch to std::convert::TryInto<Polygon>
If this Geometry is a Polygon, then return that, else None.
sourcepub fn into_multi_point(self) -> Option<MultiPoint<T>>
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPoint>
pub fn into_multi_point(self) -> Option<MultiPoint<T>>
Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPoint>
If this Geometry is a MultiPoint, then return that, else None.
sourcepub fn into_multi_line_string(self) -> Option<MultiLineString<T>>
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiLineString>
pub fn into_multi_line_string(self) -> Option<MultiLineString<T>>
Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiLineString>
If this Geometry is a MultiLineString, then return that, else None.
sourcepub fn into_multi_polygon(self) -> Option<MultiPolygon<T>>
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPolygon>
pub fn into_multi_polygon(self) -> Option<MultiPolygon<T>>
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
sourceimpl<T: CoordNum> From<LineString<T>> for Geometry<T>
impl<T: CoordNum> From<LineString<T>> for Geometry<T>
sourcefn from(x: LineString<T>) -> Self
fn from(x: LineString<T>) -> Self
Converts to this type from the input type.
sourceimpl<T: CoordNum> From<MultiLineString<T>> for Geometry<T>
impl<T: CoordNum> From<MultiLineString<T>> for Geometry<T>
sourcefn from(x: MultiLineString<T>) -> Self
fn from(x: MultiLineString<T>) -> Self
Converts to this type from the input type.
sourceimpl<T: CoordNum> From<MultiPoint<T>> for Geometry<T>
impl<T: CoordNum> From<MultiPoint<T>> for Geometry<T>
sourcefn from(x: MultiPoint<T>) -> Self
fn from(x: MultiPoint<T>) -> Self
Converts to this type from the input type.
sourceimpl<T: CoordNum> From<MultiPolygon<T>> for Geometry<T>
impl<T: CoordNum> From<MultiPolygon<T>> for Geometry<T>
sourcefn from(x: MultiPolygon<T>) -> Self
fn from(x: MultiPolygon<T>) -> Self
Converts to this type from the input type.
sourceimpl<T: CoordNum> TryFrom<Geometry<T>> for Point<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for Point<T>
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> TryFrom<Geometry<T>> for Line<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for Line<T>
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> TryFrom<Geometry<T>> for LineString<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for LineString<T>
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> TryFrom<Geometry<T>> for Polygon<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for Polygon<T>
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> TryFrom<Geometry<T>> for MultiPoint<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for MultiPoint<T>
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> TryFrom<Geometry<T>> for MultiLineString<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for MultiLineString<T>
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> TryFrom<Geometry<T>> for MultiPolygon<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for MultiPolygon<T>
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> TryFrom<Geometry<T>> for Rect<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for Rect<T>
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> TryFrom<Geometry<T>> for Triangle<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for Triangle<T>
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.
impl<T: Eq + CoordNum> Eq for Geometry<T>
impl<T: CoordNum> StructuralEq for Geometry<T>
impl<T: CoordNum> StructuralPartialEq for Geometry<T>
Auto Trait Implementations
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
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<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more