FieldTimeStampedGeodeticPoint.java

  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. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;
  20. import org.orekit.time.FieldAbsoluteDate;
  21. import org.orekit.time.FieldTimeStamped;

  22. /**
  23.  * Implements a time-stamped {@link FieldGeodeticPoint}.
  24.  * @author Romain Serra
  25.  * @since 13.1
  26.  */
  27. public class FieldTimeStampedGeodeticPoint<T extends CalculusFieldElement<T>> extends FieldGeodeticPoint<T>
  28.         implements FieldTimeStamped<T> {
  29.     /**
  30.      * Date at which the {@link FieldGeodeticPoint} is set.
  31.      */
  32.     private final FieldAbsoluteDate<T> date;

  33.     /**
  34.      * Build a new instance from geodetic coordinates.
  35.      *
  36.      * @param date      date of the point
  37.      * @param latitude  geodetic latitude (rad)
  38.      * @param longitude geodetic longitude (rad)
  39.      * @param altitude  altitude above ellipsoid (m)
  40.      */
  41.     public FieldTimeStampedGeodeticPoint(final FieldAbsoluteDate<T> date, final T latitude, final T longitude,
  42.                                          final T altitude) {
  43.         super(latitude, longitude, altitude);
  44.         this.date = date;
  45.     }

  46.     /**
  47.      * Build a new instance from a {@link FieldGeodeticPoint}.
  48.      *
  49.      * @param date      date of the point
  50.      * @param point     geodetic point
  51.      */
  52.     public FieldTimeStampedGeodeticPoint(final FieldAbsoluteDate<T> date, final FieldGeodeticPoint<T> point) {
  53.         this(date, point.getLatitude(), point.getLongitude(), point.getAltitude());
  54.     }

  55.     /**
  56.      * Build a new instance from a {@link TimeStampedGeodeticPoint}.
  57.      *
  58.      * @param field field
  59.      * @param timeStampedGeodeticPoint non-Field point
  60.      */
  61.     public FieldTimeStampedGeodeticPoint(final Field<T> field, final TimeStampedGeodeticPoint timeStampedGeodeticPoint) {
  62.         this(new FieldAbsoluteDate<>(field, timeStampedGeodeticPoint.getDate()), new FieldGeodeticPoint<>(field, timeStampedGeodeticPoint));
  63.     }

  64.     @Override
  65.     @SuppressWarnings("unchecked")
  66.     public boolean equals(final Object object) {
  67.         if (object instanceof FieldTimeStampedGeodeticPoint<?>) {
  68.             final FieldTimeStampedGeodeticPoint<T> other = (FieldTimeStampedGeodeticPoint<T>) object;
  69.             return other.date.isEqualTo(date) && super.equals(other);
  70.         } else {
  71.             return false;
  72.         }
  73.     }

  74.     @Override
  75.     public int hashCode() {
  76.         return date.hashCode() + super.hashCode();
  77.     }

  78.     @Override
  79.     public FieldAbsoluteDate<T> getDate() {
  80.         return date;
  81.     }
  82. }