Struct geo::GeometryCollection[][src]

pub struct GeometryCollection<T>(pub Vec<Geometry<T>, Global>)
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> GeometryCollection<T> where
    T: CoordNum
[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> GeometryCollection<T> where
    T: CoordNum
[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> AbsDiffEq<GeometryCollection<T>> for GeometryCollection<T> where
    T: AbsDiffEq<T, Epsilon = T> + CoordNum,
    <T as AbsDiffEq<T>>::Epsilon: Copy
[src]

type Epsilon = T

Used for specifying relative comparisons.

pub fn abs_diff_eq(
    &self,
    other: &GeometryCollection<T>,
    epsilon: <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon
) -> bool
[src]

Equality assertion with an absolute limit.

Examples

use geo_types::{GeometryCollection, point};

let a = GeometryCollection(vec![point![x: 0.0, y: 0.0].into()]);
let b = GeometryCollection(vec![point![x: 0.0, y: 0.1].into()]);

approx::abs_diff_eq!(a, b, epsilon=0.1);
approx::abs_diff_ne!(a, b, epsilon=0.001);

impl<T> Area<T> for GeometryCollection<T> where
    T: CoordFloat
[src]

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

type Output = Option<Rect<T>>

impl<T> Centroid for GeometryCollection<T> where
    T: GeoFloat
[src]

type Output = Option<Point<T>>

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

impl<T> Contains<Coordinate<T>> for GeometryCollection<T> where
    T: GeoNum
[src]

impl<F> Contains<GeometryCollection<F>> for MultiPolygon<F> where
    F: GeoFloat
[src]

impl<T> Contains<Point<T>> for GeometryCollection<T> where
    T: GeoNum
[src]

impl<T> CoordinatePosition for GeometryCollection<T> where
    T: GeoNum
[src]

type Scalar = T

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

type Iter = Box<dyn Iterator<Item = Coordinate<T>> + 'a>

type ExteriorIter = Box<dyn Iterator<Item = Coordinate<T>> + 'a>

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the GeometryCollection.

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

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

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

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

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

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

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

impl<C: GeoNum> HasDimensions for GeometryCollection<C>[src]

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

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

type Output = Geometry<T>

The returned type after indexing.

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

impl<T, G> Intersects<G> for GeometryCollection<T> where
    T: CoordNum,
    Geometry<T>: Intersects<G>, 
[src]

impl<T> Intersects<GeometryCollection<T>> for Coordinate<T> where
    GeometryCollection<T>: Intersects<Coordinate<T>>,
    T: CoordNum
[src]

impl<T> Intersects<GeometryCollection<T>> for Line<T> where
    GeometryCollection<T>: Intersects<Line<T>>,
    T: CoordNum
[src]

impl<T> Intersects<GeometryCollection<T>> for Rect<T> where
    GeometryCollection<T>: Intersects<Rect<T>>,
    T: CoordNum
[src]

impl<T> Intersects<GeometryCollection<T>> for Polygon<T> where
    GeometryCollection<T>: Intersects<Polygon<T>>,
    T: CoordNum
[src]

impl<T> IntoIterator for GeometryCollection<T> where
    T: CoordNum
[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> IntoIterator for &'a mut GeometryCollection<T> where
    T: CoordNum
[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<'a, T> IntoIterator for &'a GeometryCollection<T> where
    T: CoordNum
[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<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for GeometryCollection<T>[src]

type Output = GeometryCollection<NT>

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

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

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Point<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Line<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for LineString<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Polygon<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for MultiPoint<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for MultiLineString<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for MultiPolygon<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Rect<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Triangle<F>[src]

impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, Line<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, LineString<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, MultiLineString<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, MultiPoint<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, Point<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, Polygon<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, Rect<F>> for GeometryCollection<F>[src]

impl<F: GeoFloat> Relate<F, Triangle<F>> for GeometryCollection<F>[src]

impl<T> RelativeEq<GeometryCollection<T>> for GeometryCollection<T> where
    T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>, 
[src]

pub fn relative_eq(
    &self,
    other: &GeometryCollection<T>,
    epsilon: <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon,
    max_relative: <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon
) -> bool
[src]

Equality assertion within a relative limit.

Examples

use geo_types::{GeometryCollection, point};

let a = GeometryCollection(vec![point![x: 1.0, y: 2.0].into()]);
let b = GeometryCollection(vec![point![x: 1.0, y: 2.01].into()]);

approx::assert_relative_eq!(a, b, max_relative=0.1);
approx::assert_relative_ne!(a, b, max_relative=0.0001);

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

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

impl<T: CoordNum, NT: CoordNum> TryMapCoords<T, NT> for GeometryCollection<T>[src]

type Output = GeometryCollection<NT>

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

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<'a, T, G> Extremes<'a, T> for G where
    T: CoordNum,
    G: CoordsIter<'a, Scalar = T>, 
[src]

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

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

impl<T, G> RotatePoint<T> for G where
    T: CoordFloat,
    G: MapCoords<T, T, Output = G>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

impl<T, G> Translate<T> for G where
    T: CoordNum,
    G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>, 
[src]

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.