1   /* Copyright 2002-2012 Space Applications Services
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
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          // simple test for version sp3-a, only contains position entries
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          // 1994 12 17 0 0 0.00000000
70          Assert.assertEquals(new AbsoluteDate(1994, 12, 17, 0, 0, 0,
71                  TimeScalesFactory.getGPS()), coord.getDate());
72  
73          // P 1 16258.524750 -3529.015750 -20611.427050 -62.540600
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          // simple test for version sp3-a, contains p/v entries
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         // 1994 12 17 0 0 0.00000000
111         Assert.assertEquals(new AbsoluteDate(1994, 12, 17, 0, 0, 0,
112                 TimeScalesFactory.getGPS()), coord.getDate());
113 
114         // P 1 16258.524750 -3529.015750 -20611.427050 -62.540600
115         // V 1  -6560.373522  25605.954994  -9460.427179     -0.024236
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         // simple test for version sp3-c, contains p entries
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         // 2001  8  8  0  0  0.00000000
141         Assert.assertEquals(new AbsoluteDate(2001, 8, 8, 0, 0, 0,
142                 TimeScalesFactory.getGPS()), coord.getDate());
143 
144         // PG01 -11044.805800 -10475.672350  21929.418200    189.163300 18 18 18 219
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         // simple test for version sp3-c, contains p/v entries and correlations
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         // 2001  8  8  0  0  0.00000000
169         Assert.assertEquals(new AbsoluteDate(2001, 8, 8, 0, 0, 0,
170                 TimeScalesFactory.getGPS()), coord.getDate());
171 
172         // PG01 -11044.805800 -10475.672350  21929.418200    189.163300 18 18 18 219
173         // VG01  20298.880364 -18462.044804   1381.387685     -4.534317 14 14 14 191
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         // simple test for version sp3-d, contains p entries
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         // 2013  4  3  0  0  0.00000000
199         Assert.assertEquals(new AbsoluteDate(2013, 4, 3, 0, 0, 0,
200                 TimeScalesFactory.getGPS()), coord.getDate());
201 
202         // PS37 -34534.904566  24164.610955     29.812840      0.299420
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         // simple test for version sp3-c, contains p/v entries and correlations
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         // 2001  8  8  0  0  0.00000000
227         Assert.assertEquals(new AbsoluteDate(2001, 8, 8, 0, 0, 0,
228                 TimeScalesFactory.getGPS()), coord.getDate());
229 
230         // PG01 -11044.805800 -10475.672350  21929.418200    189.163300 18 18 18 219
231         // VG01  20298.880364 -18462.044804   1381.387685     -4.534317 14 14 14 191
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         // simple test for version sp3-c, contains more than 85 satellites
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         // PG01 -11044.805800 -10475.672350  21929.418200    189.163300 18 18 18 219
260         // PR23  24552.470459   -242.899447   6925.437998     86.875825                    
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         // setup
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         // action
276         final SP3 file = parser.parse(source);
277 
278         // verify
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         // PR13  25330.290321   -411.728000   2953.331527   -482.447619
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         // sp3 files can have mm accuracy
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         // Test issue 803 (see https://gitlab.orekit.org/orekit/orekit/-/issues/803)
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         // Coordinates
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         // Verify
498         Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
499 
500         // PL52   2228.470946   7268.265924   9581.471543
501         // VL52 -44856.945000  24321.151000  -7116.222800
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         // Test issue 827 (see https://gitlab.orekit.org/orekit/orekit/-/issues/827)
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         // Coordinates
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         // Verify
524         Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
525         Assert.assertEquals(SP3.SP3FileType.LEO, file.getType());
526 
527         // 2016  2 28 0 0 0.00000000
528         Assert.assertEquals(new AbsoluteDate(2016, 2, 28, 0, 0, 0,
529                 TimeScalesFactory.getUTC()), coord.getDate());
530 
531 
532         // PL52   2228.470946   7268.265924   9581.471543
533         // VL52 -44856.945000  24321.151000  -7116.222800
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         // Test issue 828 (see https://gitlab.orekit.org/orekit/orekit/-/issues/828)
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         // Verify
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         // Test issue 828 (see https://gitlab.orekit.org/orekit/orekit/-/issues/828)
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         // Verify
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         // Test issue 895
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         // Verify
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         // Test issue 895
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         // Verify
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         // 2021 12 26  0  0  0.00000000
603         Assert.assertEquals(new AbsoluteDate(2021, 12, 26, 0, 0, 0,
604                 TimeScalesFactory.getUTC()), coord.getDate());
605 
606         // PL51   5029.867893   1304.362160 -11075.527276 999999.999999
607         // VL51 -17720.521773 -55720.482742 -14441.695083 999999.999999
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         // Test issue 895
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         // Verify
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         // 2016  7  6 16 60  0.00000000
633         Assert.assertEquals(new AbsoluteDate(2016, 7, 6, 17, 0, 0,
634                 TimeScalesFactory.getUTC()), coord30.getDate());
635 
636         // PL51  11948.228978   2986.113872   -538.901114 999999.999999
637         // VL51   4605.419303 -27972.588048 -53316.820671 999999.999999
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         // 2016  7  6 17  2  0.00000000
645         Assert.assertEquals(new AbsoluteDate(2016, 7, 6, 17, 2, 0,
646                 TimeScalesFactory.getUTC()), coord31.getDate());
647 
648         // PL51  11982.652569   2645.786926  -1177.549463 999999.999999
649         // VL51   1128.248622 -28724.293303 -53097.358387 999999.999999
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         // 2016  7  6 17 60  0.00000000
657         Assert.assertEquals(new AbsoluteDate(2016, 7, 6, 18, 0, 0,
658                 TimeScalesFactory.getUTC()), coord60.getDate());
659 
660         // PL51  -1693.056569  -4123.276630 -11431.599723 999999.999999
661         // VL51 -59412.268951   4066.817074   7604.890337 999999.999999
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         // Test issue 895
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         // Verify
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         // 2016  7  7 24  0  0.00000000
687         Assert.assertEquals(new AbsoluteDate(2016, 7, 7, 0, 0, 0,
688                 TimeScalesFactory.getUTC()), coord30.getDate());
689 
690         //PL51   2989.229334  -8494.421415   8385.068555
691         //VL51 -19617.027447 -43444.824985 -36706.159070
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         // 2016  7  7  0  2  0.00000000
699         Assert.assertEquals(new AbsoluteDate(2016, 7, 7, 0, 2, 0,
700                 TimeScalesFactory.getUTC()), coord31.getDate());
701 
702         // PL51   2744.983592  -9000.639164   7931.904779
703         // VL51 -21072.925764 -40899.633288 -38801.567078
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         // Test issue 895
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         // Verify
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         // 2016  7  3  0  0  0.1234
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 }