1use crate::error::Error;
3use rinex::prelude::RinexType;
4
5#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub enum ProductType {
7 Observation,
10 MeteoObservation,
12 DORIS,
14 BroadcastNavigation,
17 HighPrecisionClock,
19 ANTEX,
21 IONEX,
23 #[cfg(feature = "sp3")]
24 #[cfg_attr(docsrs, doc(cfg(feature = "sp3")))]
25 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}