gnss_qc/
product.rs

1//! Input / Output Products definition
2use crate::error::Error;
3use rinex::prelude::RinexType;
4
5#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub enum ProductType {
7    /// GNSS carrier signal observation in the form
8    /// of Observation RINEX data.
9    Observation,
10    /// Meteo sensors data wrapped as Meteo RINEX files.
11    MeteoObservation,
12    /// DORIS measurements wrapped as special RINEX observation file.
13    DORIS,
14    /// Broadcast Navigation message as contained in
15    /// Navigation RINEX files.
16    BroadcastNavigation,
17    /// High precision orbital attitudes wrapped in Clock RINEX files.
18    HighPrecisionClock,
19    /// Antenna calibration information wrapped in ANTEX special RINEX files.
20    ANTEX,
21    /// Precise Ionosphere state wrapped in IONEX special RINEX files.
22    IONEX,
23    #[cfg(feature = "sp3")]
24    #[cfg_attr(docsrs, doc(cfg(feature = "sp3")))]
25    /// High precision clock data wrapped in SP3 files.
26    HighPrecisionOrbit,
27}
28
29impl std::fmt::Display for ProductType {
30    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
31        match self {
32            Self::ANTEX => write!(f, "ANTEX"),
33            Self::IONEX => write!(f, "IONEX"),
34            Self::DORIS => write!(f, "DORIS RINEX"),
35            Self::Observation => write!(f, "Observation"),
36            Self::MeteoObservation => write!(f, "Meteo"),
37            Self::HighPrecisionClock => write!(f, "High Precision Clock"),
38            Self::BroadcastNavigation => write!(f, "Broadcast Navigation (BRDC)"),
39            #[cfg(feature = "sp3")]
40            Self::HighPrecisionOrbit => write!(f, "High Precision Orbit (SP3)"),
41        }
42    }
43}
44
45impl std::str::FromStr for ProductType {
46    type Err = Error;
47    fn from_str(s: &str) -> Result<Self, Self::Err> {
48        let trimmed = s.trim();
49        let lowered = trimmed.to_lowercase();
50        match lowered.as_str() {
51            "atx" | "antex" => Ok(Self::ANTEX),
52            "ionex" => Ok(Self::IONEX),
53            "doris" => Ok(Self::DORIS),
54            "obs" | "observation" => Ok(Self::Observation),
55            "met" | "meteo" => Ok(Self::MeteoObservation),
56            "nav" | "brdc" | "navigation" => Ok(Self::BroadcastNavigation),
57            "clk" | "clock" => Ok(Self::HighPrecisionClock),
58            #[cfg(feature = "sp3")]
59            "sp3" => Ok(Self::HighPrecisionOrbit),
60            _ => Err(Error::UnknownProductType),
61        }
62    }
63}
64
65impl From<RinexType> for ProductType {
66    fn from(rt: RinexType) -> Self {
67        match rt {
68            RinexType::ObservationData => Self::Observation,
69            RinexType::NavigationData => Self::BroadcastNavigation,
70            RinexType::MeteoData => Self::MeteoObservation,
71            RinexType::ClockData => Self::HighPrecisionClock,
72            RinexType::IonosphereMaps => Self::IONEX,
73            RinexType::AntennaData => Self::ANTEX,
74            RinexType::DORIS => Self::DORIS,
75        }
76    }
77}