Skip to content

Commit

Permalink
apply suggestion
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres committed Sep 9, 2023
1 parent 0aac52b commit 87975c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
4 changes: 3 additions & 1 deletion rinex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,9 @@ impl Rinex {
if let Some(header) = &self.header.obs {
// apply a scaling, if any, otherwise : leave data untouched
// to preserve its precision
if let Some(scaling) = header.scaling(&sv.constellation, observable) {
if let Some(scaling) =
header.scaling(sv.constellation, observable.clone())
{
Some((*e, *sv, observable, obsdata.obs / *scaling as f64))
} else {
Some((*e, *sv, observable, obsdata.obs))
Expand Down
15 changes: 4 additions & 11 deletions rinex/src/observation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub struct HeaderFields {
/// True if local clock drift is compensated for
pub clock_offset_applied: bool,
/// Optionnal data scalings
pub scalings: HashMap<Constellation, HashMap<Observable, u16>>,
pub scalings: HashMap<(Constellation, Observable), u16>,
}

impl HeaderFields {
Expand All @@ -120,19 +120,12 @@ impl HeaderFields {
observable: Observable,
scaling: u16,
) {
if let Some(scalings) = self.scalings.get_mut(&c) {
scalings.insert(observable, scaling);
} else {
let mut map: HashMap<Observable, u16> = HashMap::new();
map.insert(observable, scaling);
self.scalings.insert(c, map);
}
self.scalings.insert((c, observable), scaling);
}
/// Returns given scaling to apply for given GNSS system
/// and given observation. Returns 1.0 by default, so it always applies
pub(crate) fn scaling(&self, c: &Constellation, observable: &Observable) -> Option<&u16> {
let scalings = self.scalings.get(c)?;
scalings.get(observable)
pub(crate) fn scaling(&self, c: Constellation, observable: Observable) -> Option<&u16> {
self.scalings.get(&(c, observable))
}
}

Expand Down

0 comments on commit 87975c2

Please sign in to comment.