geo/algorithm/covers/
geometry_collection.rs1use super::{Covers, impl_covers_from_relate, impl_covers_geometry_for};
2use crate::covers::impl_covers_from_intersects;
3use crate::geometry::*;
4use crate::{GeoFloat, GeoNum};
5
6impl_covers_from_intersects!(GeometryCollection<T>,[Point<T>,MultiPoint<T>]);
7impl_covers_from_relate!(GeometryCollection<T>, [
8Line<T>,
9LineString<T>, MultiLineString<T>,
10Rect<T>, Triangle<T>,
11Polygon<T>, MultiPolygon<T>,
12GeometryCollection<T>
13]);
14impl_covers_geometry_for!(GeometryCollection<T>);
15
16#[cfg(test)]
17mod tests {
18 use super::*;
19 use crate::algorithm::convert::Convert;
20 use crate::wkt;
21
22 #[test]
23 fn test_rhs_empty() {
24 let s: GeometryCollection<f64> = wkt!(GEOMETRYCOLLECTION(POINT(0 0))).convert();
25 assert!(!s.covers(&LineString::empty()));
26 assert!(!s.covers(&Polygon::empty()));
27 assert!(!s.covers(&MultiPoint::empty()));
28 assert!(!s.covers(&MultiLineString::empty()));
29 assert!(!s.covers(&MultiPolygon::empty()));
30 assert!(!s.covers(&GeometryCollection::empty()));
31 }
32
33 #[test]
34 fn test_lhs_empty() {
35 let s: GeometryCollection<f64> = GeometryCollection::empty();
36
37 assert!(!s.covers(&wkt!(POINT(0 0)).convert()));
38 assert!(!s.covers(&wkt!(MULTIPOINT(0 0,1 1)).convert()));
39
40 assert!(!s.covers(&wkt!(LINE(0 0,1 1)).convert()));
41 assert!(!s.covers(&wkt!(LINESTRING(0 0,1 1)).convert()));
42 assert!(!s.covers(&wkt!(MULTILINESTRING((0 0,1 1),(2 2,3 3))).convert()));
43
44 assert!(!s.covers(&wkt!(POLYGON((0 0,1 1,1 0,0 0))).convert()));
45 assert!(!s.covers(&wkt!(MULTIPOLYGON(((0 0,1 0, 1 1,0 1, 0 0)))).convert()));
46 assert!(!s.covers(&wkt!(RECT(0 0, 1 1)).convert()));
47 assert!(!s.covers(&wkt!(TRIANGLE(0 0, 0 1, 1 1)).convert()));
48
49 assert!(!s.covers(&Into::<Geometry>::into(wkt!(POINT(0 0)).convert())));
50 assert!(!s.covers(&wkt!(GEOMETRYCOLLECTION(POINT(0 0))).convert()));
51 }
52}