Skip to content

Commit

Permalink
fix remaining centroid behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed Feb 20, 2021
1 parent 14e7ae8 commit 7a9ca9f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion geo/src/algorithm/dimensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,19 @@ impl<C: CoordNum> HasDimensions for Polygon<C> {
}

fn dimensions(&self) -> Dimensions {
Dimensions::TwoDimensional
use crate::algorithm::coords_iter::CoordsIter;
let mut coords = self.exterior_coords_iter();
match coords.next() {
None => Dimensions::Empty,
Some(coord_0) => {
if coords.all(|coord_n| coord_0 == coord_n) {
// all coords are a single point
Dimensions::ZeroDimensional
} else {
Dimensions::TwoDimensional
}
}
}
}

fn boundary_dimensions(&self) -> Dimensions {
Expand Down

0 comments on commit 7a9ca9f

Please sign in to comment.