[][src]Struct geo_types::GeometryCollection

pub struct GeometryCollection<T>(pub Vec<Geometry<T>>)
where
    T: CoordNum
;

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(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(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(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(vec![pe]);
println!("{:?}", gc[0]);

Implementations

impl<T: CoordNum> GeometryCollection<T>[src]

pub fn new() -> GeometryCollection<T>[src]

Return an empty GeometryCollection

pub fn len(&self) -> usize[src]

Number of geometries in this GeometryCollection

pub fn is_empty(&self) -> bool[src]

Is this GeometryCollection empty

impl<'a, T: CoordNum> GeometryCollection<T>[src]

pub fn iter(&'a self) -> IterHelper<'a, T>[src]

pub fn iter_mut(&'a mut self) -> IterMutHelper<'a, T>[src]

Trait Implementations

impl<T: Clone> Clone for GeometryCollection<T> where
    T: CoordNum
[src]

impl<T: Debug> Debug for GeometryCollection<T> where
    T: CoordNum
[src]

impl<T: CoordNum> Default for GeometryCollection<T>[src]

impl<T: Eq> Eq for GeometryCollection<T> where
    T: CoordNum
[src]

impl<T: CoordNum, IG: Into<Geometry<T>>> From<IG> for GeometryCollection<T>[src]

Convert any Geometry (or anything that can be converted to a Geometry) into a GeometryCollection

impl<T: CoordNum, IG: Into<Geometry<T>>> FromIterator<IG> for GeometryCollection<T>[src]

Collect Geometries (or what can be converted to a Geometry) into a GeometryCollection

impl<T: Hash> Hash for GeometryCollection<T> where
    T: CoordNum
[src]

impl<T: CoordNum> Index<usize> for GeometryCollection<T>[src]

type Output = Geometry<T>

The returned type after indexing.

impl<T: CoordNum> IndexMut<usize> for GeometryCollection<T>[src]

impl<T: CoordNum> IntoIterator for GeometryCollection<T>[src]

type Item = Geometry<T>

The type of the elements being iterated over.

type IntoIter = IntoIteratorHelper<T>

Which kind of iterator are we turning this into?

impl<'a, T: CoordNum> IntoIterator for &'a GeometryCollection<T>[src]

type Item = &'a Geometry<T>

The type of the elements being iterated over.

type IntoIter = IterHelper<'a, T>

Which kind of iterator are we turning this into?

impl<'a, T: CoordNum> IntoIterator for &'a mut GeometryCollection<T>[src]

type Item = &'a mut Geometry<T>

The type of the elements being iterated over.

type IntoIter = IterMutHelper<'a, T>

Which kind of iterator are we turning this into?

impl<T: PartialEq> PartialEq<GeometryCollection<T>> for GeometryCollection<T> where
    T: CoordNum
[src]

impl<T> StructuralEq for GeometryCollection<T> where
    T: CoordNum
[src]

impl<T> StructuralPartialEq for GeometryCollection<T> where
    T: CoordNum
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for GeometryCollection<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for GeometryCollection<T> where
    T: Send
[src]

impl<T> Sync for GeometryCollection<T> where
    T: Sync
[src]

impl<T> Unpin for GeometryCollection<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for GeometryCollection<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.