geo/algorithm/intersects/
collections.rs1use super::{has_disjoint_bboxes, Intersects};
2use crate::geometry::*;
3use crate::geometry_delegate_impl;
4use crate::BoundingRect;
5use crate::CoordNum;
6
7impl<T, G> Intersects<G> for Geometry<T>
8where
9 T: CoordNum,
10 Point<T>: Intersects<G>,
11 MultiPoint<T>: Intersects<G>,
12 Line<T>: Intersects<G>,
13 LineString<T>: Intersects<G>,
14 MultiLineString<T>: Intersects<G>,
15 Triangle<T>: Intersects<G>,
16 Rect<T>: Intersects<G>,
17 Polygon<T>: Intersects<G>,
18 MultiPolygon<T>: Intersects<G>,
19 G: BoundingRect<T>,
20{
21 geometry_delegate_impl! {
22 fn intersects(&self, rhs: &G) -> bool;
23 }
24}
25symmetric_intersects_impl!(Coord<T>, Geometry<T>);
26symmetric_intersects_impl!(Line<T>, Geometry<T>);
27symmetric_intersects_impl!(Rect<T>, Geometry<T>);
28symmetric_intersects_impl!(Polygon<T>, Geometry<T>);
29
30impl<T, G> Intersects<G> for GeometryCollection<T>
31where
32 T: CoordNum,
33 Geometry<T>: Intersects<G>,
34 G: BoundingRect<T>,
35{
36 fn intersects(&self, rhs: &G) -> bool {
37 if has_disjoint_bboxes(self, rhs) {
38 return false;
39 }
40 self.iter().any(|geom| geom.intersects(rhs))
41 }
42}
43symmetric_intersects_impl!(Coord<T>, GeometryCollection<T>);
44symmetric_intersects_impl!(Line<T>, GeometryCollection<T>);
45symmetric_intersects_impl!(Rect<T>, GeometryCollection<T>);
46symmetric_intersects_impl!(Polygon<T>, GeometryCollection<T>);