Enum geo::Geometry [−][src]
pub enum Geometry<T> where
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>)
Tuple Fields
0: Point<T>
Line(Line<T>)
Tuple Fields
0: Line<T>
LineString(LineString<T>)
Tuple Fields
0: LineString<T>
Polygon(Polygon<T>)
Tuple Fields
0: Polygon<T>
MultiPoint(MultiPoint<T>)
Tuple Fields
0: MultiPoint<T>
MultiLineString(MultiLineString<T>)
Tuple Fields
0: MultiLineString<T>
MultiPolygon(MultiPolygon<T>)
Tuple Fields
0: MultiPolygon<T>
GeometryCollection(GeometryCollection<T>)
Tuple Fields
0: GeometryCollection<T>
Rect(Rect<T>)
Tuple Fields
0: Rect<T>
Triangle(Triangle<T>)
Tuple Fields
0: Triangle<T>
Implementations
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Point>
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::*;
let g = Geometry::Point(Point::new(0., 0.));
let p2: Point<f32> = g.into_point().unwrap();
assert_eq!(p2, Point::new(0., 0.,));
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<LineString>
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.
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Line>
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.
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<Polygon>
Will be removed in an upcoming version. Switch to std::convert::TryInto<Polygon>
If this Geometry is a Polygon, then return that, else None.
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPoint>
Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPoint>
If this Geometry is a MultiPoint, then return that, else None.
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiLineString>
Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiLineString>
If this Geometry is a MultiLineString, then return that, else None.
👎 Deprecated: Will be removed in an upcoming version. Switch to std::convert::TryInto<MultiPolygon>
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
Equality assertion with an absolute limit.
Examples
use geo_types::{Geometry, polygon};
let a: Geometry<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7., y: 9.), (x: 0., y: 0.)].into();
let b: Geometry<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7.01, y: 9.), (x: 0., y: 0.)].into();
approx::assert_abs_diff_eq!(a, b, epsilon=0.1);
approx::assert_abs_diff_ne!(a, b, epsilon=0.001);
type Epsilon = T
type Epsilon = T
Used for specifying relative comparisons.
The default tolerance to use when testing values that are close together. Read more
The inverse of AbsDiffEq::abs_diff_eq
.
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
Return the number of coordinates in the Geometry
.
type Iter = GeometryCoordsIter<'a, T>
type ExteriorIter = GeometryExteriorCoordsIter<'a, T>
type Scalar = T
Iterate over all exterior and (if any) interior coordinates of a geometry. Read more
Iterate over all exterior coordinates of a geometry. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Some geometries, like a MultiPoint
, can have zero coordinates - we call these empty
. Read more
The dimensions of some geometries are fixed, e.g. a Point always has 0 dimensions. However
for others, the dimensionality depends on the specific geometry instance - for example
typical Rect
s are 2-dimensional, but it’s possible to create degenerate Rect
s which
have either 1 or 0 dimensions. Read more
The dimensions of the Geometry
’s boundary, as used by OGC-SFA. Read more
impl<T, G> Intersects<G> for Geometry<T> where
T: CoordNum,
Point<T>: Intersects<G>,
MultiPoint<T>: Intersects<G>,
Line<T>: Intersects<G>,
LineString<T>: Intersects<G>,
MultiLineString<T>: Intersects<G>,
Triangle<T>: Intersects<G>,
Rect<T>: Intersects<G>,
Polygon<T>: Intersects<G>,
MultiPolygon<T>: Intersects<G>,
impl<T, G> Intersects<G> for Geometry<T> where
T: CoordNum,
Point<T>: Intersects<G>,
MultiPoint<T>: Intersects<G>,
Line<T>: Intersects<G>,
LineString<T>: Intersects<G>,
MultiLineString<T>: Intersects<G>,
Triangle<T>: Intersects<G>,
Rect<T>: Intersects<G>,
Polygon<T>: Intersects<G>,
MultiPolygon<T>: Intersects<G>,
impl<T> Intersects<Geometry<T>> for Coordinate<T> where
Geometry<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Coordinate<T> where
Geometry<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Line<T> where
Geometry<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Line<T> where
Geometry<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Rect<T> where
Geometry<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Rect<T> where
Geometry<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Polygon<T> where
Geometry<T>: Intersects<Polygon<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Polygon<T> where
Geometry<T>: Intersects<Polygon<T>>,
T: CoordNum,
impl<T> RelativeEq<Geometry<T>> for Geometry<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
impl<T> RelativeEq<Geometry<T>> for Geometry<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
Equality assertion within a relative limit.
Examples
use geo_types::{Geometry, polygon};
let a: Geometry<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7., y: 9.), (x: 0., y: 0.)].into();
let b: Geometry<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7.01, y: 9.), (x: 0., y: 0.)].into();
approx::assert_relative_eq!(a, b, max_relative=0.1);
approx::assert_relative_ne!(a, b, max_relative=0.001);
The default relative tolerance for testing values that are far-apart. Read more
The inverse of RelativeEq::relative_eq
.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Auto Trait Implementations
impl<T> RefUnwindSafe for Geometry<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Geometry<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more