|
| 1 | +// SBAS specific tests |
| 2 | +use crate::prelude::{Constellation, Rinex, SV}; |
| 3 | +use qc_traits::{Filter, FilterItem, MaskOperand, Preprocessing}; |
| 4 | +use std::str::FromStr; |
| 5 | + |
| 6 | +// Formatting issue |
| 7 | +#[test] |
| 8 | +#[cfg(feature = "flate2")] |
| 9 | +fn test_sbas_obs_v3_formatting() { |
| 10 | + let rinex = |
| 11 | + Rinex::from_gzip_file("data/CRNX/V3/ESBC00DNK_R_20201770000_01D_30S_MO.crx.gz").unwrap(); |
| 12 | + |
| 13 | + // basic initial verifications.. |
| 14 | + let (mut s23_found, mut s25_found, mut s36_found) = (false, false, false); |
| 15 | + let s23 = SV::from_str("S23").unwrap(); |
| 16 | + let s25 = SV::from_str("S25").unwrap(); |
| 17 | + let s36 = SV::from_str("S36").unwrap(); |
| 18 | + |
| 19 | + for sv in rinex.sv_iter() { |
| 20 | + s23_found |= sv == s23; |
| 21 | + s25_found |= sv == s25; |
| 22 | + s36_found |= sv == s36; |
| 23 | + } |
| 24 | + |
| 25 | + assert!(s23_found, "S23 not present in initial setup!"); |
| 26 | + assert!(s25_found, "S25 not present in initial setup!"); |
| 27 | + assert!(s36_found, "S36 not present in initial setup!"); |
| 28 | + |
| 29 | + let geo_only = Filter::mask( |
| 30 | + MaskOperand::Equals, |
| 31 | + FilterItem::ConstellationItem(vec![Constellation::SBAS]), |
| 32 | + ); |
| 33 | + |
| 34 | + let mut geo_only = rinex.filter(&geo_only); |
| 35 | + |
| 36 | + // RINEX |
| 37 | + let rinex_geo_only = geo_only.crnx2rnx(); |
| 38 | + |
| 39 | + // dump |
| 40 | + rinex_geo_only |
| 41 | + .to_file("test_geo-only.txt") |
| 42 | + .unwrap_or_else(|e| panic!("SBAS only formatting issue: {}", e)); |
| 43 | + |
| 44 | + // parse back |
| 45 | + let dut = Rinex::from_file("test_geo-only.txt") |
| 46 | + .unwrap_or_else(|e| panic!("SABS only: failed to parse back: {}", e)); |
| 47 | + |
| 48 | + // test |
| 49 | + let (mut s23_found, mut s25_found, mut s36_found) = (false, false, false); |
| 50 | + for sv in dut.sv_iter() { |
| 51 | + s23_found |= sv == s23; |
| 52 | + s25_found |= sv == s25; |
| 53 | + s36_found |= sv == s36; |
| 54 | + } |
| 55 | + |
| 56 | + assert!(s23_found, "S23 not present in parsed-back RINEX!"); |
| 57 | + assert!(s25_found, "S25 not present in parsed-back RINEX!"); |
| 58 | + assert!(s36_found, "S36 not present in parsed-back RINEX!"); |
| 59 | + |
| 60 | + // CRINEX dump |
| 61 | + geo_only |
| 62 | + .to_file("test_geo-only.txt") |
| 63 | + .unwrap_or_else(|e| panic!("SBAS only CRINEX formatting issue: {}", e)); |
| 64 | + |
| 65 | + // parse back |
| 66 | + let dut = Rinex::from_file("test_geo-only.txt") |
| 67 | + .unwrap_or_else(|e| panic!("SABS only: failed to parse back: {}", e)); |
| 68 | + |
| 69 | + // test |
| 70 | + let (mut s23_found, mut s25_found, mut s36_found) = (false, false, false); |
| 71 | + for sv in dut.sv_iter() { |
| 72 | + s23_found |= sv == s23; |
| 73 | + s25_found |= sv == s25; |
| 74 | + s36_found |= sv == s36; |
| 75 | + } |
| 76 | + |
| 77 | + assert!(s23_found, "S23 not present in parsed-back RINEX!"); |
| 78 | + assert!(s25_found, "S25 not present in parsed-back RINEX!"); |
| 79 | + assert!(s36_found, "S36 not present in parsed-back RINEX!"); |
| 80 | + |
| 81 | + // delete |
| 82 | + let _ = std::fs::remove_file("test_geo-only.txt"); |
| 83 | +} |
0 commit comments