1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.files.sp3;
18
19 import java.io.IOException;
20 import java.net.URISyntaxException;
21 import java.util.List;
22
23 import org.hipparchus.geometry.euclidean.threed.Vector3D;
24 import org.junit.Assert;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.orekit.Utils;
28 import org.orekit.data.DataSource;
29 import org.orekit.data.UnixCompressFilter;
30 import org.orekit.errors.OrekitException;
31 import org.orekit.errors.OrekitMessages;
32 import org.orekit.files.sp3.SP3.SP3Coordinate;
33 import org.orekit.files.sp3.SP3.SP3Ephemeris;
34 import org.orekit.files.sp3.SP3.SP3OrbitType;
35 import org.orekit.frames.FactoryManagedFrame;
36 import org.orekit.frames.Frame;
37 import org.orekit.frames.FramesFactory;
38 import org.orekit.frames.Predefined;
39 import org.orekit.gnss.TimeSystem;
40 import org.orekit.propagation.BoundedPropagator;
41 import org.orekit.time.AbsoluteDate;
42 import org.orekit.time.TimeScale;
43 import org.orekit.time.TimeScalesFactory;
44 import org.orekit.utils.Constants;
45 import org.orekit.utils.IERSConventions;
46 import org.orekit.utils.PVCoordinates;
47
48 public class SP3ParserTest {
49
50 @Test
51 public void testParseSP3a1() throws IOException, URISyntaxException {
52
53 final String ex = "/sp3/example-a-1.sp3";
54 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
55 final SP3 file = new SP3Parser().parse(source);
56
57 Assert.assertEquals(SP3OrbitType.FIT, file.getOrbitType());
58 Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem());
59 Assert.assertSame(Predefined.ITRF_CIO_CONV_2010_ACCURATE_EOP,
60 ((FactoryManagedFrame) file.getSatellites().get("1").getFrame()).getFactoryKey());
61
62 Assert.assertEquals(25, file.getSatelliteCount());
63
64 final List<SP3Coordinate> coords = file.getSatellites().get("1").getCoordinates();
65 Assert.assertEquals(3, coords.size());
66
67 final SP3Coordinate coord = coords.get(0);
68
69
70 Assert.assertEquals(new AbsoluteDate(1994, 12, 17, 0, 0, 0,
71 TimeScalesFactory.getGPS()), coord.getDate());
72
73
74 checkPVEntry(new PVCoordinates(new Vector3D(16258524.75, -3529015.75, -20611427.049),
75 Vector3D.ZERO),
76 coord);
77 Assert.assertEquals(-0.0000625406, coord.getClockCorrection(), 1.0e-15);
78 Assert.assertEquals("NGS", file.getAgency());
79 Assert.assertEquals("ITR92", file.getCoordinateSystem());
80 Assert.assertEquals("d", file.getDataUsed());
81 Assert.assertEquals(0.0, file.getDayFraction(), 1.0e-15);
82 Assert.assertEquals("1994-12-16T23:59:50.000", file.getEpoch().toString(TimeScalesFactory.getUTC()));
83 Assert.assertEquals(49703, file.getJulianDay());
84 Assert.assertEquals(3, file.getNumberOfEpochs());
85 Assert.assertEquals(900.0, file.getEpochInterval(), 1.0e-15);
86 Assert.assertEquals(779, file.getGpsWeek());
87 Assert.assertEquals(518400.0, file.getSecondsOfWeek(), 1.0e-10);
88 Assert.assertEquals(25, file.getSatellites().size());
89 Assert.assertEquals(SP3.SP3FileType.UNDEFINED, file.getType());
90 Assert.assertNull(file.getSatellites().get(null));
91 }
92
93 @Test
94 public void testParseSP3a2() throws IOException {
95
96 final String ex = "/sp3/example-a-2.sp3";
97 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
98 final SP3 file = new SP3Parser().parse(source);
99
100 Assert.assertEquals(SP3OrbitType.FIT, file.getOrbitType());
101 Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem());
102
103 Assert.assertEquals(25, file.getSatelliteCount());
104
105 final List<SP3Coordinate> coords = file.getSatellites().get("1").getCoordinates();
106 Assert.assertEquals(3, coords.size());
107
108 final SP3Coordinate coord = coords.get(0);
109
110
111 Assert.assertEquals(new AbsoluteDate(1994, 12, 17, 0, 0, 0,
112 TimeScalesFactory.getGPS()), coord.getDate());
113
114
115
116 checkPVEntry(new PVCoordinates(new Vector3D(16258524.75, -3529015.75, -20611427.049),
117 new Vector3D(-656.0373, 2560.5954, -946.0427)),
118 coord);
119 Assert.assertEquals(-0.0000625406, coord.getClockCorrection(), 1.0e-15);
120 Assert.assertEquals(-0.0000024236, coord.getClockRateChange(), 1.0e-15);
121 }
122
123 @Test
124 public void testParseSP3c1() throws IOException {
125
126 final String ex = "/sp3/example-c-1.sp3";
127 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
128 final SP3 file = new SP3Parser().parse(source);
129
130 Assert.assertEquals(SP3OrbitType.HLM, file.getOrbitType());
131 Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem());
132
133 Assert.assertEquals(26, file.getSatelliteCount());
134
135 final List<SP3Coordinate> coords = file.getSatellites().get("G01").getCoordinates();
136 Assert.assertEquals(2, coords.size());
137
138 final SP3Coordinate coord = coords.get(0);
139
140
141 Assert.assertEquals(new AbsoluteDate(2001, 8, 8, 0, 0, 0,
142 TimeScalesFactory.getGPS()), coord.getDate());
143
144
145 checkPVEntry(new PVCoordinates(new Vector3D(-11044805.8, -10475672.35, 21929418.2),
146 Vector3D.ZERO),
147 coord);
148 Assert.assertEquals(0.0001891633, coord.getClockCorrection(), 1.0e-15);
149 }
150
151 @Test
152 public void testParseSP3c2() throws IOException {
153
154 final String ex = "/sp3/example-c-2.sp3";
155 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
156 final SP3 file = new SP3Parser().parse(source);
157
158 Assert.assertEquals(SP3OrbitType.HLM, file.getOrbitType());
159 Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem());
160
161 Assert.assertEquals(26, file.getSatelliteCount());
162
163 final List<SP3Coordinate> coords = file.getSatellites().get("G01").getCoordinates();
164 Assert.assertEquals(2, coords.size());
165
166 final SP3Coordinate coord = coords.get(0);
167
168
169 Assert.assertEquals(new AbsoluteDate(2001, 8, 8, 0, 0, 0,
170 TimeScalesFactory.getGPS()), coord.getDate());
171
172
173
174 checkPVEntry(new PVCoordinates(new Vector3D(-11044805.8, -10475672.35, 21929418.2),
175 new Vector3D(2029.8880364, -1846.2044804, 138.1387685)),
176 coord);
177 Assert.assertEquals(0.0001891633, coord.getClockCorrection(), 1.0e-15);
178 Assert.assertEquals(-0.0004534317, coord.getClockRateChange(), 1.0e-15);
179 }
180
181 @Test
182 public void testParseSP3d1() throws IOException {
183
184 final String ex = "/sp3/example-d-1.sp3";
185 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
186 final SP3 file = new SP3Parser().parse(source);
187
188 Assert.assertEquals(SP3OrbitType.BCT, file.getOrbitType());
189 Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem());
190
191 Assert.assertEquals(140, file.getSatelliteCount());
192
193 final List<SP3Coordinate> coords = file.getSatellites().get("S37").getCoordinates();
194 Assert.assertEquals(2, coords.size());
195
196 final SP3Coordinate coord = coords.get(0);
197
198
199 Assert.assertEquals(new AbsoluteDate(2013, 4, 3, 0, 0, 0,
200 TimeScalesFactory.getGPS()), coord.getDate());
201
202
203 checkPVEntry(new PVCoordinates(new Vector3D(-34534904.566, 24164610.955, 29812.840),
204 Vector3D.ZERO),
205 coord);
206 Assert.assertEquals(0.00000029942, coord.getClockCorrection(), 1.0e-15);
207 }
208
209 @Test
210 public void testParseSP3d2() throws IOException {
211
212 final String ex = "/sp3/example-d-2.sp3";
213 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
214 final SP3 file = new SP3Parser().parse(source);
215
216 Assert.assertEquals(SP3OrbitType.HLM, file.getOrbitType());
217 Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem());
218
219 Assert.assertEquals(26, file.getSatelliteCount());
220
221 final List<SP3Coordinate> coords = file.getSatellites().get("G01").getCoordinates();
222 Assert.assertEquals(2, coords.size());
223
224 final SP3Coordinate coord = coords.get(0);
225
226
227 Assert.assertEquals(new AbsoluteDate(2001, 8, 8, 0, 0, 0,
228 TimeScalesFactory.getGPS()), coord.getDate());
229
230
231
232 checkPVEntry(new PVCoordinates(new Vector3D(-11044805.8, -10475672.35, 21929418.2),
233 new Vector3D(2029.8880364, -1846.2044804, 138.1387685)),
234 coord);
235 Assert.assertEquals(0.0001891633, coord.getClockCorrection(), 1.0e-15);
236 Assert.assertEquals(-0.0004534317, coord.getClockRateChange(), 1.0e-15);
237 }
238
239 @Test
240 public void testSP3GFZ() throws IOException {
241
242 final String ex = "/sp3/gbm19500_truncated.sp3";
243 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
244 final SP3 file = new SP3Parser().parse(source);
245
246 Assert.assertEquals(SP3OrbitType.FIT, file.getOrbitType());
247 Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem());
248
249 Assert.assertEquals(87, file.getSatelliteCount());
250
251 final List<SP3Coordinate> coords = file.getSatellites().get("R23").getCoordinates();
252 Assert.assertEquals(2, coords.size());
253
254 final SP3Coordinate coord = coords.get(0);
255
256 Assert.assertEquals(new AbsoluteDate(2017, 5, 21, 0, 0, 0,
257 TimeScalesFactory.getGPS()), coord.getDate());
258
259
260
261 checkPVEntry(new PVCoordinates(new Vector3D(24552470.459, -242899.447, 6925437.998),
262 Vector3D.ZERO),
263 coord);
264 Assert.assertEquals(0.000086875825, coord.getClockCorrection(), 1.0e-15);
265 }
266
267 @Test
268 public void testSP3Propagator() throws Exception {
269
270 final String ex = "/sp3/example-a-2.sp3";
271 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
272 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
273 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
274
275
276 final SP3 file = parser.parse(source);
277
278
279 TimeScale gps = TimeScalesFactory.getGPS();
280 SP3Ephemeris ephemeris = file.getSatellites().get("1");
281 BoundedPropagator propagator = ephemeris.getPropagator();
282 Assert.assertEquals(propagator.getMinDate(), new AbsoluteDate(1994, 12, 17, gps));
283 Assert.assertEquals(propagator.getMaxDate(), new AbsoluteDate(1994, 12, 17, 23, 45, 0, gps));
284 SP3Coordinate expected = ephemeris.getCoordinates().get(0);
285 checkPVEntry(
286 propagator.getPVCoordinates(propagator.getMinDate(), frame),
287 expected);
288 expected = ephemeris.getCoordinates().get(1);
289 checkPVEntry(propagator.getPVCoordinates(expected.getDate(), frame), expected);
290 expected = ephemeris.getCoordinates().get(2);
291 checkPVEntry(
292 propagator.getPVCoordinates(propagator.getMaxDate(), frame),
293 expected);
294
295 ephemeris = file.getSatellites().get("31");
296 propagator = ephemeris.getPropagator();
297 Assert.assertEquals(propagator.getMinDate(), new AbsoluteDate(1994, 12, 17, gps));
298 Assert.assertEquals(propagator.getMaxDate(), new AbsoluteDate(1994, 12, 17, 23, 45, 0, gps));
299 expected = ephemeris.getCoordinates().get(0);
300 checkPVEntry(
301 propagator.propagate(propagator.getMinDate()).getPVCoordinates(frame),
302 expected);
303 expected = ephemeris.getCoordinates().get(1);
304 checkPVEntry(propagator.propagate(expected.getDate()).getPVCoordinates(frame), expected);
305 expected = ephemeris.getCoordinates().get(2);
306 checkPVEntry(
307 propagator.propagate(propagator.getMaxDate()).getPVCoordinates(frame),
308 expected);
309 }
310
311 @Test
312 public void testSP3Compressed() throws IOException {
313 final String ex = "/sp3/gbm18432.sp3.Z";
314
315 final SP3Parser parser = new SP3Parser();
316 final DataSource compressed = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
317 final SP3 file = parser.parse(new UnixCompressFilter().filter(compressed));
318
319 Assert.assertEquals(SP3OrbitType.FIT, file.getOrbitType());
320 Assert.assertEquals("FIT",file.getOrbitTypeKey());
321 Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem());
322
323 Assert.assertEquals(71, file.getSatelliteCount());
324
325 final List<SP3Coordinate> coords = file.getSatellites().get("R13").getCoordinates();
326 Assert.assertEquals(288, coords.size());
327
328 final SP3Coordinate coord = coords.get(228);
329
330
331 Assert.assertEquals(new AbsoluteDate(2015, 5, 5, 19, 0, 0,
332 TimeScalesFactory.getGPS()), coord.getDate());
333
334
335 checkPVEntry(new PVCoordinates(new Vector3D(25330290.321, -411728.000, 2953331.527),
336 Vector3D.ZERO),
337 coord);
338 Assert.assertEquals(-0.000482447619, coord.getClockCorrection(), 1.0e-15);
339 }
340
341 private void checkPVEntry(final PVCoordinates expected, final PVCoordinates actual) {
342 final Vector3D expectedPos = expected.getPosition();
343 final Vector3D expectedVel = expected.getVelocity();
344
345 final Vector3D actualPos = actual.getPosition();
346 final Vector3D actualVel = actual.getVelocity();
347
348
349 final double eps = 1e-3;
350
351 Assert.assertEquals(expectedPos.getX(), actualPos.getX(), eps);
352 Assert.assertEquals(expectedPos.getY(), actualPos.getY(), eps);
353 Assert.assertEquals(expectedPos.getZ(), actualPos.getZ(), eps);
354
355 Assert.assertEquals(expectedVel.getX(), actualVel.getX(), eps);
356 Assert.assertEquals(expectedVel.getY(), actualVel.getY(), eps);
357 Assert.assertEquals(expectedVel.getZ(), actualVel.getZ(), eps);
358
359 Assert.assertEquals(Vector3D.ZERO, actual.getAcceleration());
360 }
361
362 @Test
363 public void testTruncatedLine() throws IOException {
364 try {
365 final String ex = "/sp3/truncated-line.sp3";
366 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
367 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
368 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
369 parser.parse(source);
370 Assert.fail("an exception should have been thrown");
371 } catch (OrekitException oe) {
372 Assert.assertEquals(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE,
373 oe.getSpecifier());
374 Assert.assertEquals(27, ((Integer) oe.getParts()[0]).intValue());
375 }
376
377 }
378
379 @Test
380 public void testMissingEOF() throws IOException {
381 try {
382 final String ex = "/sp3/missing-eof.sp3";
383 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
384 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
385 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
386 parser.parse(source);
387 Assert.fail("an exception should have been thrown");
388 } catch (OrekitException oe) {
389 Assert.assertEquals(OrekitMessages.SP3_UNEXPECTED_END_OF_FILE,
390 oe.getSpecifier());
391 Assert.assertEquals(24, ((Integer) oe.getParts()[0]).intValue());
392 }
393
394 }
395
396 @Test
397 public void testWrongLineIdentifier() throws IOException {
398 try {
399 final String ex = "/sp3/wrong-line-identifier.sp3";
400 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
401 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
402 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
403 parser.parse(source);
404 Assert.fail("an exception should have been thrown");
405 } catch (OrekitException oe) {
406 Assert.assertEquals(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE,
407 oe.getSpecifier());
408 Assert.assertEquals(13, ((Integer) oe.getParts()[0]).intValue());
409 }
410
411 }
412
413 @Test
414 public void testBHN() throws IOException {
415 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
416 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
417 final String ex = "/sp3/esaBHN.sp3.Z";
418 final DataSource compressed = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
419 final DataSource uncompressed = new UnixCompressFilter().filter(compressed);
420 final SP3 file = parser.parse(uncompressed);
421 Assert.assertEquals(SP3OrbitType.FIT, file.getOrbitType());
422 Assert.assertEquals("BHN",file.getOrbitTypeKey());
423 }
424
425 @Test
426 public void testPRO() throws IOException {
427 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
428 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
429 final String ex = "/sp3/esaPRO.sp3.Z";
430 final DataSource compressed = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
431 final DataSource uncompressed = new UnixCompressFilter().filter(compressed);
432 final SP3 file = parser.parse(uncompressed);
433 Assert.assertEquals(SP3OrbitType.EXT, file.getOrbitType());
434 Assert.assertEquals("PRO",file.getOrbitTypeKey());
435 }
436
437 @Test
438 public void testUnknownType() throws IOException {
439 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
440 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
441 final String ex = "/sp3/unknownType.sp3.Z";
442 final DataSource compressed = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
443 final DataSource uncompressed = new UnixCompressFilter().filter(compressed);
444 final SP3 file = parser.parse(uncompressed);
445 Assert.assertEquals(SP3OrbitType.OTHER, file.getOrbitType());
446 Assert.assertEquals("UKN",file.getOrbitTypeKey());
447 }
448
449 @Test
450 public void testUnsupportedVersion() throws IOException {
451 try {
452 final String ex = "/sp3/unsupported-version.sp3";
453 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
454 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
455 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
456 parser.parse(source);
457 Assert.fail("an exception should have been thrown");
458 } catch (OrekitException oe) {
459 Assert.assertEquals(OrekitMessages.SP3_UNSUPPORTED_VERSION,
460 oe.getSpecifier());
461 Assert.assertEquals('z', ((Character) oe.getParts()[0]).charValue());
462 }
463
464 }
465
466 @Test
467 public void testWrongNumberOfEpochs() throws IOException {
468 try {
469 final String ex = "/sp3/wrong-number-of-epochs.sp3";
470 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
471 final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
472 final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
473 parser.parse(source);
474 Assert.fail("an exception should have been thrown");
475 } catch (OrekitException oe) {
476 Assert.assertEquals(OrekitMessages.SP3_NUMBER_OF_EPOCH_MISMATCH,
477 oe.getSpecifier());
478 Assert.assertEquals( 2, ((Integer) oe.getParts()[0]).intValue());
479 Assert.assertEquals(192, ((Integer) oe.getParts()[2]).intValue());
480 }
481
482 }
483
484 @Test
485 public void testIssue803() {
486
487
488 final String ex = "/sp3/truncated-nsgf.orb.lageos2.160305.v35.sp3";
489 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
490 final SP3 file = new SP3Parser().parse(source);
491
492
493 final List<SP3Coordinate> coords = file.getSatellites().get("L52").getCoordinates();
494 Assert.assertEquals(1, coords.size());
495 final SP3Coordinate coord = coords.get(0);
496
497
498 Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
499
500
501
502 checkPVEntry(new PVCoordinates(new Vector3D(2228470.946, 7268265.924, 9581471.543),
503 new Vector3D(-4485.6945000, 2432.1151000, -711.6222800)),
504 coord);
505 Assert.assertEquals(999999.999999, coord.getClockCorrection(), 1.0e-6);
506 Assert.assertEquals(999999.999999, coord.getClockRateChange(), 1.0e-6);
507
508 }
509
510 @Test
511 public void testIssue827() {
512
513
514 final String ex = "/sp3/truncated-nsgf.orb.lageos2.160305.v35.sp3";
515 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
516 final SP3 file = new SP3Parser().parse(source);
517
518
519 final List<SP3Coordinate> coords = file.getSatellites().get("L52").getCoordinates();
520 Assert.assertEquals(1, coords.size());
521 final SP3Coordinate coord = coords.get(0);
522
523
524 Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
525 Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
526
527
528 Assert.assertEquals(new AbsoluteDate(2016, 2, 28, 0, 0, 0,
529 TimeScalesFactory.getUTC()), coord.getDate());
530
531
532
533
534 checkPVEntry(new PVCoordinates(new Vector3D(2228470.946, 7268265.924, 9581471.543),
535 new Vector3D(-4485.6945000, 2432.1151000, -711.6222800)),
536 coord);
537 Assert.assertEquals(999999.999999, coord.getClockCorrection(), 1.0e-6);
538 Assert.assertEquals(999999.999999, coord.getClockRateChange(), 1.0e-6);
539
540 }
541
542 @Test
543 public void testIssue828() {
544
545
546 final String ex = "/sp3/example-d-3.sp3";
547 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
548 final SP3 file = new SP3Parser().parse(source);
549
550
551 Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
552 Assert.assertEquals(SP3.SP3FileType.IRNSS, file.getType());
553
554 }
555
556 @Test
557 public void testIssue828Bis() {
558
559
560 final String ex = "/sp3/example-d-4.sp3";
561 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
562 final SP3 file = new SP3Parser().parse(source);
563
564
565 Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
566 Assert.assertEquals(SP3.SP3FileType.SBAS, file.getType());
567
568 }
569
570 @Test
571 public void testIssue895HeaderComment() {
572
573
574 final String ex = "/sp3/issue895-header-comment.sp3";
575 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
576 final SP3 file = new SP3Parser().parse(source);
577
578
579 Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
580 Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
581
582 }
583
584 @Test
585 public void testIssue895ClockRecord() {
586
587
588 final String ex = "/sp3/issue895-clock-record.sp3";
589 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
590 final SP3 file = new SP3Parser().parse(source);
591
592
593 Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
594 Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
595 Assert.assertEquals(1, file.getSatelliteCount());
596
597 final List<SP3Coordinate> coords = file.getSatellites().get("L51").getCoordinates();
598 Assert.assertEquals(1, coords.size());
599
600 final SP3Coordinate coord = coords.get(0);
601
602
603 Assert.assertEquals(new AbsoluteDate(2021, 12, 26, 0, 0, 0,
604 TimeScalesFactory.getUTC()), coord.getDate());
605
606
607
608 checkPVEntry(new PVCoordinates(new Vector3D(5029867.893, 1304362.160, -11075527.276),
609 new Vector3D(-1772.0521773, -5572.0482742, -1444.1695083)),
610 coord);
611
612 }
613
614 @Test
615 public void testIssue895RolloverMinutes() {
616
617
618 final String ex = "/sp3/issue895-minutes-increment.sp3";
619 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
620 final SP3 file = new SP3Parser().parse(source);
621
622
623 Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
624 Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
625 Assert.assertEquals(1, file.getSatelliteCount());
626
627 final List<SP3Coordinate> coords = file.getSatellites().get("L51").getCoordinates();
628 Assert.assertEquals(91, coords.size());
629
630 final SP3Coordinate coord30 = coords.get(30);
631
632
633 Assert.assertEquals(new AbsoluteDate(2016, 7, 6, 17, 0, 0,
634 TimeScalesFactory.getUTC()), coord30.getDate());
635
636
637
638 checkPVEntry(new PVCoordinates(new Vector3D(11948228.978, 2986113.872, -538901.114),
639 new Vector3D(460.5419303, -2797.2588048, -5331.6820671)),
640 coord30);
641
642 final SP3Coordinate coord31 = coords.get(31);
643
644
645 Assert.assertEquals(new AbsoluteDate(2016, 7, 6, 17, 2, 0,
646 TimeScalesFactory.getUTC()), coord31.getDate());
647
648
649
650 checkPVEntry(new PVCoordinates(new Vector3D(11982652.569, 2645786.926, -1177549.463),
651 new Vector3D(112.8248622, -2872.4293303, -5309.7358387)),
652 coord31);
653
654 final SP3Coordinate coord60 = coords.get(60);
655
656
657 Assert.assertEquals(new AbsoluteDate(2016, 7, 6, 18, 0, 0,
658 TimeScalesFactory.getUTC()), coord60.getDate());
659
660
661
662 checkPVEntry(new PVCoordinates(new Vector3D(-1693056.569, -4123276.630, -11431599.723),
663 new Vector3D(-5941.2268951, 406.6817074, 760.4890337)),
664 coord60);
665
666 }
667
668 @Test
669 public void testIssue895RolloverHours() {
670
671
672 final String ex = "/sp3/issue895-hours-increment.sp3";
673 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
674 final SP3 file = new SP3Parser().parse(source);
675
676
677 Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
678 Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
679 Assert.assertEquals(1, file.getSatelliteCount());
680
681 final List<SP3Coordinate> coords = file.getSatellites().get("L51").getCoordinates();
682 Assert.assertEquals(61, coords.size());
683
684 final SP3Coordinate coord30 = coords.get(30);
685
686
687 Assert.assertEquals(new AbsoluteDate(2016, 7, 7, 0, 0, 0,
688 TimeScalesFactory.getUTC()), coord30.getDate());
689
690
691
692 checkPVEntry(new PVCoordinates(new Vector3D(2989229.334, -8494421.415, 8385068.555),
693 new Vector3D(-1961.7027447, -4344.4824985, -3670.6159070)),
694 coord30);
695
696 final SP3Coordinate coord31 = coords.get(31);
697
698
699 Assert.assertEquals(new AbsoluteDate(2016, 7, 7, 0, 2, 0,
700 TimeScalesFactory.getUTC()), coord31.getDate());
701
702
703
704 checkPVEntry(new PVCoordinates(new Vector3D(2744983.592, -9000639.164, 7931904.779),
705 new Vector3D(-2107.2925764, -4089.9633288, -3880.1567078)),
706 coord31);
707
708 }
709
710 @Test
711 public void testIssue895SecondDigits() {
712
713
714 final String ex = "/sp3/issue895-second-digits.sp3";
715 final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
716 final SP3 file = new SP3Parser().parse(source);
717
718
719 Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
720 Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
721 Assert.assertEquals(1, file.getSatelliteCount());
722
723 final List<SP3Coordinate> coords = file.getSatellites().get("L51").getCoordinates();
724 Assert.assertEquals(1, coords.size());
725
726 final SP3Coordinate coord = coords.get(0);
727
728
729 Assert.assertEquals(new AbsoluteDate(2016, 7, 3, 0, 0, 0.1234,
730 TimeScalesFactory.getUTC()), coord.getDate());
731
732 }
733
734 @Before
735 public void setUp() {
736 Utils.setDataRoot("regular-data");
737 }
738 }