1   /* Copyright 2002-2025 CS GROUP
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.utils;
18  
19  import org.junit.jupiter.api.Assertions;
20  import org.junit.jupiter.api.Test;
21  import org.orekit.Utils;
22  import org.orekit.bodies.GeodeticPoint;
23  import org.orekit.bodies.TimeStampedGeodeticPoint;
24  import org.orekit.time.AbsoluteDate;
25  
26  class TimeStampedGeodeticPointTest {
27  
28      @Test
29      void testEquals() {
30          final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
31          final TimeStampedGeodeticPoint geo = new TimeStampedGeodeticPoint(date, 1.0, 2.0, 3.0);
32          Assertions.assertEquals(geo, new TimeStampedGeodeticPoint(geo.getDate(), geo.getLatitude(), geo.getLongitude(), geo.getAltitude()));
33          Assertions.assertNotEquals(geo, date);
34          Assertions.assertNotEquals(geo, new TimeStampedGeodeticPoint(geo.getDate().shiftedBy(1), geo.getLatitude(), geo.getLongitude(), geo.getAltitude()));
35      }
36  
37      @Test
38      void testFullConstructor() {
39          final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
40          final TimeStampedGeodeticPoint geo = new TimeStampedGeodeticPoint(date, 1.0, 2.0, 3.0);
41          Assertions.assertEquals(date, geo.getDate());
42          Assertions.assertEquals(1.0, geo.getLatitude());
43          Assertions.assertEquals(2.0, geo.getLongitude());
44          Assertions.assertEquals(3.0, geo.getAltitude());
45      }
46  
47      @Test
48      void testGeodeticPointConstructor() {
49          final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
50          final GeodeticPoint geo = new GeodeticPoint(1.0, 2.0, 3.0);
51          final TimeStampedGeodeticPoint timedGeo = new TimeStampedGeodeticPoint(date, geo);
52          Assertions.assertEquals(date, timedGeo.getDate());
53          Assertions.assertEquals(geo.getLatitude(), timedGeo.getLatitude());
54          Assertions.assertEquals(geo.getLongitude(), timedGeo.getLongitude());
55          Assertions.assertEquals(geo.getAltitude(), timedGeo.getAltitude());
56      }
57  
58      @Test
59      void testShiftedBy() {
60          final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
61          final GeodeticPoint geo = new GeodeticPoint(1.0, 2.0, 3.0);
62          final TimeStampedGeodeticPoint timedGeo = new TimeStampedGeodeticPoint(date, geo);
63  
64          // Shift point in time
65          final double dt = 3600;
66          final AbsoluteDate newDate = date.shiftedBy(dt);
67          final TimeStampedGeodeticPoint timedGeoShifted = timedGeo.shiftedBy(dt);
68  
69          // Check that shifted point has not moved but date has been updated
70          Assertions.assertEquals(newDate, timedGeoShifted.getDate());
71          Assertions.assertEquals(geo.getLatitude(), timedGeoShifted.getLatitude());
72          Assertions.assertEquals(geo.getLongitude(), timedGeoShifted.getLongitude());
73          Assertions.assertEquals(geo.getAltitude(), timedGeoShifted.getAltitude());
74      }
75  
76      @Test
77      void testToString() {
78          Utils.setDataRoot("regular-data");
79          final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
80          final TimeStampedGeodeticPoint geo = new TimeStampedGeodeticPoint(date, 1.0, 2.0, 3.0);
81          Assertions.assertEquals("{date: 2000-01-01T11:58:55.816Z, lat: 57.29577951308232 deg, lon: 114.59155902616465 deg, alt: 3.0}", geo.toString());
82      }
83  }