Skip to content

Commit bddaef4

Browse files
authored
Merge pull request #10 from rtk-rs/rinex-upgrade
Rinex lib upgrade
2 parents 04a202a + 15811d0 commit bddaef4

File tree

14 files changed

+316
-373
lines changed

14 files changed

+316
-373
lines changed

Cargo.toml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ categories = ["science", "science::geo"]
1111
edition = "2021"
1212

1313
[features]
14-
default = [] # no features by default
14+
default = ["sp3"] # no features by default
1515

1616
# Unlock support of high precision SP3 files.
1717
# When targetting highest precision analysis and solutions, like in PPP,
@@ -37,26 +37,17 @@ strum_macros = "0.26"
3737
itertools = "0.14.0"
3838
serde = { version = "1.0", default-features = false, features = ["derive"] }
3939

40-
map_3d = "0.1.5"
41-
4240
hifitime = "4.0"
4341
anise = { version = "0.5.3", features = ["embed_ephem"] }
44-
gnss-rs = { version = "2.3.1", features = ["serde"] }
45-
46-
gnss-qc-traits = { version = "0.0.2", features = ["processing"] }
47-
# gnss-qc-traits = { path = "../traits", version = "=0.0.1", features = ["processing"] }
42+
gnss-rs = { version = "2.3.3", features = ["serde"] }
43+
gnss-qc-traits = { version = "0.1.0", features = ["processing"] }
4844

4945
maud = "0.26"
50-
5146
plotly = "0.12"
52-
# plotly = { path = "../../plotly-rs/plotly" }
53-
# plotly = { git = "https://github.com/gwbres/plotly", branch = "scattergeo"}
5447

55-
# RINEX lib
56-
rinex = { version = "=0.17.0-alpha-3", features = ["full"] }
48+
rinex = { git = "https://github.com/georust/rinex", branch = "main", features = ["qc", "processing", "obs", "clock", "nav", "ionex", "serde"] }
5749

58-
# SP3 lib
59-
sp3 = { version = "=1.1.0-alpha-2", features = ["qc", "processing", "serde"], optional = true }
50+
sp3 = { git = "https://github.com/georust/rinex", branch = "main", features = ["qc", "processing", "anise", "serde"], optional = true }
6051

6152
[dev-dependencies]
6253
serde_json = "1"

src/cfg.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use maud::{html, Markup, Render};
2-
use rinex::prelude::*;
32
use thiserror::Error;
43

54
use serde::{Deserialize, Serialize};
65

6+
use rinex::prelude::nav::Orbit;
7+
78
/// Configuration Error
89
#[derive(Debug, Clone, Error)]
910
pub enum Error {
@@ -53,7 +54,7 @@ pub struct QcConfig {
5354
#[serde(default)]
5455
pub report: QcReportType,
5556
#[serde(default)]
56-
pub manual_reference: Option<GroundPosition>,
57+
pub manual_rx_orbit: Option<Orbit>,
5758
#[serde(default)]
5859
/// When both SP3 and BRDC NAV are present,
5960
/// SP3 is prefered for skyplot project: set true here to
@@ -65,8 +66,8 @@ impl QcConfig {
6566
pub fn set_report_type(&mut self, report_type: QcReportType) {
6667
self.report = report_type;
6768
}
68-
pub fn set_reference_position(&mut self, pos: GroundPosition) {
69-
self.manual_reference = Some(pos.clone());
69+
pub fn set_reference_rx_orbit(&mut self, orbit: Orbit) {
70+
self.manual_rx_orbit = Some(orbit);
7071
}
7172
}
7273

@@ -81,10 +82,10 @@ impl Render for QcConfig {
8182
(self.report.to_string())
8283
}
8384
}
84-
@if let Some(position) = self.manual_reference {
85+
@if let Some(_) = self.manual_rx_orbit {
8586
tr {
8687
td {
87-
(position.render())
88+
"TODO"
8889
}
8990
}
9091
}

src/context.rs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ use std::{
1010
path::{Path, PathBuf},
1111
};
1212

13-
use rinex::{
14-
prelude::{Almanac, GroundPosition, Rinex, TimeScale},
15-
types::Type as RinexType,
16-
Error as RinexError,
13+
use rinex::prelude::{
14+
nav::{Almanac, Orbit},
15+
Rinex, RinexType, TimeScale,
1716
};
1817

18+
use qc_traits::{Merge, MergeError};
19+
1920
use anise::{
2021
almanac::{
2122
metaload::MetaAlmanacError,
@@ -30,7 +31,7 @@ use anise::{
3031
#[cfg(feature = "sp3")]
3132
use sp3::prelude::SP3;
3233

33-
use qc_traits::{Filter, Merge, MergeError, Preprocessing, Repair, RepairTrait};
34+
use qc_traits::{Filter, Preprocessing, Repair, RepairTrait};
3435

3536
/// Context Error
3637
#[derive(Debug, Error)]
@@ -41,14 +42,12 @@ pub enum Error {
4142
MetaAlmanac(#[from] MetaAlmanacError),
4243
#[error("planetary data error")]
4344
PlanetaryData(#[from] PlanetaryDataError),
44-
#[error("failed to extend gnss context")]
45-
ContextExtensionError(#[from] MergeError),
4645
#[error("non supported file format")]
4746
NonSupportedFileFormat,
4847
#[error("failed to determine filename")]
4948
FileNameDetermination,
50-
#[error("invalid rinex: {0}")]
51-
RinexError(#[from] RinexError),
49+
#[error("failed to extend context")]
50+
Merge(#[from] MergeError),
5251
}
5352

5453
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -379,7 +378,7 @@ impl QcContext {
379378
pub fn timescale(&self) -> Option<TimeScale> {
380379
#[cfg(feature = "sp3")]
381380
if let Some(sp3) = self.sp3() {
382-
return Some(sp3.time_scale);
381+
return Some(sp3.header.timescale);
383382
}
384383

385384
if let Some(obs) = self.observation() {
@@ -601,7 +600,7 @@ impl QcContext {
601600
/// Returns true if High Precision Orbits also contains temporal information.
602601
pub fn sp3_has_clock(&self) -> bool {
603602
if let Some(sp3) = self.sp3() {
604-
sp3.sv_clock().count() > 0
603+
sp3.has_satellite_clock_offset()
605604
} else {
606605
false
607606
}
@@ -667,16 +666,18 @@ impl QcContext {
667666
pub fn nav_compatible(&self) -> bool {
668667
self.observation().is_some() && self.brdc_navigation().is_some()
669668
}
669+
670670
/// True if Self is compatible with CPP positioning,
671671
/// see <https://docs.rs/gnss-rtk/latest/gnss_rtk/prelude/enum.Method.html#variant.CodePPP>
672672
pub fn cpp_compatible(&self) -> bool {
673673
// TODO: improve: only PR
674674
if let Some(obs) = self.observation() {
675-
obs.carrier().count() > 1
675+
obs.carrier_iter().count() > 1
676676
} else {
677677
false
678678
}
679679
}
680+
680681
/// [Self] cannot be True if self is compatible with PPP positioning,
681682
/// see <https://docs.rs/gnss-rtk/latest/gnss_rtk/prelude/enum.Method.html#variant.PPP>
682683
pub fn ppp_compatible(&self) -> bool {
@@ -705,21 +706,15 @@ impl QcContext {
705706
pub fn tropo_bias_model_optimization(&self) -> bool {
706707
self.has_meteo()
707708
}
709+
708710
/// Returns possible Reference position defined in this context.
709711
/// Usually the Receiver location in the laboratory.
710-
pub fn reference_position(&self) -> Option<GroundPosition> {
711-
if let Some(data) = self.observation() {
712-
if let Some(pos) = data.header.ground_position {
713-
return Some(pos);
714-
}
715-
}
716-
if let Some(data) = self.brdc_navigation() {
717-
if let Some(pos) = data.header.ground_position {
718-
return Some(pos);
719-
}
720-
}
721-
None
712+
pub fn reference_rx_orbit(&self) -> Option<Orbit> {
713+
let obs_rinex = self.observation()?;
714+
let first_epoch = obs_rinex.first_epoch()?;
715+
obs_rinex.header.rx_orbit(first_epoch, self.earth_cef)
722716
}
717+
723718
/// Apply preprocessing filter algorithm to mutable [Self].
724719
/// Filter will apply to all data contained in the context.
725720
pub fn filter_mut(&mut self, filter: &Filter) {

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pub mod prelude {
2525
pub use crate::plot::{Marker, MarkerSymbol, Mode, Plot};
2626
pub use maud::{html, Markup, Render};
2727
pub use qc_traits::{Filter, Preprocessing, Repair, RepairTrait};
28-
pub use rinex::prelude::{Almanac, Error as RinexError, Rinex};
28+
pub use rinex::prelude::nav::Almanac;
29+
pub use rinex::prelude::{Error as RinexError, Rinex};
2930
#[cfg(feature = "sp3")]
3031
pub use sp3::prelude::{Error as SP3Error, SP3};
3132
pub use std::path::Path;

src/report/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ pub struct QcReport {
161161
impl QcReport {
162162
/// Builds a new GNSS report, ready to be rendered
163163
pub fn new(context: &QcContext, cfg: QcConfig) -> Self {
164-
let ref_position = if let Some(position) = cfg.manual_reference {
164+
let ref_position = if let Some(position) = cfg.manual_rx_orbit {
165165
Some(position)
166166
} else {
167-
context.reference_position()
167+
context.reference_rx_orbit()
168168
};
169169
let summary = QcSummary::new(&context, &cfg);
170170
let summary_only = cfg.report == QcReportType::Summary;
@@ -226,11 +226,7 @@ impl QcReport {
226226
#[cfg(feature = "sp3")]
227227
orbit: {
228228
if (context.has_sp3() || context.has_brdc_navigation()) && !summary_only {
229-
Some(OrbitReport::new(
230-
context,
231-
ref_position,
232-
cfg.force_brdc_skyplot,
233-
))
229+
Some(OrbitReport::new(context, ref_position))
234230
} else {
235231
None
236232
}

0 commit comments

Comments
 (0)