Skip to content

Commit

Permalink
OBS_RINEX formatting: fix tiny issues when formatting header section (#…
Browse files Browse the repository at this point in the history
…212)

* OBS_RINEX formatting: fix tiny issues when formatting header section
* removed unused variable
* unlock meteo_v3 formatting test

---------

Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres authored Mar 21, 2024
1 parent 754b134 commit fd2444b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
7 changes: 5 additions & 2 deletions rinex/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1613,8 +1613,11 @@ impl Header {
for (constell, observables) in &obs.codes {
let mut descriptor = String::new();
descriptor.push_str(&format!("{:x}{:5}", constell, observables.len()));
for observable in observables {
descriptor.push_str(&format!(" {}", observable));
for (i, observable) in observables.iter().enumerate() {
if (i % 13) == 0 && (i > 0) {
descriptor.push_str(&format!(" ")); // TAB
}
descriptor.push_str(&format!(" {}", observable)); // TAB
}
writeln!(f, "{}", fmt_rinex(&descriptor, "SYS / # / OBS TYPES"))?;
}
Expand Down
20 changes: 14 additions & 6 deletions rinex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,8 @@ pub(crate) fn fmt_rinex(content: &str, marker: &str) -> String {
for i in 0..nb_lines {
let start_off = i * 60;
let end_off = std::cmp::min(start_off + 60, content.len());
string.push_str(&format!(
"{:<padding$}{}",
&content[start_off..end_off],
marker,
padding = 60
));
let chunk = &content[start_off..end_off];
string.push_str(&format!("{:<padding$}{}", chunk, marker, padding = 60));
if i < nb_lines - 1 {
string.push('\n');
}
Expand Down Expand Up @@ -3471,4 +3467,16 @@ mod test {
}
}
}
#[test]
fn fmt_observables_v3() {
for (desc, expected) in [
("R 9 C1C L1C S1C C2C C2P L2C L2P S2C S2P",
"R 9 C1C L1C S1C C2C C2P L2C L2P S2C S2P SYS / # / OBS TYPES"),
("G 18 C1C L1C S1C C2P C2W C2S C2L C2X L2P L2W L2S L2L L2X S2P S2W S2S S2L S2X",
"G 18 C1C L1C S1C C2P C2W C2S C2L C2X L2P L2W L2S L2L L2X SYS / # / OBS TYPES
S2P S2W S2S S2L S2X SYS / # / OBS TYPES"),
] {
assert_eq!(fmt_rinex(desc, "SYS / # / OBS TYPES"), expected);
}
}
}
12 changes: 11 additions & 1 deletion rinex/src/tests/production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod test {
use crate::*;
use std::path::Path;
fn testbench(path: &str) {
// parse this file
println!("running on \"{}\"", path);
let rnx = Rinex::from_file(path).unwrap(); // already tested elsewhere
let tmp_path = format!("test-{}.rnx", random_name(5));
assert!(rnx.to_file(&tmp_path).is_ok()); // test writer
Expand Down Expand Up @@ -67,6 +67,16 @@ mod test {
}
#[test]
#[cfg(feature = "flate2")]
fn meteo_v3() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/../test_resources/MET/V3/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
testbench(fp.to_str().unwrap());
}
}
#[test]
#[cfg(feature = "flate2")]
fn meteo_v4() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/../test_resources/MET/V4/";
for file in std::fs::read_dir(folder).unwrap() {
Expand Down
Empty file removed test_resources/MET/V3/.gitkeep
Empty file.

0 comments on commit fd2444b

Please sign in to comment.