Skip to content

Commit

Permalink
Merge #827
Browse files Browse the repository at this point in the history
827: rstar::object for geo_types::Polygon r=rmanoka,lnicola a=michaelkirk

- [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/main/CODE_OF_CONDUCT.md).
- [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users.
---
superesedes #351

Introduced an rstar::Object implementation for Polygon. This was originally proposed in #351,  but that PR has since grown stale because we now support two versions of rstar.

based on #351, this PR:
- merges in main
- update polygon impl to work with the multiple versions of rstar we now support


Co-authored-by: Stephan Hügel <[email protected]>
Co-authored-by: Michael Kirk <[email protected]>
  • Loading branch information
3 people authored May 10, 2022
2 parents 6fbde25 + 5947bbb commit 9653e4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions geo-types/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Add `split_x` and `split_y` methods on `Rect`
* <https://github.com/georust/geo/pull/823>
* Add support for `Polygon` in `RTree`
* <https://github.com/georust/geo/pull/351>

## 0.7.4

Expand Down
22 changes: 22 additions & 0 deletions geo-types/src/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,25 @@ impl<T: AbsDiffEq<Epsilon = T> + CoordNum> AbsDiffEq for Polygon<T> {
zipper.all(|(lhs, rhs)| lhs.abs_diff_eq(rhs, epsilon))
}
}

#[cfg(any(feature = "rstar_0_8", feature = "rstar_0_9"))]
macro_rules! impl_rstar_polygon {
($rstar:ident) => {
impl<T> $rstar::RTreeObject for Polygon<T>
where
T: ::num_traits::Float + ::$rstar::RTreeNum,
{
type Envelope = ::$rstar::AABB<Point<T>>;

fn envelope(&self) -> Self::Envelope {
self.exterior.envelope()
}
}
};
}

#[cfg(feature = "rstar_0_8")]
impl_rstar_polygon!(rstar_0_8);

#[cfg(feature = "rstar_0_9")]
impl_rstar_polygon!(rstar_0_9);

0 comments on commit 9653e4f

Please sign in to comment.