Struct geo_types::geometry::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§
source§impl<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
Return an empty GeometryCollection
Trait Implementations§
source§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,
source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Equality assertion with an absolute limit.
Examples
use geo_types::{GeometryCollection, point};
let a = GeometryCollection::new_from(vec![point![x: 0.0, y: 0.0].into()]);
let b = GeometryCollection::new_from(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);
source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq
.source§impl<T: Clone + CoordNum> Clone for GeometryCollection<T>
impl<T: Clone + CoordNum> Clone for GeometryCollection<T>
source§fn clone(&self) -> GeometryCollection<T>
fn clone(&self) -> GeometryCollection<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: CoordNum> Default for GeometryCollection<T>
impl<T: CoordNum> Default for GeometryCollection<T>
source§impl<'de, T> Deserialize<'de> for GeometryCollection<T>where
T: Deserialize<'de> + CoordNum,
impl<'de, T> Deserialize<'de> for GeometryCollection<T>where
T: Deserialize<'de> + CoordNum,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<T: CoordNum, IG: Into<Geometry<T>>> From<IG> for GeometryCollection<T>
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§impl<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
source§fn 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
source§impl<'a, T: CoordNum> IntoIterator for &'a GeometryCollection<T>
impl<'a, T: CoordNum> IntoIterator for &'a GeometryCollection<T>
source§impl<'a, T: CoordNum> IntoIterator for &'a mut GeometryCollection<T>
impl<'a, T: CoordNum> IntoIterator for &'a mut GeometryCollection<T>
source§impl<T: CoordNum> IntoIterator for GeometryCollection<T>
impl<T: CoordNum> IntoIterator for GeometryCollection<T>
source§impl<T: PartialEq + CoordNum> PartialEq<GeometryCollection<T>> for GeometryCollection<T>
impl<T: PartialEq + CoordNum> PartialEq<GeometryCollection<T>> for GeometryCollection<T>
source§fn eq(&self, other: &GeometryCollection<T>) -> bool
fn eq(&self, other: &GeometryCollection<T>) -> bool
source§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,
source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
Equality assertion within a relative limit.
Examples
use geo_types::{GeometryCollection, point};
let a = GeometryCollection::new_from(vec![point![x: 1.0, y: 2.0].into()]);
let b = GeometryCollection::new_from(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);
source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of
RelativeEq::relative_eq
.