1
1
use crate :: {
2
2
epoch:: epoch_decompose,
3
3
error:: FormattingError ,
4
+ fmt_rinex,
4
5
navigation:: { formatting:: NavFormatter , time:: TimeOffset } ,
5
6
prelude:: { Epoch , TimeScale } ,
6
7
} ;
@@ -32,13 +33,19 @@ impl TimeOffset {
32
33
& self ,
33
34
w : & mut BufWriter < W > ,
34
35
) -> Result < ( ) , FormattingError > {
35
- write ! (
36
+ writeln ! (
36
37
w,
37
- " {}{} {:8} {:8} DELTA-UTC: A0,A1,T,W" ,
38
- NavFormatter :: new( self . polynomials. 0 ) ,
39
- NavFormatter :: new( self . polynomials. 1 ) ,
40
- self . t_ref. 1 / 1_000_000_000 ,
41
- self . t_ref. 0 ,
38
+ "{}" ,
39
+ fmt_rinex(
40
+ & format!(
41
+ " {}{} {:8} {:8}" ,
42
+ NavFormatter :: new_time_system_correction_v2( self . polynomials. 0 ) ,
43
+ NavFormatter :: new_time_system_correction_v2( self . polynomials. 1 ) ,
44
+ self . t_ref. 1 / 1_000_000_000 ,
45
+ self . t_ref. 0 ,
46
+ ) ,
47
+ "DELTA-UTC: A0,A1,T,W" ,
48
+ ) ,
42
49
) ?;
43
50
44
51
Ok ( ( ) )
@@ -53,40 +60,41 @@ impl TimeOffset {
53
60
54
61
let ( y, m, d, _, _, _, _) = epoch_decompose ( t) ;
55
62
56
- write ! (
63
+ writeln ! (
57
64
w,
58
- "{:6}{:6}{:6} {}" ,
59
- y,
60
- m,
61
- d,
62
- NavFormatter :: new( self . polynomials. 0 )
65
+ "{}" ,
66
+ fmt_rinex(
67
+ & format!(
68
+ "{:6}{:6}{:6} {}" ,
69
+ y,
70
+ m,
71
+ d,
72
+ NavFormatter :: new_time_system_correction_v2( self . polynomials. 0 )
73
+ ) ,
74
+ "CORR TO SYSTEM TIME" ,
75
+ ) ,
63
76
) ?;
64
77
65
78
Ok ( ( ) )
66
79
}
67
80
68
81
/// Format [TimeOffset] according to RINEXv3 standard
69
82
pub ( crate ) fn format_v3 < W : Write > ( & self , w : & mut BufWriter < W > ) -> Result < ( ) , FormattingError > {
70
- write ! ( w, "{} " , self . to_lhs_rhs_timescales( ) ) ?;
71
-
72
- // TODO: convert to NavFormatter with programmable precision
73
- if self . polynomials . 0 == 0.0 {
74
- write ! ( w, " 0.0000000000e+00" , ) ?;
75
- } else if self . polynomials . 0 . is_sign_negative ( ) {
76
- write ! ( w, "{:14.10E} " , self . polynomials. 0 , ) ?;
77
- } else {
78
- write ! ( w, " {:14.10E} " , self . polynomials. 0 , ) ?;
79
- }
80
-
81
- if self . polynomials . 1 == 0.0 {
82
- write ! ( w, " 0.000000000e+00 " , ) ?;
83
- } else if self . polynomials . 1 . is_sign_negative ( ) {
84
- write ! ( w, "{:14.9E} " , self . polynomials. 1 , ) ?;
85
- } else {
86
- write ! ( w, " {:14.9E} " , self . polynomials. 1 , ) ?;
87
- }
88
-
89
- write ! ( w, "{:6}{:5}" , self . t_ref. 1 / 1_000_000_000 , self . t_ref. 0 ) ?;
83
+ writeln ! (
84
+ w,
85
+ "{}" ,
86
+ fmt_rinex(
87
+ & format!(
88
+ "{} {}{} {:6}{:5}" ,
89
+ self . to_lhs_rhs_timescales( ) ,
90
+ NavFormatter :: new_time_system_correction_v3_offset( self . polynomials. 0 ) ,
91
+ NavFormatter :: new_time_system_correction_v3_drift( self . polynomials. 1 ) ,
92
+ self . t_ref. 1 / 1_000_000_000 ,
93
+ self . t_ref. 0
94
+ ) ,
95
+ "TIME SYSTEM CORR"
96
+ ) ,
97
+ ) ?;
90
98
91
99
Ok ( ( ) )
92
100
}
@@ -95,9 +103,9 @@ impl TimeOffset {
95
103
let t = Epoch :: from_time_of_week ( self . t_ref . 0 , self . t_ref . 1 , self . lhs ) ;
96
104
let ( y, m, d, hh, mm, ss, _) = epoch_decompose ( t) ;
97
105
98
- write ! (
106
+ writeln ! (
99
107
w,
100
- " {:04} {:02} {:02} {:02} {:02} {:02} {}\n " ,
108
+ " {:04} {:02} {:02} {:02} {:02} {:02} {}" ,
101
109
y,
102
110
m,
103
111
d,
@@ -107,7 +115,7 @@ impl TimeOffset {
107
115
self . to_lhs_rhs_timescales( ) ,
108
116
) ?;
109
117
110
- write ! (
118
+ writeln ! (
111
119
w,
112
120
" {}{}{}{}" ,
113
121
NavFormatter :: new( ( self . t_ref. 1 / 1_000_000_000 ) as f64 ) ,
0 commit comments