1   /* Copyright 2022-2025 Romain Serra
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.bodies;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.hipparchus.Field;
21  import org.orekit.time.FieldAbsoluteDate;
22  import org.orekit.time.FieldTimeStamped;
23  
24  /**
25   * Implements a time-stamped {@link FieldGeodeticPoint}.
26   * @author Romain Serra
27   * @since 13.1
28   */
29  public class FieldTimeStampedGeodeticPoint<T extends CalculusFieldElement<T>> extends FieldGeodeticPoint<T>
30          implements FieldTimeStamped<T> {
31      /**
32       * Date at which the {@link FieldGeodeticPoint} is set.
33       */
34      private final FieldAbsoluteDate<T> date;
35  
36      /**
37       * Build a new instance from geodetic coordinates.
38       *
39       * @param date      date of the point
40       * @param latitude  geodetic latitude (rad)
41       * @param longitude geodetic longitude (rad)
42       * @param altitude  altitude above ellipsoid (m)
43       */
44      public FieldTimeStampedGeodeticPoint(final FieldAbsoluteDate<T> date, final T latitude, final T longitude,
45                                           final T altitude) {
46          super(latitude, longitude, altitude);
47          this.date = date;
48      }
49  
50      /**
51       * Build a new instance from a {@link FieldGeodeticPoint}.
52       *
53       * @param date      date of the point
54       * @param point     geodetic point
55       */
56      public FieldTimeStampedGeodeticPoint(final FieldAbsoluteDate<T> date, final FieldGeodeticPoint<T> point) {
57          this(date, point.getLatitude(), point.getLongitude(), point.getAltitude());
58      }
59  
60      /**
61       * Build a new instance from a {@link TimeStampedGeodeticPoint}.
62       *
63       * @param field field
64       * @param timeStampedGeodeticPoint non-Field point
65       */
66      public FieldTimeStampedGeodeticPoint(final Field<T> field, final TimeStampedGeodeticPoint timeStampedGeodeticPoint) {
67          this(new FieldAbsoluteDate<>(field, timeStampedGeodeticPoint.getDate()), new FieldGeodeticPoint<>(field, timeStampedGeodeticPoint));
68      }
69  
70      @Override
71      @SuppressWarnings("unchecked")
72      public boolean equals(final Object object) {
73          if (object instanceof FieldTimeStampedGeodeticPoint<?>) {
74              final FieldTimeStampedGeodeticPoint<T> other = (FieldTimeStampedGeodeticPoint<T>) object;
75              return other.date.isEqualTo(date) && super.equals(other);
76          } else {
77              return false;
78          }
79      }
80  
81      @Override
82      public int hashCode() {
83          return date.hashCode() + super.hashCode();
84      }
85  
86      @Override
87      public FieldAbsoluteDate<T> getDate() {
88          return date;
89      }
90  }