astrodynamics-gnss 0.7.0

GNSS domain layer (SP3, broadcast ephemeris, multi-GNSS single-point positioning, ionosphere/troposphere, DOP) built on the astrodynamics core
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
//! Parser unit + property tests for the SP3-c / SP3-d reader.
//!
//! These are supplemental coverage (round-trip, missing-value, boundary,
//! flags, unit conversion). They are NOT the 0-ULP parity acceptance gate —
//! that is the gnssanalysis/scipy golden-vector suite for the *interpolation*,
//! which is a separate deliverable. A parser is not a contested float recipe,
//! so these prove correctness of the byte/record decoding and the
//! unit/frame/flag contracts.

use super::*;

/// A minimal but standards-shaped SP3-c position+clock file with two GPS sats,
/// two epochs, a missing-orbit record, a bad-clock record, and assorted flags.
const SP3C_FILE: &str = "\
#cP2020  6 24  0  0  0.00000000       2 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
+    2   G01G02  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
++         0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c G  cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
%f  1.2500000  1.025000000  0.00000000000  0.000000000000000
%f  0.0000000  0.000000000  0.00000000000  0.000000000000000
%i    0    0    0    0      0      0      0      0         0
%i    0    0    0    0      0      0      0      0         0
/* TEST SP3-c FIXTURE
*  2020  6 24  0  0  0.00000000
PG01  15000.000000 -20000.000000   5000.000000    123.456789
PG02  -1234.567890   2345.678901  -3456.789012 999999.999999
*  2020  6 24  0 15  0.00000000
PG01  15100.000000 -20100.000000   5100.000000   -987.654321              E
PG02      0.000000      0.000000      0.000000    100.000000
EOF
";

/// A minimal SP3-d multi-GNSS file with position+velocity records, GPS +
/// Galileo + BeiDou, and predicted/maneuver flags.
const SP3D_FILE: &str = "\
#dV2022  1  2  3  4  5.00000000       1 ORBIT IGS20 FIT  TST
## 2191 270245.00000000   300.00000000 59581 0.1281597222222
+    3   G05E11C30  0  0  0  0  0  0  0  0  0  0  0  0  0  0
++         0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c M  cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
%f  1.2500000  1.025000000  0.00000000000  0.000000000000000
%f  0.0000000  0.000000000  0.00000000000  0.000000000000000
%i    0    0    0    0      0      0      0      0         0
%i    0    0    0    0      0      0      0      0         0
/* TEST SP3-d FIXTURE
*  2022  1  2  3  4  5.00000000
PG05  10000.000000  20000.000000  30000.000000    -50.000000
VG05  10000.000000 -20000.000000  30000.000000      1.000000
PE11 -11111.111111  22222.222222 -33333.333333    250.000000                   P
VE11  -5000.000000   5000.000000  -5000.000000      2.500000
PC30   1000.000000   2000.000000   3000.000000    -10.000000                  MP
VC30   1234.000000   5678.000000   9012.000000     -1.000000
EOF
";

fn id(sys: GnssSystem, prn: u8) -> GnssSatelliteId {
    GnssSatelliteId::new(sys, prn)
}

#[test]
fn parses_sp3c_header() {
    let sp3 = Sp3::parse(SP3C_FILE.as_bytes()).expect("parse SP3-c");
    let h = &sp3.header;
    assert_eq!(h.version, Sp3Version::C);
    assert_eq!(h.data_type, Sp3DataType::Position);
    assert_eq!(h.num_epochs, 2);
    assert_eq!(h.coordinate_system, "IGS14");
    assert_eq!(h.orbit_type, "FIT");
    assert_eq!(h.agency, "TST");
    assert_eq!(h.gnss_week, 2111);
    assert_eq!(h.seconds_of_week, 432000.0);
    assert_eq!(h.epoch_interval_s, 900.0);
    assert_eq!(h.mjd, 59024);
    assert_eq!(h.time_scale, TimeScale::Gpst);
    assert_eq!(
        h.satellites,
        vec![id(GnssSystem::Gps, 1), id(GnssSystem::Gps, 2)]
    );
    assert_eq!(sp3.epoch_count(), 2);
    assert_eq!(sp3.comments, vec!["TEST SP3-c FIXTURE".to_string()]);
}

#[test]
fn parses_sp3c_position_and_clock_units() {
    let sp3 = Sp3::parse(SP3C_FILE.as_bytes()).unwrap();
    let st = sp3.state(id(GnssSystem::Gps, 1), 0).unwrap();
    // km -> m is a single *1000 multiply.
    assert_eq!(st.position.x_m, 15000.000000 * 1_000.0);
    assert_eq!(st.position.y_m, -20000.000000 * 1_000.0);
    assert_eq!(st.position.z_m, 5000.000000 * 1_000.0);
    // us -> s is a single *1e-6 multiply.
    assert_eq!(st.clock_s, Some(123.456789 * 1.0e-6));
    assert!(st.velocity.is_none());
    assert!(st.clock_rate_s_s.is_none());
    assert_eq!(st.flags, Sp3Flags::default());
}

#[test]
fn missing_clock_sentinel_is_none_but_position_kept() {
    let sp3 = Sp3::parse(SP3C_FILE.as_bytes()).unwrap();
    // G02 epoch 0 has a valid position but the 999999.999999 bad-clock sentinel.
    let st = sp3.state(id(GnssSystem::Gps, 2), 0).unwrap();
    assert_eq!(st.position.x_m, -1234.567890 * 1_000.0);
    assert_eq!(st.clock_s, None, "bad-clock sentinel must surface as None");
}

#[test]
fn missing_position_record_is_dropped() {
    let sp3 = Sp3::parse(SP3C_FILE.as_bytes()).unwrap();
    // G02 epoch 1 is the all-zero (missing-orbit) sentinel: no state recorded.
    let err = sp3.state(id(GnssSystem::Gps, 2), 1).unwrap_err();
    assert_eq!(err, Error::UnknownSatellite(id(GnssSystem::Gps, 2)));
    // G01 at the same epoch is still present.
    assert!(sp3.state(id(GnssSystem::Gps, 1), 1).is_ok());
}

#[test]
fn clock_event_flag_parsed() {
    let sp3 = Sp3::parse(SP3C_FILE.as_bytes()).unwrap();
    let st = sp3.state(id(GnssSystem::Gps, 1), 1).unwrap();
    assert!(st.flags.clock_event, "E flag in clock-event column");
    assert!(!st.flags.orbit_predicted);
    assert_eq!(st.clock_s, Some(-987.654321 * 1.0e-6));
}

#[test]
fn parses_sp3d_multignss_velocity() {
    let sp3 = Sp3::parse(SP3D_FILE.as_bytes()).expect("parse SP3-d");
    assert_eq!(sp3.header.version, Sp3Version::D);
    assert_eq!(sp3.header.data_type, Sp3DataType::Velocity);
    assert_eq!(
        sp3.header.satellites,
        vec![
            id(GnssSystem::Gps, 5),
            id(GnssSystem::Galileo, 11),
            id(GnssSystem::BeiDou, 30),
        ]
    );

    // GPS sat: position + velocity, distinct per-axis (guards the refs/sp3
    // X/Y axis bug).
    let g = sp3.state(id(GnssSystem::Gps, 5), 0).unwrap();
    assert_eq!(g.position.x_m, 10000.0 * 1_000.0);
    let v = g.velocity.expect("velocity present");
    // dm/s -> m/s is *0.1, and each axis is read independently.
    assert_eq!(v.vx_m_s, 10000.0 * 0.1);
    assert_eq!(v.vy_m_s, -20000.0 * 0.1);
    assert_eq!(v.vz_m_s, 30000.0 * 0.1);
    assert_ne!(v.vx_m_s, v.vy_m_s, "X and Y velocity must not be aliased");
    // clock-rate: 1e-4 us/s field -> s/s is *1e-10.
    assert_eq!(g.clock_rate_s_s, Some(1.0 * 1.0e-10));
}

#[test]
fn predicted_and_maneuver_flags_sp3d() {
    let sp3 = Sp3::parse(SP3D_FILE.as_bytes()).unwrap();
    let e = sp3.state(id(GnssSystem::Galileo, 11), 0).unwrap();
    assert!(e.flags.orbit_predicted, "trailing P = predicted orbit");
    let c = sp3.state(id(GnssSystem::BeiDou, 30), 0).unwrap();
    assert!(c.flags.maneuver, "M = maneuver");
    assert!(c.flags.orbit_predicted, "P after M = predicted orbit");
}

#[test]
fn epoch_index_out_of_range_errors() {
    let sp3 = Sp3::parse(SP3C_FILE.as_bytes()).unwrap();
    assert_eq!(
        sp3.state(id(GnssSystem::Gps, 1), 99),
        Err(Error::EpochOutOfRange)
    );
    assert!(sp3.states_at(99).is_err());
}

#[test]
fn epoch_julian_split_is_consistent() {
    let sp3 = Sp3::parse(SP3C_FILE.as_bytes()).unwrap();
    // 2020-06-24 00:00:00 -> the day boundary should be on a *.5 JD whole, and
    // the second epoch is 900 s = 0.625 hours later, i.e. fraction differs by
    // exactly 900/86400.
    let e0 = sp3.epochs[0].julian_date().unwrap();
    let e1 = sp3.epochs[1].julian_date().unwrap();
    assert_eq!(e0.jd_whole, e1.jd_whole, "same civil day");
    assert_eq!(e1.fraction - e0.fraction, 900.0 / 86_400.0);
    // 2020-06-24 is JD 2459024.5 at midnight.
    assert_eq!(e0.jd_whole + e0.fraction, 2_459_024.5);
}

// --- Boundary / malformed-input tests ------------------------------------

#[test]
fn missing_header_line1_errors() {
    let no_h1 = "\
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
EOF
";
    let err = Sp3::parse(no_h1.as_bytes()).unwrap_err();
    assert!(matches!(err, Error::Parse(_)));
}

#[test]
fn missing_header_line2_errors() {
    let no_h2 = "\
#cP2020  6 24  0  0  0.00000000      2 ORBIT IGS14 FIT  TST
EOF
";
    let err = Sp3::parse(no_h2.as_bytes()).unwrap_err();
    assert!(matches!(err, Error::Parse(_)));
}

#[test]
fn unknown_time_system_errors() {
    // GLO time system is intentionally rejected rather than aliased.
    let glo = "\
#cP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
+    1   R01  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c R  cc GLO ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
EOF
";
    let err = Sp3::parse(glo.as_bytes()).unwrap_err();
    assert!(
        matches!(err, Error::Parse(ref m) if m.contains("GLO")),
        "got {err:?}"
    );
}

#[test]
fn missing_pc_descriptor_errors_for_sp3c() {
    // SP3-c with NO %c line at all: the time system is unknown and MUST NOT
    // silently default to GPST. finish() rejects it.
    let no_pc = "\
#cP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
+    1   G01  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
*  2020  6 24  0  0  0.00000000
PG01  15000.000000 -20000.000000   5000.000000    123.456789
EOF
";
    let err = Sp3::parse(no_pc.as_bytes()).unwrap_err();
    assert!(
        matches!(err, Error::Parse(ref m) if m.contains("time system")),
        "missing %c must error, not default to GPST; got {err:?}"
    );
}

#[test]
fn short_pc_descriptor_errors_for_sp3c() {
    // SP3-c with a %c line too short to carry the time-system field: error,
    // never a GPST fallback.
    let short_pc = "\
#cP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
+    1   G01  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c G
EOF
";
    let err = Sp3::parse(short_pc.as_bytes()).unwrap_err();
    assert!(
        matches!(err, Error::Parse(ref m) if m.contains("too short")),
        "short %c must error; got {err:?}"
    );
}

#[test]
fn blank_pc_time_system_errors_for_sp3c() {
    // SP3-c %c line long enough but with a blank time-system field (cols 9-12):
    // a blank scale is malformed, not GPST.
    let blank_pc = "\
#cP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
+    1   G01  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c G  cc     ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
EOF
";
    let err = Sp3::parse(blank_pc.as_bytes()).unwrap_err();
    assert!(
        matches!(err, Error::Parse(ref m) if m.contains("blank")),
        "blank %c time system must error; got {err:?}"
    );
}

#[test]
fn sp3a_with_no_pc_descriptor_is_gpst() {
    // SP3-a predates %c and is implicitly GPST; a file with no %c line still
    // parses and resolves to GPST.
    let sp3a = "\
#aP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
+    1     1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
*  2020  6 24  0  0  0.00000000
P  1  15000.000000 -20000.000000   5000.000000    123.456789
EOF
";
    let sp3 = Sp3::parse(sp3a.as_bytes()).expect("SP3-a parses without %c");
    assert_eq!(sp3.header.version, Sp3Version::A);
    assert_eq!(sp3.header.time_scale, TimeScale::Gpst);
    assert!(sp3.state(id(GnssSystem::Gps, 1), 0).is_ok());
}

#[test]
fn sp3a_ignores_pc_descriptor_and_stays_gpst() {
    // Even if an SP3-a file carries a %c line with a non-GPS label, SP3-a is
    // implicitly GPST and the descriptor is ignored (no error, no aliasing).
    let sp3a = "\
#aP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
+    1     1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c R  cc GLO ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
*  2020  6 24  0  0  0.00000000
P  1  15000.000000 -20000.000000   5000.000000    123.456789
EOF
";
    let sp3 = Sp3::parse(sp3a.as_bytes()).expect("SP3-a parses, ignoring %c");
    assert_eq!(sp3.header.time_scale, TimeScale::Gpst);
}

#[test]
fn valid_gps_pc_descriptor_parses() {
    // A valid GPS %c on an SP3-c file resolves to GPST (the SP3C_FILE fixture).
    let sp3 = Sp3::parse(SP3C_FILE.as_bytes()).unwrap();
    assert_eq!(sp3.header.time_scale, TimeScale::Gpst);
}

#[test]
fn velocity_only_record_produces_no_state() {
    // A V-record with no preceding P-record for that sat at the epoch must NOT
    // synthesize a (0,0,0) geocenter position. The satellite is left absent.
    let vel_only = "\
#dV2022  1  2  3  4  5.00000000       1 ORBIT IGS20 FIT  TST
## 2191 270245.00000000   300.00000000 59581 0.1281597222222
+    1   G05  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c M  cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
*  2022  1  2  3  4  5.00000000
VG05  10000.000000 -20000.000000  30000.000000      1.000000
EOF
";
    let sp3 = Sp3::parse(vel_only.as_bytes()).expect("parse velocity-only");
    // No state for G05: a fabricated (0,0,0) must never be exposed.
    let err = sp3.state(id(GnssSystem::Gps, 5), 0).unwrap_err();
    assert_eq!(err, Error::UnknownSatellite(id(GnssSystem::Gps, 5)));
    // states_at must likewise be empty for this epoch.
    assert!(
        sp3.states_at(0).unwrap().is_empty(),
        "no (0,0,0) state leaked"
    );
}

#[test]
fn position_then_velocity_augments_velocity() {
    // The normal P-then-V case still augments the existing position state with
    // the velocity (regression guard for the #4 fix).
    let sp3 = Sp3::parse(SP3D_FILE.as_bytes()).unwrap();
    let st = sp3.state(id(GnssSystem::Gps, 5), 0).unwrap();
    // Real position (not the fabricated geocenter).
    assert_eq!(st.position.x_m, 10000.0 * 1_000.0);
    let v = st
        .velocity
        .expect("velocity augmented onto the P-record state");
    assert_eq!(v.vx_m_s, 10000.0 * 0.1);
    assert_eq!(v.vy_m_s, -20000.0 * 0.1);
    assert_eq!(v.vz_m_s, 30000.0 * 0.1);
}

#[test]
fn position_record_before_epoch_errors() {
    let bad = "\
#cP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
+    1   G01  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c G  cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
PG01  15000.000000 -20000.000000   5000.000000    123.456789
EOF
";
    let err = Sp3::parse(bad.as_bytes()).unwrap_err();
    assert!(
        matches!(err, Error::Parse(ref m) if m.contains("before any epoch")),
        "got {err:?}"
    );
}

#[test]
fn non_utf8_input_errors() {
    let bytes = [0xffu8, 0xfe, 0x00, 0x01];
    let err = Sp3::parse(&bytes).unwrap_err();
    assert!(
        matches!(err, Error::Parse(ref m) if m.contains("UTF-8")),
        "got {err:?}"
    );
}

#[test]
fn trailing_truncation_after_eof_tolerated() {
    // Lines after EOF are ignored; parse still succeeds with the prior epochs.
    let truncated = format!("{SP3C_FILE}garbage line that should be ignored\n");
    let sp3 = Sp3::parse(truncated.as_bytes()).unwrap();
    assert_eq!(sp3.epoch_count(), 2);
}

// --- Property-style tests (round-trip on the value contracts) ------------

#[test]
fn sv_token_round_trips_through_display() {
    // Every system+prn we can format should parse back to the same id, which
    // is the parser's identity contract for the satellite list.
    for sys in [
        GnssSystem::Gps,
        GnssSystem::Glonass,
        GnssSystem::Galileo,
        GnssSystem::BeiDou,
        GnssSystem::Qzss,
        GnssSystem::Navic,
        GnssSystem::Sbas,
    ] {
        for prn in [1u8, 5, 9, 12, 30, 99] {
            let want = id(sys, prn);
            let token = want.to_string(); // e.g. "G01"
            let got = super::parse_sv_token(&token, Some(Sp3Version::D))
                .unwrap_or_else(|| panic!("token {token:?} failed to parse"));
            assert_eq!(got, want);
        }
    }
}

#[test]
fn sp3a_bare_numeric_prn_is_gps() {
    // SP3-a omits the constellation letter: a bare PRN is GPS.
    assert_eq!(
        super::parse_sv_token(" 7", Some(Sp3Version::A)),
        Some(id(GnssSystem::Gps, 7))
    );
    assert_eq!(
        super::parse_sv_token("23", Some(Sp3Version::A)),
        Some(id(GnssSystem::Gps, 23))
    );
}

#[test]
fn multibyte_line_does_not_panic() {
    // SP3 is ASCII, but a stray multibyte char must not panic the fixed-column
    // slicer (it should surface as a parse error, not an abort).
    let file = "\
#cP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST
## 2111 432000.00000000   900.00000000 59024 0.0000000000000
%c G  cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
*  2020  6 24  0  0  0.00000000
PG01  15000.000000 -20000.000000   5000.000000    123.456789 \u{00e9}\u{00e9}\u{00e9}
EOF
";
    // Must not panic; either parses (ignoring the trailing garbage) or errors.
    let _ = Sp3::parse(file.as_bytes());
}

#[test]
fn coordinate_sign_and_magnitude_preserved() {
    // A small fuzz over signed magnitudes parsed through fixed columns: build a
    // position record for each, parse, and require the meters back equals
    // km*1000 exactly (no rounding in the unit step).
    for &km in &[0.000001f64, -12345.678901, 26560.123456, -26560.999999] {
        // Position record columns: P(0) sv(1..4) x(4..18) y(18..32) z(32..46)
        // clk(46..60). Each numeric field is exactly 14 wide.
        let line = format!("PG01{:14.6}{:14.6}{:14.6}{:14.6}", km, km, km, 0.0);
        let file = format!(
            "#cP2020  6 24  0  0  0.00000000       1 ORBIT IGS14 FIT  TST\n\
## 2111 432000.00000000   900.00000000 59024 0.0000000000000\n\
+    1   G01  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0\n\
%c G  cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc\n\
*  2020  6 24  0  0  0.00000000\n\
{line}\n\
EOF\n"
        );
        let sp3 = Sp3::parse(file.as_bytes()).unwrap();
        let st = sp3.state(id(GnssSystem::Gps, 1), 0).unwrap();
        assert_eq!(st.position.x_m, km * 1_000.0, "km={km}");
        assert_eq!(st.position.z_m, km * 1_000.0, "km={km}");
    }
}