• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geo-engine / geoengine / 3929938005

pending completion
3929938005

push

github

GitHub
Merge #713

84930 of 96741 relevant lines covered (87.79%)

79640.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.28
/operators/src/processing/point_in_polygon/wrapper.rs
1
use geoengine_datatypes::collections::MultiPolygonCollection;
2
use ouroboros::self_referencing;
3

4
use super::PointInPolygonTester;
5

6
/// A wrapper to allow storing a [`MultiPolygonCollection`] together with a [`PointInPolygonTester`].
7
#[self_referencing]
×
8
struct PipWrapperInternal {
9
    collection: MultiPolygonCollection,
10
    #[borrows(collection)]
11
    #[covariant]
12
    tester: PointInPolygonTester<'this>,
13
}
14

15
/// A wrapper to allow storing a [`MultiPolygonCollection`] together with a [`PointInPolygonTester`].
16
pub struct PointInPolygonTesterWithCollection(PipWrapperInternal);
17

18
impl PointInPolygonTesterWithCollection {
19
    pub fn new(collection: MultiPolygonCollection) -> Self {
4✔
20
        Self(
4✔
21
            PipWrapperInternalBuilder {
4✔
22
                collection,
4✔
23
                tester_builder: |collection| PointInPolygonTester::new(collection),
4✔
24
            }
4✔
25
            .build(),
4✔
26
        )
4✔
27
    }
4✔
28

29
    pub fn collection(&self) -> &MultiPolygonCollection {
6✔
30
        self.0.borrow_collection()
6✔
31
    }
6✔
32

33
    pub fn tester(&self) -> &PointInPolygonTester<'_> {
9✔
34
        self.0.borrow_tester()
9✔
35
    }
9✔
36
}
37

38
impl From<PointInPolygonTesterWithCollection> for MultiPolygonCollection {
39
    fn from(value: PointInPolygonTesterWithCollection) -> Self {
2✔
40
        value.0.into_heads().collection
2✔
41
    }
2✔
42
}
43

44
#[cfg(test)]
45
mod tests {
46
    use std::collections::HashMap;
47

48
    use geoengine_datatypes::{
49
        collections::FeatureCollectionInfos,
50
        primitives::{MultiPolygon, TimeInterval},
51
    };
52

53
    use super::*;
54

55
    #[test]
1✔
56
    fn test() {
1✔
57
        let collection = MultiPolygonCollection::from_data(
1✔
58
            vec![
1✔
59
                MultiPolygon::new(vec![vec![
1✔
60
                    vec![
1✔
61
                        (0.0, 0.1).into(),
1✔
62
                        (10.0, 10.1).into(),
1✔
63
                        (0.0, 10.1).into(),
1✔
64
                        (0.0, 0.1).into(),
1✔
65
                    ],
1✔
66
                    vec![
1✔
67
                        (2.0, 2.1).into(),
1✔
68
                        (3.0, 3.1).into(),
1✔
69
                        (2.0, 3.1).into(),
1✔
70
                        (2.0, 2.1).into(),
1✔
71
                    ],
1✔
72
                ]])
1✔
73
                .unwrap(),
1✔
74
                MultiPolygon::new(vec![vec![vec![
1✔
75
                    (5.0, 5.1).into(),
1✔
76
                    (6.0, 6.1).into(),
1✔
77
                    (5.0, 6.1).into(),
1✔
78
                    (5.0, 5.1).into(),
1✔
79
                ]]])
1✔
80
                .unwrap(),
1✔
81
            ],
1✔
82
            vec![Default::default(); 2],
1✔
83
            HashMap::new(),
1✔
84
        )
1✔
85
        .unwrap();
1✔
86

1✔
87
        let wrapper = PointInPolygonTesterWithCollection::new(collection);
1✔
88

1✔
89
        assert!(wrapper
1✔
90
            .tester()
1✔
91
            .any_polygon_contains_coordinate(&(5.0, 5.1).into(), &TimeInterval::default()));
1✔
92

93
        assert_eq!(wrapper.collection().len(), 2);
1✔
94
    }
1✔
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc