Struct geo_types::GeometryCollection
source · [−]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
sourceimpl<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
Will be replaced with a parametrized version in upcoming version. Use GeometryCollection::default() instead
Return an empty GeometryCollection
Trait Implementations
sourceimpl<T: Clone + CoordNum> Clone for GeometryCollection<T>
impl<T: Clone + CoordNum> Clone for GeometryCollection<T>
sourcefn clone(&self) -> GeometryCollection<T>
fn clone(&self) -> GeometryCollection<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug + CoordNum> Debug for GeometryCollection<T>
impl<T: Debug + CoordNum> Debug for GeometryCollection<T>
sourceimpl<T: CoordNum> Default for GeometryCollection<T>
impl<T: CoordNum> Default for GeometryCollection<T>
sourceimpl<T: CoordNum, IG: Into<Geometry<T>>> From<IG> for GeometryCollection<T>
impl<T: CoordNum, IG: Into<Geometry<T>>> From<IG> for GeometryCollection<T>
Convert any Geometry (or anything that can be converted to a Geometry) into a GeometryCollection
sourceimpl<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
sourcefn 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
sourceimpl<T: Hash + CoordNum> Hash for GeometryCollection<T>
impl<T: Hash + CoordNum> Hash for GeometryCollection<T>
sourceimpl<T: CoordNum> Index<usize> for GeometryCollection<T>
impl<T: CoordNum> Index<usize> for GeometryCollection<T>
sourceimpl<T: CoordNum> IndexMut<usize> for GeometryCollection<T>
impl<T: CoordNum> IndexMut<usize> for GeometryCollection<T>
sourceimpl<T: CoordNum> IntoIterator for GeometryCollection<T>
impl<T: CoordNum> IntoIterator for GeometryCollection<T>
sourceimpl<'a, T: CoordNum> IntoIterator for &'a GeometryCollection<T>
impl<'a, T: CoordNum> IntoIterator for &'a GeometryCollection<T>
sourceimpl<'a, T: CoordNum> IntoIterator for &'a mut GeometryCollection<T>
impl<'a, T: CoordNum> IntoIterator for &'a mut GeometryCollection<T>
sourceimpl<T: PartialEq + CoordNum> PartialEq<GeometryCollection<T>> for GeometryCollection<T>
impl<T: PartialEq + CoordNum> PartialEq<GeometryCollection<T>> for GeometryCollection<T>
sourcefn eq(&self, other: &GeometryCollection<T>) -> bool
fn eq(&self, other: &GeometryCollection<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &GeometryCollection<T>) -> bool
fn ne(&self, other: &GeometryCollection<T>) -> bool
This method tests for !=
.
impl<T: Eq + CoordNum> Eq for GeometryCollection<T>
impl<T: CoordNum> StructuralEq for GeometryCollection<T>
impl<T: CoordNum> StructuralPartialEq for GeometryCollection<T>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more