-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
516: Round up Intersects implementations r=rmanoka a=rmanoka This PR completes the `Intersects` implementation for all pairs of current geo-types (discounting possible bugs)! + Add OGC-SA descriptions to geo-types docs + Verify existing implementations + Add implementations for containers: `Geometry`, `GeometryCollection` See [here](//georust.github.io/geo/support/intersects.html) for table describing the implementation status / map. Interestingly, we didn't need geom-graph for this trait (presumably because this trait doesn't distinguish between interior and boundary). I also removed any usage of `Contains` trait in this trait for easier verification of correctness. Co-authored-by: Rajsekar Manokaran <[email protected]> Co-authored-by: rmanoka <[email protected]>
- Loading branch information
Showing
20 changed files
with
318 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use super::Intersects; | ||
use crate::*; | ||
|
||
impl<T, G> Intersects<G> for Geometry<T> | ||
where | ||
T: CoordinateType, | ||
Point<T>: Intersects<G>, | ||
MultiPoint<T>: Intersects<G>, | ||
Line<T>: Intersects<G>, | ||
LineString<T>: Intersects<G>, | ||
MultiLineString<T>: Intersects<G>, | ||
Triangle<T>: Intersects<G>, | ||
Rect<T>: Intersects<G>, | ||
Polygon<T>: Intersects<G>, | ||
MultiPolygon<T>: Intersects<G>, | ||
{ | ||
fn intersects(&self, rhs: &G) -> bool { | ||
match self { | ||
Geometry::Point(geom) => geom.intersects(rhs), | ||
Geometry::MultiPoint(geom) => geom.intersects(rhs), | ||
Geometry::Line(geom) => geom.intersects(rhs), | ||
Geometry::LineString(geom) => geom.intersects(rhs), | ||
Geometry::MultiLineString(geom) => geom.intersects(rhs), | ||
Geometry::Triangle(geom) => geom.intersects(rhs), | ||
Geometry::Rect(geom) => geom.intersects(rhs), | ||
Geometry::Polygon(geom) => geom.intersects(rhs), | ||
Geometry::MultiPolygon(geom) => geom.intersects(rhs), | ||
Geometry::GeometryCollection(geom) => geom.intersects(rhs), | ||
} | ||
} | ||
} | ||
symmetric_intersects_impl!(Coordinate<T>, Geometry<T>); | ||
symmetric_intersects_impl!(Line<T>, Geometry<T>); | ||
symmetric_intersects_impl!(Rect<T>, Geometry<T>); | ||
symmetric_intersects_impl!(Polygon<T>, Geometry<T>); | ||
|
||
impl<T, G> Intersects<G> for GeometryCollection<T> | ||
where | ||
T: CoordinateType, | ||
Geometry<T>: Intersects<G>, | ||
{ | ||
fn intersects(&self, rhs: &G) -> bool { | ||
self.0.iter().any(|geom| geom.intersects(rhs)) | ||
} | ||
} | ||
symmetric_intersects_impl!(Coordinate<T>, GeometryCollection<T>); | ||
symmetric_intersects_impl!(Line<T>, GeometryCollection<T>); | ||
symmetric_intersects_impl!(Rect<T>, GeometryCollection<T>); | ||
symmetric_intersects_impl!(Polygon<T>, GeometryCollection<T>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.