pub struct GeometryCollection<T = f64>(pub Vec<Geometry<T>>)
where
T: CoordNum;geo-types only.Expand description
A collection of Geometry types.
It can be created from a Vec of Geometries, or from an Iterator which yields Geometries.
Looping over this object yields its component Geometry
enum members (not the underlying geometry
primitives), and it supports iteration and indexing as
well as the various
MapCoords
functions, which are directly applied to the
underlying geometry primitives.
§Examples
§Looping
use std::convert::TryFrom;
use geo_types::{Point, point, Geometry, GeometryCollection};
let p = point!(x: 1.0, y: 1.0);
let pe = Geometry::Point(p);
let gc = GeometryCollection::new_from(vec![pe]);
for geom in gc {
println!("{:?}", Point::try_from(geom).unwrap().x());
}§Implements iter()
use std::convert::TryFrom;
use geo_types::{Point, point, Geometry, GeometryCollection};
let p = point!(x: 1.0, y: 1.0);
let pe = Geometry::Point(p);
let gc = GeometryCollection::new_from(vec![pe]);
gc.iter().for_each(|geom| println!("{:?}", geom));§Mutable Iteration
use std::convert::TryFrom;
use geo_types::{Point, point, Geometry, GeometryCollection};
let p = point!(x: 1.0, y: 1.0);
let pe = Geometry::Point(p);
let mut gc = GeometryCollection::new_from(vec![pe]);
gc.iter_mut().for_each(|geom| {
if let Geometry::Point(p) = geom {
p.set_x(0.2);
}
});
let updated = gc[0].clone();
assert_eq!(Point::try_from(updated).unwrap().x(), 0.2);§Indexing
use std::convert::TryFrom;
use geo_types::{Point, point, Geometry, GeometryCollection};
let p = point!(x: 1.0, y: 1.0);
let pe = Geometry::Point(p);
let gc = GeometryCollection::new_from(vec![pe]);
println!("{:?}", gc[0]);Tuple Fields§
§0: Vec<Geometry<T>>Implementations§
Source§impl<T> GeometryCollection<T>where
T: CoordNum,
impl<T> GeometryCollection<T>where
T: CoordNum,
Sourcepub fn new() -> GeometryCollection<T>
👎Deprecated: Will be replaced with a parametrized version in upcoming version. Use GeometryCollection::empty() instead
pub fn new() -> GeometryCollection<T>
Return an empty GeometryCollection
Sourcepub fn new_from(value: Vec<Geometry<T>>) -> GeometryCollection<T>
pub fn new_from(value: Vec<Geometry<T>>) -> GeometryCollection<T>
DO NOT USE!
This fn will be renamed to new in the upcoming version.
This fn is not marked as deprecated because it would require extensive refactoring of the geo code.
Sourcepub fn empty() -> GeometryCollection<T>
pub fn empty() -> GeometryCollection<T>
Returns an empty GeometryCollection
Trait Implementations§
Source§impl<T> Clone for GeometryCollection<T>
impl<T> Clone for GeometryCollection<T>
Source§fn clone(&self) -> GeometryCollection<T>
fn clone(&self) -> GeometryCollection<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for GeometryCollection<T>where
T: CoordNum,
impl<T> Debug for GeometryCollection<T>where
T: CoordNum,
Source§impl<T> Default for GeometryCollection<T>where
T: CoordNum,
impl<T> Default for GeometryCollection<T>where
T: CoordNum,
Source§fn default() -> GeometryCollection<T>
fn default() -> GeometryCollection<T>
Source§impl<T, IG> From<IG> for GeometryCollection<T>
DO NOT USE! Deprecated since 0.7.5.
impl<T, IG> From<IG> for GeometryCollection<T>
DO NOT USE! Deprecated since 0.7.5.
Use GeometryCollection::from(vec![geom]) instead.
Source§fn from(x: IG) -> GeometryCollection<T>
fn from(x: IG) -> GeometryCollection<T>
Source§impl<T, IG> From<Vec<IG>> for GeometryCollection<T>
impl<T, IG> From<Vec<IG>> for GeometryCollection<T>
Source§fn from(geoms: Vec<IG>) -> GeometryCollection<T>
fn from(geoms: Vec<IG>) -> GeometryCollection<T>
Source§impl<T, IG> FromIterator<IG> for GeometryCollection<T>
Collect Geometries (or what can be converted to a Geometry) into a GeometryCollection
impl<T, IG> FromIterator<IG> for GeometryCollection<T>
Collect Geometries (or what can be converted to a Geometry) into a GeometryCollection
Source§fn from_iter<I>(iter: I) -> GeometryCollection<T>where
I: IntoIterator<Item = IG>,
fn from_iter<I>(iter: I) -> GeometryCollection<T>where
I: IntoIterator<Item = IG>,
Source§impl<'a, T> GeometryCollectionTrait for &'a GeometryCollection<T>where
T: CoordNum,
impl<'a, T> GeometryCollectionTrait for &'a GeometryCollection<T>where
T: CoordNum,
Source§type GeometryType<'b> = &'a Geometry<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type GeometryType<'b> = &'a Geometry<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§fn num_geometries(&self) -> usize
fn num_geometries(&self) -> usize
Source§unsafe fn geometry_unchecked(
&self,
i: usize,
) -> <&'a GeometryCollection<T> as GeometryCollectionTrait>::GeometryType<'_>
unsafe fn geometry_unchecked( &self, i: usize, ) -> <&'a GeometryCollection<T> as GeometryCollectionTrait>::GeometryType<'_>
Source§fn geometries(&self) -> impl DoubleEndedIterator + ExactSizeIterator
fn geometries(&self) -> impl DoubleEndedIterator + ExactSizeIterator
Source§impl<T> GeometryCollectionTrait for GeometryCollection<T>where
T: CoordNum,
impl<T> GeometryCollectionTrait for GeometryCollection<T>where
T: CoordNum,
Source§type GeometryType<'a> = &'a Geometry<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'a
type GeometryType<'a> = &'a Geometry<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'a
Source§fn num_geometries(&self) -> usize
fn num_geometries(&self) -> usize
Source§unsafe fn geometry_unchecked(
&self,
i: usize,
) -> <GeometryCollection<T> as GeometryCollectionTrait>::GeometryType<'_>
unsafe fn geometry_unchecked( &self, i: usize, ) -> <GeometryCollection<T> as GeometryCollectionTrait>::GeometryType<'_>
Source§fn geometries(&self) -> impl DoubleEndedIterator + ExactSizeIterator
fn geometries(&self) -> impl DoubleEndedIterator + ExactSizeIterator
Source§impl<'a, T> GeometryTrait for &'a GeometryCollection<T>where
T: CoordNum + 'a,
impl<'a, T> GeometryTrait for &'a GeometryCollection<T>where
T: CoordNum + 'a,
Source§type PointType<'b> = Point<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type PointType<'b> = Point<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type LineStringType<'b> = LineString<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type LineStringType<'b> = LineString<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type PolygonType<'b> = Polygon<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type PolygonType<'b> = Polygon<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type MultiPointType<'b> = MultiPoint<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type MultiPointType<'b> = MultiPoint<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type MultiLineStringType<'b> = MultiLineString<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type MultiLineStringType<'b> = MultiLineString<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type MultiPolygonType<'b> = MultiPolygon<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type MultiPolygonType<'b> = MultiPolygon<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type GeometryCollectionType<'b> = GeometryCollection<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type GeometryCollectionType<'b> = GeometryCollection<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type RectType<'b> = Rect<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type RectType<'b> = Rect<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type TriangleType<'b> = Triangle<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type TriangleType<'b> = Triangle<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§type LineType<'b> = Line<<&'a GeometryCollection<T> as GeometryTrait>::T>
where
&'a GeometryCollection<T>: 'b
type LineType<'b> = Line<<&'a GeometryCollection<T> as GeometryTrait>::T> where &'a GeometryCollection<T>: 'b
Source§fn dim(&self) -> Dimensions
fn dim(&self) -> Dimensions
Source§fn as_type(
&self,
) -> GeometryType<'_, Point<T>, LineString<T>, Polygon<T>, MultiPoint<T>, MultiLineString<T>, MultiPolygon<T>, GeometryCollection<T>, Rect<T>, Triangle<T>, Line<T>>
fn as_type( &self, ) -> GeometryType<'_, Point<T>, LineString<T>, Polygon<T>, MultiPoint<T>, MultiLineString<T>, MultiPolygon<T>, GeometryCollection<T>, Rect<T>, Triangle<T>, Line<T>>
GeometryType enum, which allows for downcasting to a specific
typeSource§impl<T> GeometryTrait for GeometryCollection<T>where
T: CoordNum,
impl<T> GeometryTrait for GeometryCollection<T>where
T: CoordNum,
Source§type PointType<'b> = Point<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type PointType<'b> = Point<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type LineStringType<'b> = LineString<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type LineStringType<'b> = LineString<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type PolygonType<'b> = Polygon<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type PolygonType<'b> = Polygon<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type MultiPointType<'b> = MultiPoint<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type MultiPointType<'b> = MultiPoint<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type MultiLineStringType<'b> = MultiLineString<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type MultiLineStringType<'b> = MultiLineString<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type MultiPolygonType<'b> = MultiPolygon<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type MultiPolygonType<'b> = MultiPolygon<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type GeometryCollectionType<'b> = GeometryCollection<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type GeometryCollectionType<'b> = GeometryCollection<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type RectType<'b> = Rect<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type RectType<'b> = Rect<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type TriangleType<'b> = Triangle<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type TriangleType<'b> = Triangle<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§type LineType<'b> = Line<<GeometryCollection<T> as GeometryTrait>::T>
where
GeometryCollection<T>: 'b
type LineType<'b> = Line<<GeometryCollection<T> as GeometryTrait>::T> where GeometryCollection<T>: 'b
Source§fn dim(&self) -> Dimensions
fn dim(&self) -> Dimensions
Source§fn as_type(
&self,
) -> GeometryType<'_, Point<T>, LineString<T>, Polygon<T>, MultiPoint<T>, MultiLineString<T>, MultiPolygon<T>, GeometryCollection<T>, Rect<T>, Triangle<T>, Line<T>>
fn as_type( &self, ) -> GeometryType<'_, Point<T>, LineString<T>, Polygon<T>, MultiPoint<T>, MultiLineString<T>, MultiPolygon<T>, GeometryCollection<T>, Rect<T>, Triangle<T>, Line<T>>
GeometryType enum, which allows for downcasting to a specific
typeSource§impl<T> Hash for GeometryCollection<T>
impl<T> Hash for GeometryCollection<T>
Source§impl<'a, T> IntoIterator for &'a GeometryCollection<T>where
T: CoordNum,
impl<'a, T> IntoIterator for &'a GeometryCollection<T>where
T: CoordNum,
Source§impl<'a, T> IntoIterator for &'a mut GeometryCollection<T>where
T: CoordNum,
impl<'a, T> IntoIterator for &'a mut GeometryCollection<T>where
T: CoordNum,
Source§fn into_iter(self) -> <&'a mut GeometryCollection<T> as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a mut GeometryCollection<T> as IntoIterator>::IntoIter
Source§impl<T> IntoIterator for GeometryCollection<T>where
T: CoordNum,
impl<T> IntoIterator for GeometryCollection<T>where
T: CoordNum,
Source§impl<T> PartialEq for GeometryCollection<T>
impl<T> PartialEq for GeometryCollection<T>
Source§impl<T> ToWkt<T> for GeometryCollection<T>
§Examples
use geo_types::{line_string, LineString, polygon, Polygon, GeometryCollection};
use wkt::ToWkt;
let polygon: Polygon<f64> = polygon![(x: 0., y: 0.), (x: 4., y: 0.), (x: 2., y: 4.), (x: 0., y: 0.)];
let line_string: LineString<f64> = line_string![(x: 1., y: 2.), (x: 3., y: 4.), (x: 5., y: 6.)];
let geometry_collection: GeometryCollection<f64> = GeometryCollection::new_from(vec![polygon.into(), line_string.into()]);
assert_eq!(geometry_collection.wkt_string(), "GEOMETRYCOLLECTION(POLYGON((0 0,4 0,2 4,0 0)),LINESTRING(1 2,3 4,5 6))");
impl<T> ToWkt<T> for GeometryCollection<T>
§Examples
use geo_types::{line_string, LineString, polygon, Polygon, GeometryCollection};
use wkt::ToWkt;
let polygon: Polygon<f64> = polygon![(x: 0., y: 0.), (x: 4., y: 0.), (x: 2., y: 4.), (x: 0., y: 0.)];
let line_string: LineString<f64> = line_string![(x: 1., y: 2.), (x: 3., y: 4.), (x: 5., y: 6.)];
let geometry_collection: GeometryCollection<f64> = GeometryCollection::new_from(vec![polygon.into(), line_string.into()]);
assert_eq!(geometry_collection.wkt_string(), "GEOMETRYCOLLECTION(POLYGON((0 0,4 0,2 4,0 0)),LINESTRING(1 2,3 4,5 6))");Source§impl<T> TryFrom<GeometryCollection<T>> for GeometryCollection<T>where
T: CoordNum,
impl<T> TryFrom<GeometryCollection<T>> for GeometryCollection<T>where
T: CoordNum,
Source§fn try_from(
geometry_collection: GeometryCollection<T>,
) -> Result<GeometryCollection<T>, <GeometryCollection<T> as TryFrom<GeometryCollection<T>>>::Error>
fn try_from( geometry_collection: GeometryCollection<T>, ) -> Result<GeometryCollection<T>, <GeometryCollection<T> as TryFrom<GeometryCollection<T>>>::Error>
Source§impl<T> TryFrom<Wkt<T>> for GeometryCollection<T>where
T: CoordNum,
Fallibly convert this WKT primitive into this geo_types primitive
impl<T> TryFrom<Wkt<T>> for GeometryCollection<T>where
T: CoordNum,
Fallibly convert this WKT primitive into this geo_types primitive
Source§impl<T> TryFromWkt<T> for GeometryCollection<T>
impl<T> TryFromWkt<T> for GeometryCollection<T>
type Error = Error
Source§fn try_from_wkt_str(
wkt_str: &str,
) -> Result<GeometryCollection<T>, <GeometryCollection<T> as TryFromWkt<T>>::Error>
fn try_from_wkt_str( wkt_str: &str, ) -> Result<GeometryCollection<T>, <GeometryCollection<T> as TryFromWkt<T>>::Error>
Source§fn try_from_wkt_reader(
wkt_reader: impl Read,
) -> Result<GeometryCollection<T>, <GeometryCollection<T> as TryFromWkt<T>>::Error>
fn try_from_wkt_reader( wkt_reader: impl Read, ) -> Result<GeometryCollection<T>, <GeometryCollection<T> as TryFromWkt<T>>::Error>
impl<T> Eq for GeometryCollection<T>
impl<T> StructuralPartialEq for GeometryCollection<T>where
T: CoordNum,
Auto Trait Implementations§
impl<T> Freeze for GeometryCollection<T>
impl<T> RefUnwindSafe for GeometryCollection<T>where
T: RefUnwindSafe,
impl<T> Send for GeometryCollection<T>where
T: Send,
impl<T> Sync for GeometryCollection<T>where
T: Sync,
impl<T> Unpin for GeometryCollection<T>where
T: Unpin,
impl<T> UnwindSafe for GeometryCollection<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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, G> ToGeoGeometry<T> for Gwhere
T: CoordNum,
G: GeometryTrait<T = T>,
impl<T, G> ToGeoGeometry<T> for Gwhere
T: CoordNum,
G: GeometryTrait<T = T>,
Source§impl<T, G> ToGeoGeometryCollection<T> for Gwhere
T: CoordNum,
G: GeometryCollectionTrait<T = T>,
impl<T, G> ToGeoGeometryCollection<T> for Gwhere
T: CoordNum,
G: GeometryCollectionTrait<T = T>,
Source§fn try_to_geometry_collection(&self) -> Option<GeometryCollection<T>>
fn try_to_geometry_collection(&self) -> Option<GeometryCollection<T>>
GeometryCollection. Read moreSource§fn to_geometry_collection(&self) -> GeometryCollection<T>
fn to_geometry_collection(&self) -> GeometryCollection<T>
GeometryCollection. Read more