Enum geo_types::geometry::Geometry

source ·
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>

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: Clone + CoordNum> Clone for Geometry<T>

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<T: Debug + CoordNum> Debug for Geometry<T>

source§

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

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

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

Deserialize this value from the given Serde deserializer. Read more
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

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: PartialEq + CoordNum> PartialEq for Geometry<T>

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<T> Serialize for Geometry<T>
where T: Serialize + CoordNum,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

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§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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.

source§

type Error = Error

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

fn try_from(geom: Geometry<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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

source§

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> 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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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<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, 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,