@@ -174,17 +174,19 @@ impl SP3Entry {
174174 let mut formatted = format ! (
175175 "P{}{}{}{}" ,
176176 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 ) ,
180180 ) ;
181181
182182 if let Some ( value) = self . clock_us {
183- formatted. push_str ( & format ! ( "{}" , CoordsFormatter :: new ( value) ) ) ;
183+ formatted. push_str ( & format ! ( "{}" , CoordsFormatter :: coordinates ( value) ) ) ;
184184 } else {
185- formatted. push_str ( " " ) ;
185+ formatted. push_str ( " " ) ;
186186 }
187187
188+ formatted. push_str ( " " ) ; // deviations not handled yet
189+
188190 if self . clock_event {
189191 formatted. push ( 'E' ) ;
190192 } else {
@@ -214,13 +216,13 @@ impl SP3Entry {
214216 formatted. push_str ( & format ! (
215217 "\n V{}{}{}{}" ,
216218 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) ,
220222 ) ) ;
221223
222224 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) ) ) ;
224226 }
225227 }
226228
@@ -553,6 +555,7 @@ VG01 -22859.768469 -8524.538983 -15063.229095\n",
553555 "PG01 15402.861499 21607.418873 -992.500669
554556VG01 -22859.768469 -8524.538983 -15063.229095 -3.292980\n " ,
555557 ) ;
558+
556559 let mut buf = BufWriter :: new ( Utf8Buffer :: new ( 1024 ) ) ;
557560
558561 data. format ( g01, & mut buf) . unwrap_or_else ( |e| {
@@ -565,4 +568,34 @@ VG01 -22859.768469 -8524.538983 -15063.229095 -3.292980\n",
565568 assert_eq ! ( formatted, expected) ;
566569 }
567570 }
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+ }
568601}
0 commit comments