rinex/ionex/
grid.rs

1use crate::linspace::Linspace;
2
3#[cfg(feature = "serde")]
4use serde::Serialize;
5
6/// Reference Grid,
7/// defined in terms of Latitude, Longitude and Altitude.
8/// If 2D-TEC maps, static altitude is defined, ie.:
9/// start = end altitude and spacing = 0.
10#[derive(Debug, Clone, Default, PartialEq, PartialOrd)]
11#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12pub struct Grid {
13    /// Latitude
14    pub latitude: Linspace,
15    /// Longitude
16    pub longitude: Linspace,
17    /// Altitude
18    pub height: Linspace,
19}
20
21impl Grid {
22    /// Returns true if self is defined for 3D TEC map
23    pub fn is_3d_grid(&self) -> bool {
24        !self.is_2d_grid()
25    }
26    /// Returns true if self is defined to 2D TEC maps,
27    /// ie.: static altitude ref point with no altitude space
28    /// definition.
29    pub fn is_2d_grid(&self) -> bool {
30        self.height.is_single_point()
31    }
32}
33
34#[cfg(test)]
35mod test {
36    use super::*;
37    #[test]
38    fn test_grid() {
39        let default = Linspace::default();
40        assert_eq!(
41            default,
42            Linspace {
43                start: 0.0,
44                end: 0.0,
45                spacing: 0.0,
46            }
47        );
48        let grid = Linspace::new(1.0, 10.0, 1.0).unwrap();
49        assert_eq!(grid.length(), 10);
50        assert!(!grid.is_single_point());
51    }
52}