Skip to content

Commit 4575997

Browse files
authored
Hatanaka compression (#319)
* RNX2CRX v3 starting to give good results Signed-off-by: Guillaume W. Bres <[email protected]>
1 parent 01c8538 commit 4575997

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

src/hatanaka/compressor.rs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
epoch::epoch_decompose as epoch_decomposition,
55
error::FormattingError,
66
hatanaka::{NumDiff, TextDiff},
7-
observation::{HeaderFields, Record},
7+
observation::{HeaderFields, LliFlags, Record},
88
prelude::{Observable, SV},
99
BufWriter,
1010
};
@@ -62,10 +62,10 @@ impl<const M: usize> CompressorExpert<M> {
6262
header: &HeaderFields,
6363
) -> Result<(), FormattingError> {
6464
for (k, v) in record.iter() {
65-
// TODO: epoch kernel reset on phase lock loss ?
66-
//if k.flags.intersects(LliFlags::LOCK_LOSS || LliFlags::HALF_CYCLE_SLIP) {
67-
// self.epoch_compression = false;
68-
//}
65+
if !k.flag.is_ok() {
66+
// TODO not 100% correct, verify > 1
67+
self.epoch_compression = false;
68+
}
6969

7070
let (y, m, d, hh, mm, ss, ns) = epoch_decomposition(k.epoch);
7171

@@ -78,9 +78,23 @@ impl<const M: usize> CompressorExpert<M> {
7878
.sorted()
7979
.collect::<Vec<_>>();
8080

81+
if !self.epoch_compression {
82+
if self.v3 {
83+
write!(w, "> ")?;
84+
} else {
85+
write!(w, "&")?;
86+
}
87+
} else {
88+
if self.v3 {
89+
write!(w, " ")?;
90+
} else {
91+
write!(w, " ")?;
92+
}
93+
}
94+
8195
if self.v3 {
8296
self.epoch_buf.push_str(&format!(
83-
"> {:04} {:02} {:02} {:02} {:02} {:02}.{:07} {}{:3} ",
97+
"{:04} {:02} {:02} {:02} {:02} {:02}.{:07} {}{:3} ",
8498
y,
8599
m,
86100
d,
@@ -93,7 +107,7 @@ impl<const M: usize> CompressorExpert<M> {
93107
));
94108
} else {
95109
self.epoch_buf.push_str(&format!(
96-
"&{:04} {:02} {:02} {:02} {:02} {:02}.{:07} {}{:3} ",
110+
"{:02} {:02} {:02} {:02} {:02} {:02}.{:07} {}{:3} ",
97111
y,
98112
m,
99113
d,
@@ -112,11 +126,12 @@ impl<const M: usize> CompressorExpert<M> {
112126
}
113127

114128
// Epoch compression
115-
if self.epoch_compression {
116-
let compressed = self.epoch_diff.compress(&self.epoch_buf);
117-
writeln!(w, "{}", compressed)?;
129+
if !self.epoch_compression {
130+
self.epoch_diff.force_init(&self.epoch_buf);
131+
writeln!(w, "{}", self.epoch_buf.trim_end())?;
118132
} else {
119-
writeln!(w, "{}", self.epoch_buf)?;
133+
let compressed = self.epoch_diff.compress(&self.epoch_buf);
134+
writeln!(w, "{}", compressed.trim_end())?;
120135
}
121136

122137
if let Some(clk) = v.clock {
@@ -192,7 +207,10 @@ impl<const M: usize> CompressorExpert<M> {
192207
}
193208
self.flags_buf.clear();
194209
}
210+
211+
// prepare for next epoch
195212
self.epoch_compression = true;
213+
self.epoch_buf.clear();
196214
}
197215
Ok(())
198216
}

src/tests/compression.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,17 @@ mod test {
5656
}
5757

5858
#[test]
59-
#[ignore]
6059
fn crinex3() {
6160
let pool = vec![
6261
(
6362
"ACOR00ESP_R_20213550000_01D_30S_MO.crx",
6463
"ACOR00ESP_R_20213550000_01D_30S_MO.rnx",
6564
),
66-
// ("DUTH0630.22D", "DUTH0630.22O"),
67-
// ("VLNS0010.22D", "VLNS0010.22O"),
68-
// ("VLNS0630.22D", "VLNS0630.22O"),
69-
// ("flrs0010.12d", "flrs0010.12o"),
70-
// ("pdel0010.21d", "pdel0010.21o"),
65+
("DUTH0630.22D", "DUTH0630.22O"),
66+
("VLNS0010.22D", "VLNS0010.22O"),
67+
("VLNS0630.22D", "VLNS0630.22O"),
68+
("flrs0010.12d", "flrs0010.12o"),
69+
("pdel0010.21d", "pdel0010.21o"),
7170
];
7271
for duplet in pool {
7372
let (crnx_name, rnx_name) = duplet;

0 commit comments

Comments
 (0)