Skip to content

Commit

Permalink
Fix geo-types empty Polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Oct 14, 2024
1 parent 9421e05 commit 9552705
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions geo-traits/src/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ impl<T: CoordNum> PolygonTrait for Polygon<T> {
}

fn exterior(&self) -> Option<Self::RingType<'_>> {
// geo-types doesn't really have a way to describe an empty polygon
Some(Polygon::exterior(self))
let ext_ring = Polygon::exterior(self);
if ext_ring.num_points() == 0 {
None
} else {
Some(ext_ring)
}
}

fn num_interiors(&self) -> usize {
Expand All @@ -84,8 +88,12 @@ impl<'a, T: CoordNum> PolygonTrait for &'a Polygon<T> {
}

fn exterior(&self) -> Option<Self::RingType<'_>> {
// geo-types doesn't really have a way to describe an empty polygon
Some(Polygon::exterior(self))
let ext_ring = Polygon::exterior(self);
if ext_ring.num_points() == 0 {
None
} else {
Some(ext_ring)
}
}

fn num_interiors(&self) -> usize {
Expand Down

0 comments on commit 9552705

Please sign in to comment.