1mod coordinate;
2pub use coordinate::Coordinate;
3
4mod level;
5pub use level::{First, Fourth, Level, Second, Third};
6
7mod spot;
8pub use spot::Spot;
9
10use std::marker::PhantomData;
11
12#[derive(Clone, Debug)]
13pub struct GridCell<A: Level> {
14 pub code: u64,
15 pub west_longitude: f64,
16 pub south_latitude: f64,
17 phantom: PhantomData<A>,
18}
19
20#[cfg(test)]
21mod tests {
22 use crate::{Coordinate, Spot};
23
24 #[test]
25 fn first_cell() {
26 let actual = new_spot1().as_first_cell().code;
27 let expected = 5339;
28 assert_eq!(actual, expected);
29 }
30
31 #[test]
32 fn second_cell() {
33 let actual = new_spot1().as_second_cell().code;
34 let expected = 533945;
35 assert_eq!(actual, expected);
36 }
37
38 #[test]
39 fn third_cell() {
40 let actual = new_spot1().as_third_cell().code;
41 let expected = 53394518;
42 assert_eq!(actual, expected);
43 }
44
45 #[test]
46 fn fourth_cell() {
47 let actual = new_spot1().as_fourth_cell().code;
48 let expected = 533945184;
49 assert_eq!(actual, expected);
50 }
51
52 fn new_spot1() -> Spot {
53 Spot::new(Coordinate {
54 longitude: 139.733231,
55 latitude: 35.680916,
56 })
57 }
58}