Skip to content

Commit

Permalink
use latest rinex tag
Browse files Browse the repository at this point in the history
  • Loading branch information
gwbres committed Apr 8, 2022
1 parent e4d40d2 commit b83b645
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
readme = "README.md"

[dependencies]
rinex = "0.2.2"
rinex = "0.3.0"
clap = { version = "~2.27.0", features = ["yaml"] }
thiserror = "1"

Expand Down
22 changes: 7 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,39 +72,31 @@ fn main() -> Result<(), Error> {
/// writer: stream
fn decompress (fp: &str, m: u16, mut writer: std::fs::File) -> Result<(), Error> {
let mut content = String::new();
let mut hd_content = String::new();
let input = std::fs::File::open(fp)?;
let reader = BufReader::new(input);
let mut header : header::Header = header::Header::default();
let header = header::Header::new(fp)?;
let mut end_of_header = false;
let mut decompressor = hatanaka::Decompressor::new(m.into());

let mut header_parsed = false;
println!("Decompressing file \"{}\"", fp);
for l in reader.lines() {
let line = &l.unwrap();
if !header_parsed {
hd_content.push_str(line);
hd_content.push_str("\n");
if !end_of_header {
if !line.contains("CRINEX VERS") && !line.contains("CRINEX PROG") {
// strip CRINEX special header
content.push_str(line);
content.push_str("\n");
write!(writer, "{}", line)?
}
if line.contains("END OF HEADER") {
// identify header section
header = rinex::header::Header::from_str(&hd_content)?;
println!("RINEX Header parsed");
write!(writer, "{}", content)?;
// reset for record section
content.clear();
header_parsed = true;
end_of_header = true;
}
} else { // RINEX record
let mut content : String = String::from(line);
let mut content = line.to_string();
if content.len() == 0 {
content = String::from(" ");
}
let recovered = decompressor.recover(&header, &content)?;
let recovered = decompressor.decompress(&header, &content)?;
write!(writer, "{}", recovered)?
}
}
Expand Down

0 comments on commit b83b645

Please sign in to comment.