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>

source

pub fn new() -> Self

👎Deprecated: Will be replaced with a parametrized version in upcoming version. Use GeometryCollection::default() instead

Return an empty GeometryCollection

source

pub fn new_from(value: Vec<Geometry<T>>) -> Self

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.

source

pub fn len(&self) -> usize

Number of geometries in this GeometryCollection

source

pub fn is_empty(&self) -> bool

Is this GeometryCollection empty

source§

impl<'a, T: CoordNum> GeometryCollection<T>

source

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

source

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

Trait Implementations§

source§

impl<T: Clone + CoordNum> Clone for GeometryCollection<T>

source§

fn clone(&self) -> GeometryCollection<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + CoordNum> Debug for GeometryCollection<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: CoordNum> Default for GeometryCollection<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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§

fn from(x: IG) -> Self

Converts to this type from the input type.
source§

impl<T: CoordNum, IG: Into<Geometry<T>>> From<Vec<IG>> for GeometryCollection<T>

source§

fn from(geoms: Vec<IG>) -> Self

Converts to this type from the input type.
source§

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

Creates a value from an iterator. Read more
source§

impl<T: Hash + CoordNum> Hash for GeometryCollection<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: CoordNum> Index<usize> for GeometryCollection<T>

§

type Output = Geometry<T>

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Geometry<T>

Performs the indexing (container[index]) operation. Read more
source§

impl<T: CoordNum> IndexMut<usize> for GeometryCollection<T>

source§

fn index_mut(&mut self, index: usize) -> &mut Geometry<T>

Performs the mutable indexing (container[index]) operation. Read more
source§

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

§

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?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

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

§

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?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: CoordNum> IntoIterator for GeometryCollection<T>

§

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?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: PartialEq + CoordNum> PartialEq for GeometryCollection<T>

source§

fn eq(&self, other: &GeometryCollection<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq + CoordNum> Eq for GeometryCollection<T>

source§

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.