Struct geo::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>, Global>
Implementations
Trait Implementations
impl<T> AbsDiffEq<GeometryCollection<T>> for GeometryCollection<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
<T as AbsDiffEq<T>>::Epsilon: Copy,
impl<T> AbsDiffEq<GeometryCollection<T>> for GeometryCollection<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
<T as AbsDiffEq<T>>::Epsilon: Copy,
pub fn abs_diff_eq(
&self,
other: &GeometryCollection<T>,
epsilon: <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon
) -> bool
pub fn abs_diff_eq(
&self,
other: &GeometryCollection<T>,
epsilon: <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon
) -> bool
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.
pub fn default_epsilon(
) -> <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon
pub fn default_epsilon(
) -> <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
The inverse of AbsDiffEq::abs_diff_eq
.
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
Return the number of coordinates in the GeometryCollection
.
type Iter = Box<dyn Iterator<Item = Coordinate<T>> + 'a>
type ExteriorIter = Box<dyn Iterator<Item = Coordinate<T>> + 'a>
type Scalar = T
Iterate over all exterior and (if any) interior coordinates of a geometry. Read more
Iterate over all exterior coordinates of a geometry. Read more
Returns the “default value” for a type. Read more
Convert any Geometry (or anything that can be converted to a Geometry) into a GeometryCollection
Performs the conversion.
impl<T, IG> FromIterator<IG> for GeometryCollection<T> where
T: CoordNum,
IG: Into<Geometry<T>>,
impl<T, IG> FromIterator<IG> for GeometryCollection<T> where
T: CoordNum,
IG: Into<Geometry<T>>,
Collect Geometries (or what can be converted to a Geometry) into a GeometryCollection
Creates a value from an iterator. Read more
Some geometries, like a MultiPoint
, can have zero coordinates - we call these empty
. Read more
The dimensions of some geometries are fixed, e.g. a Point always has 0 dimensions. However
for others, the dimensionality depends on the specific geometry instance - for example
typical Rect
s are 2-dimensional, but it’s possible to create degenerate Rect
s which
have either 1 or 0 dimensions. Read more
The dimensions of the Geometry
’s boundary, as used by OGC-SFA. Read more
impl<T, G> Intersects<G> for GeometryCollection<T> where
T: CoordNum,
Geometry<T>: Intersects<G>,
impl<T, G> Intersects<G> for GeometryCollection<T> where
T: CoordNum,
Geometry<T>: Intersects<G>,
impl<T> Intersects<GeometryCollection<T>> for Coordinate<T> where
GeometryCollection<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Coordinate<T> where
GeometryCollection<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Line<T> where
GeometryCollection<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Line<T> where
GeometryCollection<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Rect<T> where
GeometryCollection<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Rect<T> where
GeometryCollection<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Polygon<T> where
GeometryCollection<T>: Intersects<Polygon<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Polygon<T> where
GeometryCollection<T>: Intersects<Polygon<T>>,
T: CoordNum,
impl<T> PartialEq<GeometryCollection<T>> for GeometryCollection<T> where
T: PartialEq<T> + CoordNum,
impl<T> PartialEq<GeometryCollection<T>> for GeometryCollection<T> where
T: PartialEq<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<T, Epsilon = T> + CoordNum + RelativeEq<T>,
impl<T> RelativeEq<GeometryCollection<T>> for GeometryCollection<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
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
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
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);
pub fn default_max_relative(
) -> <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon
pub fn default_max_relative(
) -> <GeometryCollection<T> as AbsDiffEq<GeometryCollection<T>>>::Epsilon
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
Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more