Skip to content

Commit f9024a1

Browse files
authored
Merge pull request #12 from rtk-rs/update
Update
2 parents 2f71534 + ea12f86 commit f9024a1

File tree

6 files changed

+130
-78
lines changed

6 files changed

+130
-78
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ serde = { version = "1.0", default-features = false, features = ["derive"] }
3939

4040
hifitime = "4.0"
4141
anise = { version = "0.5.3", features = ["embed_ephem"] }
42-
gnss-rs = { version = "2.3.3", features = ["serde"] }
43-
gnss-qc-traits = { version = "0.1.0", features = ["processing"] }
42+
43+
gnss-rs = { version = "2.3.5", features = ["serde"] }
44+
gnss-qc-traits = { git = "https://github.com/rtk-rs/qc-traits", features = ["processing"] }
4445

4546
maud = "0.26"
4647
plotly = "0.12"

src/context.rs

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
//! GNSS processing context definition.
2-
use thiserror::Error;
3-
42
use std::{
53
collections::HashMap,
64
ffi::OsStr,
@@ -33,76 +31,7 @@ use sp3::prelude::SP3;
3331

3432
use qc_traits::{Filter, Preprocessing, Repair, RepairTrait};
3533

36-
/// Context Error
37-
#[derive(Debug, Error)]
38-
pub enum Error {
39-
#[error("almanac error: {0}")]
40-
Almanac(#[from] AlmanacError),
41-
#[error("meta error: {0}")]
42-
MetaAlmanac(#[from] MetaAlmanacError),
43-
#[error("planetary data error")]
44-
PlanetaryData(#[from] PlanetaryDataError),
45-
#[error("non supported file format")]
46-
NonSupportedFileFormat,
47-
#[error("failed to determine filename")]
48-
FileNameDetermination,
49-
#[error("failed to extend context")]
50-
Merge(#[from] MergeError),
51-
}
52-
53-
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
54-
pub enum ProductType {
55-
/// GNSS carrier signal observation in the form
56-
/// of Observation RINEX data.
57-
Observation,
58-
/// Meteo sensors data wrapped as Meteo RINEX files.
59-
MeteoObservation,
60-
/// DORIS measurements wrapped as special RINEX observation file.
61-
DORIS,
62-
/// Broadcast Navigation message as contained in
63-
/// Navigation RINEX files.
64-
BroadcastNavigation,
65-
/// High precision orbital attitudes wrapped in Clock RINEX files.
66-
HighPrecisionClock,
67-
/// Antenna calibration information wrapped in ANTEX special RINEX files.
68-
ANTEX,
69-
/// Precise Ionosphere state wrapped in IONEX special RINEX files.
70-
IONEX,
71-
#[cfg(feature = "sp3")]
72-
#[cfg_attr(docsrs, doc(cfg(feature = "sp3")))]
73-
/// High precision clock data wrapped in SP3 files.
74-
HighPrecisionOrbit,
75-
}
76-
77-
impl std::fmt::Display for ProductType {
78-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
79-
match self {
80-
Self::ANTEX => write!(f, "ANTEX"),
81-
Self::IONEX => write!(f, "IONEX"),
82-
Self::DORIS => write!(f, "DORIS RINEX"),
83-
Self::Observation => write!(f, "Observation"),
84-
Self::MeteoObservation => write!(f, "Meteo"),
85-
Self::HighPrecisionClock => write!(f, "High Precision Clock"),
86-
Self::BroadcastNavigation => write!(f, "Broadcast Navigation (BRDC)"),
87-
#[cfg(feature = "sp3")]
88-
Self::HighPrecisionOrbit => write!(f, "High Precision Orbit (SP3)"),
89-
}
90-
}
91-
}
92-
93-
impl From<RinexType> for ProductType {
94-
fn from(rt: RinexType) -> Self {
95-
match rt {
96-
RinexType::ObservationData => Self::Observation,
97-
RinexType::NavigationData => Self::BroadcastNavigation,
98-
RinexType::MeteoData => Self::MeteoObservation,
99-
RinexType::ClockData => Self::HighPrecisionClock,
100-
RinexType::IonosphereMaps => Self::IONEX,
101-
RinexType::AntennaData => Self::ANTEX,
102-
RinexType::DORIS => Self::DORIS,
103-
}
104-
}
105-
}
34+
use crate::{error::Error, prelude::ProductType};
10635

10736
enum BlobData {
10837
/// RINEX content

src/error.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//! Error types definition
2+
use thiserror::Error;
3+
4+
use qc_traits::MergeError;
5+
6+
use anise::{
7+
almanac::{metaload::MetaAlmanac, metaload::MetaAlmanacError, planetary::PlanetaryDataError},
8+
errors::AlmanacError,
9+
};
10+
11+
/// Context Error
12+
#[derive(Debug, Error)]
13+
pub enum Error {
14+
#[error("almanac error: {0}")]
15+
Almanac(#[from] AlmanacError),
16+
#[error("meta error: {0}")]
17+
MetaAlmanac(#[from] MetaAlmanacError),
18+
#[error("planetary data error")]
19+
PlanetaryData(#[from] PlanetaryDataError),
20+
#[error("non supported file format")]
21+
NonSupportedFileFormat,
22+
#[error("failed to determine filename")]
23+
FileNameDetermination,
24+
#[error("failed to extend context")]
25+
Merge(#[from] MergeError),
26+
#[error("unknown / non supported product type")]
27+
UnknownProductType,
28+
}

src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ extern crate gnss_qc_traits as qc_traits;
99
extern crate gnss_rs as gnss;
1010

1111
mod cfg;
12-
13-
pub mod plot;
14-
1512
mod context;
13+
mod product;
1614
mod report;
1715

16+
pub mod error;
17+
pub mod plot;
18+
1819
pub mod prelude {
1920
pub use crate::{
2021
cfg::{QcConfig, QcReportType},
21-
context::{ProductType, QcContext},
22+
context::QcContext,
23+
error::Error,
24+
product::ProductType,
2225
report::{QcExtraPage, QcReport},
2326
};
2427
// Pub re-export

src/product.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
}

src/scope.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use crate::prelude::ProductType;
2+
3+
#[derive(Debug, Clone, PartialEq)]
4+
pub enum QcScope {
5+
/// Scope by [ProductType] (file type)
6+
ProductType(ProductType),
7+
/// Scope by file name
8+
FileName(String),
9+
/// Scope by Agency
10+
Agency(String),
11+
/// Scope by Operator / Observer
12+
Operator(String),
13+
}

0 commit comments

Comments
 (0)