geo/algorithm/contains/
geometry.rs1use super::Contains;
2use crate::geometry::*;
3use crate::geometry_delegate_impl;
4use crate::{GeoFloat, GeoNum};
5
6impl<T> Contains<Coord<T>> for Geometry<T>
7where
8 T: GeoNum,
9{
10 fn contains(&self, coord: &Coord<T>) -> bool {
11 self.contains(&Point::from(*coord))
12 }
13}
14
15impl<T> Contains<Point<T>> for Geometry<T>
16where
17 T: GeoNum,
18{
19 geometry_delegate_impl! {
20 fn contains(&self, point: &Point<T>) -> bool;
21 }
22}
23
24impl<T> Contains<Line<T>> for Geometry<T>
25where
26 T: GeoFloat,
27{
28 geometry_delegate_impl! {
29 fn contains(&self, line: &Line<T>) -> bool;
30 }
31}
32
33impl<T> Contains<LineString<T>> for Geometry<T>
34where
35 T: GeoFloat,
36{
37 geometry_delegate_impl! {
38 fn contains(&self, line_string: &LineString<T>) -> bool;
39 }
40}
41
42impl<T> Contains<Polygon<T>> for Geometry<T>
43where
44 T: GeoFloat,
45{
46 geometry_delegate_impl! {
47 fn contains(&self, polygon: &Polygon<T>) -> bool;
48 }
49}
50
51impl<T> Contains<MultiPoint<T>> for Geometry<T>
52where
53 T: GeoFloat,
54{
55 geometry_delegate_impl! {
56 fn contains(&self, multi_point: &MultiPoint<T>) -> bool;
57 }
58}
59
60impl<T> Contains<MultiLineString<T>> for Geometry<T>
61where
62 T: GeoFloat,
63{
64 geometry_delegate_impl! {
65 fn contains(&self, multi_line_string: &MultiLineString<T>) -> bool;
66 }
67}
68
69impl<T> Contains<MultiPolygon<T>> for Geometry<T>
70where
71 T: GeoFloat,
72{
73 geometry_delegate_impl! {
74 fn contains(&self, multi_line_string: &MultiPolygon<T>) -> bool;
75 }
76}
77
78impl<T> Contains<GeometryCollection<T>> for Geometry<T>
79where
80 T: GeoFloat,
81{
82 geometry_delegate_impl! {
83 fn contains(&self, geometry_collection: &GeometryCollection<T>) -> bool;
84 }
85}
86
87impl<T> Contains<Rect<T>> for Geometry<T>
88where
89 T: GeoFloat,
90{
91 geometry_delegate_impl! {
92 fn contains(&self, rect: &Rect<T>) -> bool;
93 }
94}
95
96impl<T> Contains<Triangle<T>> for Geometry<T>
97where
98 T: GeoFloat,
99{
100 geometry_delegate_impl! {
101 fn contains(&self, triangle: &Triangle<T>) -> bool;
102 }
103}
104
105impl<T> Contains<Geometry<T>> for Geometry<T>
106where
107 T: GeoFloat,
108{
109 fn contains(&self, other: &Geometry<T>) -> bool {
110 match other {
111 Geometry::Point(geom) => self.contains(geom),
112 Geometry::Line(geom) => self.contains(geom),
113 Geometry::LineString(geom) => self.contains(geom),
114 Geometry::Polygon(geom) => self.contains(geom),
115 Geometry::MultiPoint(geom) => self.contains(geom),
116 Geometry::MultiLineString(geom) => self.contains(geom),
117 Geometry::MultiPolygon(geom) => self.contains(geom),
118 Geometry::GeometryCollection(geom) => self.contains(geom),
119 Geometry::Rect(geom) => self.contains(geom),
120 Geometry::Triangle(geom) => self.contains(geom),
121 }
122 }
123}