diff --git a/geo-types/src/geometry/multi_point.rs b/geo-types/src/geometry/multi_point.rs index 1391da78e..ff3c16c6f 100644 --- a/geo-types/src/geometry/multi_point.rs +++ b/geo-types/src/geometry/multi_point.rs @@ -35,16 +35,16 @@ use core::iter::FromIterator; pub struct MultiPoint(pub Vec>); impl>> From for MultiPoint { - /// Convert a single `Point` (or something which can be converted to a `Point`) into a - /// one-member `MultiPoint` + /// Convert a single `Point` (or something which can be converted to a + /// `Point`) into a one-member `MultiPoint` fn from(x: IP) -> Self { Self(vec![x.into()]) } } impl>> From> for MultiPoint { - /// Convert a `Vec` of `Points` (or `Vec` of things which can be converted to a `Point`) into a - /// `MultiPoint`. + /// Convert a `Vec` of `Points` (or `Vec` of things which can be converted + /// to a `Point`) into a `MultiPoint`. fn from(v: Vec) -> Self { Self(v.into_iter().map(|p| p.into()).collect()) } @@ -90,6 +90,14 @@ impl MultiPoint { Self(value) } + pub fn len(&self) -> usize { + self.0.len() + } + + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } + pub fn iter(&self) -> impl Iterator> { self.0.iter() } diff --git a/geo/CHANGES.md b/geo/CHANGES.md index ab0e24660..05f7acdd4 100644 --- a/geo/CHANGES.md +++ b/geo/CHANGES.md @@ -27,9 +27,11 @@ * Fix coordinate wrapping in `HaversineDestination` * * Add `wkt!` macro to define geometries at compile time. - + * * Add `TriangulateSpade` trait which provides (un)constrained Delaunay Triangulations for all `geo_types` via the `spade` crate * +* Add `len()` and `is_empty()` to `MultiPoint` + * ## 0.26.0