Struct geo_types::geometry::GeometryCollection
source · pub struct GeometryCollection<T: CoordNum = f64>(pub Vec<Geometry<T>>);
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: CoordNum> GeometryCollection<T>
impl<T: CoordNum> GeometryCollection<T>
sourcepub fn new() -> Self
👎Deprecated: Will be replaced with a parametrized version in upcoming version. Use GeometryCollection::default() instead
pub fn new() -> Self
Return an empty GeometryCollection
Trait Implementations§
source§impl<T: Clone + CoordNum> Clone for GeometryCollection<T>
impl<T: Clone + CoordNum> Clone for GeometryCollection<T>
source§fn clone(&self) -> GeometryCollection<T>
fn clone(&self) -> GeometryCollection<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: CoordNum> Default for GeometryCollection<T>
impl<T: CoordNum> Default for GeometryCollection<T>
source§impl<'de, T> Deserialize<'de> for GeometryCollection<T>where
T: Deserialize<'de> + CoordNum,
impl<'de, T> Deserialize<'de> for GeometryCollection<T>where
T: Deserialize<'de> + CoordNum,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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, IG: Into<Geometry<T>>> From<IG> for GeometryCollection<T>
impl<T: CoordNum, IG: Into<Geometry<T>>> From<IG> for GeometryCollection<T>
DO NOT USE! Deprecated since 0.7.5.
Use GeometryCollection::from(vec![geom])
instead.
source§impl<T: CoordNum, IG: Into<Geometry<T>>> FromIterator<IG> for GeometryCollection<T>
impl<T: CoordNum, IG: Into<Geometry<T>>> FromIterator<IG> for GeometryCollection<T>
Collect Geometries (or what can be converted to a Geometry) into a GeometryCollection
source§fn from_iter<I: IntoIterator<Item = IG>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = IG>>(iter: I) -> Self
Creates a value from an iterator. Read more
source§impl<'a, T: CoordNum> IntoIterator for &'a GeometryCollection<T>
impl<'a, T: CoordNum> IntoIterator for &'a GeometryCollection<T>
source§impl<'a, T: CoordNum> IntoIterator for &'a mut GeometryCollection<T>
impl<'a, T: CoordNum> IntoIterator for &'a mut GeometryCollection<T>
source§impl<T: CoordNum> IntoIterator for GeometryCollection<T>
impl<T: CoordNum> IntoIterator for GeometryCollection<T>
source§impl<T> Serialize for GeometryCollection<T>
impl<T> Serialize for GeometryCollection<T>
impl<T: Eq + CoordNum> Eq for GeometryCollection<T>
impl<T: CoordNum> StructuralPartialEq for GeometryCollection<T>
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)