geo_types::geometry

Enum 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<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: 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 u8)

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