Skip to content

Commit

Permalink
Fix empty constellation case (old RINEX format)
Browse files Browse the repository at this point in the history
   - #228

Signed-off-by: Guillaume W. Bres <[email protected]>
  • Loading branch information
gwbres committed Apr 15, 2024
1 parent a793762 commit b0b1318
Showing 1 changed file with 41 additions and 18 deletions.
59 changes: 41 additions & 18 deletions rinex/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,24 +442,47 @@ impl Header {
let (vers, rem) = line.split_at(20);
let (type_str, rem) = rem.split_at(20);
let (constell_str, _) = rem.split_at(20);
rinex_type = Type::from_str(type_str.trim())?;
if type_str.contains("GLONASS") {
// old GLONASS NAV : no constellation field
constellation = Some(Constellation::Glonass);
} else if type_str.contains("GPS NAV DATA") {
constellation = Some(Constellation::GPS);
} else if type_str.contains("IRNSS NAV DATA") {
constellation = Some(Constellation::IRNSS);
} else if type_str.contains("GNSS NAV DATA") {
constellation = Some(Constellation::Mixed);
} else if type_str.contains("METEOROLOGICAL DATA") {
// these files are not tied to a constellation system,
// therefore, do not have this field
} else {
// regular files
if let Ok(constell) = Constellation::from_str(constell_str.trim()) {
constellation = Some(constell);
}

let type_str = type_str.trim();
let constell_str = constell_str.trim();

// File type identification
rinex_type = Type::from_str(type_str)?;

// Constellation identification
match rinex_type {
Type::NavigationData => {
if type_str.contains("GLONASS") {
// old GLONASS NAV : no constellation field
constellation = Some(Constellation::Glonass);
} else if type_str.contains("GPS NAV DATA") {
constellation = Some(Constellation::GPS);
} else if type_str.contains("IRNSS NAV DATA") {
constellation = Some(Constellation::IRNSS);
} else if type_str.contains("GNSS NAV DATA") {
constellation = Some(Constellation::Mixed);
} else if type_str.eq("NAVIGATION DATA") {
if constell_str.is_empty() {
// old GPS NAVIGATION DATA
constellation = Some(Constellation::GPS);
} else {
// Modern NAVIGATION DATA
if let Ok(c) = Constellation::from_str(constell_str) {
constellation = Some(c);
}
}
}
},
Type::MeteoData => {
// no constellation associated to it
},
_ => {
// any other
// regular files
if let Ok(c) = Constellation::from_str(constell_str) {
constellation = Some(c);
}
},
}
/*
* Parse version descriptor
Expand Down

0 comments on commit b0b1318

Please sign in to comment.