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