pub enum Geometry<T: CoordNum = f64> {
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: 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>>
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>>
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>>
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>>
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>>
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>>
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>>
If this Geometry is a MultiPolygon, then return that, else None.
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Geometry<T>where
T: Deserialize<'de> + CoordNum,
impl<'de, T> Deserialize<'de> for Geometry<T>where
T: Deserialize<'de> + CoordNum,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<T: CoordNum> From<LineString<T>> for Geometry<T>
impl<T: CoordNum> From<LineString<T>> for Geometry<T>
source§fn from(x: LineString<T>) -> Self
fn from(x: LineString<T>) -> Self
source§impl<T: CoordNum> From<MultiLineString<T>> for Geometry<T>
impl<T: CoordNum> From<MultiLineString<T>> for Geometry<T>
source§fn from(x: MultiLineString<T>) -> Self
fn from(x: MultiLineString<T>) -> Self
source§impl<T: CoordNum> From<MultiPoint<T>> for Geometry<T>
impl<T: CoordNum> From<MultiPoint<T>> for Geometry<T>
source§fn from(x: MultiPoint<T>) -> Self
fn from(x: MultiPoint<T>) -> Self
source§impl<T: CoordNum> From<MultiPolygon<T>> for Geometry<T>
impl<T: CoordNum> From<MultiPolygon<T>> for Geometry<T>
source§fn from(x: MultiPolygon<T>) -> Self
fn from(x: MultiPolygon<T>) -> Self
source§impl<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.
source§impl<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.
source§impl<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.
source§impl<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.
source§impl<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.
source§impl<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.
source§impl<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.
source§impl<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.
source§impl<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> StructuralPartialEq for Geometry<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)