Struct geo_types::GeometryCollection [−][src]
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(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]);
Tuple Fields
0: Vec<Geometry<T>>
Implementations
Trait Implementations
impl<T> AbsDiffEq<GeometryCollection<T>> for GeometryCollection<T> where
T: AbsDiffEq<Epsilon = T> + CoordNum,
T::Epsilon: Copy,
impl<T> AbsDiffEq<GeometryCollection<T>> for GeometryCollection<T> where
T: AbsDiffEq<Epsilon = T> + CoordNum,
T::Epsilon: Copy,
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);
type Epsilon = T
type Epsilon = T
Used for specifying relative comparisons.
The default tolerance to use when testing values that are close together. Read more
The inverse of AbsDiffEq::abs_diff_eq
.
Convert any Geometry (or anything that can be converted to a Geometry) into a GeometryCollection
Collect Geometries (or what can be converted to a Geometry) into a GeometryCollection
Creates a value from an iterator. Read more
impl<T: PartialEq> PartialEq<GeometryCollection<T>> for GeometryCollection<T> where
T: CoordNum,
impl<T: PartialEq> PartialEq<GeometryCollection<T>> for GeometryCollection<T> where
T: CoordNum,
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
impl<T> RelativeEq<GeometryCollection<T>> for GeometryCollection<T> where
T: AbsDiffEq<Epsilon = T> + CoordNum + RelativeEq,
impl<T> RelativeEq<GeometryCollection<T>> for GeometryCollection<T> where
T: AbsDiffEq<Epsilon = T> + CoordNum + RelativeEq,
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);
The default relative tolerance for testing values that are far-apart. Read more
The inverse of RelativeEq::relative_eq
.
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
Mutably borrows from an owned value. Read more