Skip to content

Commit

Permalink
GeometryCollection gets ::empty constructor and things to see how man…
Browse files Browse the repository at this point in the history
…y geometries it contains
  • Loading branch information
Rory McCann committed Feb 13, 2019
1 parent 96c7846 commit c9b9237
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions geo-types/src/geometry_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ pub struct GeometryCollection<T>(pub Vec<Geometry<T>>)
where
T: CoordinateType;

impl<T: CoordinateType> GeometryCollection<T> {
/// Return an empty GeometryCollection
pub fn empty() -> GeometryCollection<T> {
GeometryCollection(Vec::new())
}

/// Number of geometries in this GeometryCollection
pub fn len(&self) -> usize {
self.0.len()
}

/// Is this GeometryCollection empty
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}


impl<T: CoordinateType, IG: Into<Geometry<T>>> From<IG> for GeometryCollection<T> {
fn from(x: IG) -> Self {
GeometryCollection(vec![x.into()])
Expand Down

0 comments on commit c9b9237

Please sign in to comment.