@@ -174,17 +174,19 @@ impl SP3Entry {
174
174
let mut formatted = format ! (
175
175
"P{}{}{}{}" ,
176
176
sv,
177
- CoordsFormatter :: new ( self . position_km. 0 ) ,
178
- CoordsFormatter :: new ( self . position_km. 1 ) ,
179
- CoordsFormatter :: new ( self . position_km. 2 ) ,
177
+ CoordsFormatter :: coordinates ( self . position_km. 0 ) ,
178
+ CoordsFormatter :: coordinates ( self . position_km. 1 ) ,
179
+ CoordsFormatter :: coordinates ( self . position_km. 2 ) ,
180
180
) ;
181
181
182
182
if let Some ( value) = self . clock_us {
183
- formatted. push_str ( & format ! ( "{}" , CoordsFormatter :: new ( value) ) ) ;
183
+ formatted. push_str ( & format ! ( "{}" , CoordsFormatter :: coordinates ( value) ) ) ;
184
184
} else {
185
- formatted. push_str ( " " ) ;
185
+ formatted. push_str ( " " ) ;
186
186
}
187
187
188
+ formatted. push_str ( " " ) ; // deviations not handled yet
189
+
188
190
if self . clock_event {
189
191
formatted. push ( 'E' ) ;
190
192
} else {
@@ -214,13 +216,13 @@ impl SP3Entry {
214
216
formatted. push_str ( & format ! (
215
217
"\n V{}{}{}{}" ,
216
218
sv,
217
- CoordsFormatter :: new ( vel_x_km) ,
218
- CoordsFormatter :: new ( vel_y_km) ,
219
- CoordsFormatter :: new ( vel_z_km) ,
219
+ CoordsFormatter :: coordinates ( vel_x_km) ,
220
+ CoordsFormatter :: coordinates ( vel_y_km) ,
221
+ CoordsFormatter :: coordinates ( vel_z_km) ,
220
222
) ) ;
221
223
222
224
if let Some ( drift_ns) = self . clock_drift_ns {
223
- formatted. push_str ( & format ! ( "{}" , CoordsFormatter :: new ( drift_ns) ) ) ;
225
+ formatted. push_str ( & format ! ( "{}" , CoordsFormatter :: coordinates ( drift_ns) ) ) ;
224
226
}
225
227
}
226
228
@@ -553,6 +555,7 @@ VG01 -22859.768469 -8524.538983 -15063.229095\n",
553
555
"PG01 15402.861499 21607.418873 -992.500669
554
556
VG01 -22859.768469 -8524.538983 -15063.229095 -3.292980\n " ,
555
557
) ;
558
+
556
559
let mut buf = BufWriter :: new ( Utf8Buffer :: new ( 1024 ) ) ;
557
560
558
561
data. format ( g01, & mut buf) . unwrap_or_else ( |e| {
@@ -565,4 +568,34 @@ VG01 -22859.768469 -8524.538983 -15063.229095 -3.292980\n",
565
568
assert_eq ! ( formatted, expected) ;
566
569
}
567
570
}
571
+
572
+ #[ test]
573
+ fn sp3_d_predicted_entry_formatting ( ) {
574
+ let g01 = SV :: from_str ( "G01" ) . unwrap ( ) ;
575
+
576
+ let entry = SP3Entry {
577
+ position_km : ( -22335.782004 , -14656.280389 , -1218.238499 ) ,
578
+ velocity_km_s : None ,
579
+ predicted_clock : true ,
580
+ predicted_orbit : true ,
581
+ maneuver : true ,
582
+ clock_event : true ,
583
+ clock_us : Some ( -176.397152 ) ,
584
+ clock_drift_ns : None ,
585
+ } ;
586
+
587
+ let mut buf = BufWriter :: new ( Utf8Buffer :: new ( 1024 ) ) ;
588
+
589
+ entry. format ( g01, & mut buf) . unwrap_or_else ( |e| {
590
+ panic ! ( "SP3/data formatting issue: {}" , e) ;
591
+ } ) ;
592
+
593
+ let formatted = buf. into_inner ( ) . unwrap ( ) ;
594
+ let formatted = formatted. to_ascii_utf8 ( ) ;
595
+
596
+ assert_eq ! (
597
+ formatted,
598
+ "PG01 -22335.782004 -14656.280389 -1218.238499 -176.397152 EP MP\n "
599
+ ) ;
600
+ }
568
601
}
0 commit comments