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<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.