TimeStampedGeodeticPoint.java

  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.bodies;

  18. import org.hipparchus.util.FastMath;
  19. import org.orekit.time.AbsoluteDate;
  20. import org.orekit.time.TimeShiftable;
  21. import org.orekit.time.TimeStamped;

  22. /**
  23.  * Implements a time-stamped {@link GeodeticPoint}.
  24.  * @author Jérôme Tabeaud
  25.  * @since 13.1
  26.  */
  27. public class TimeStampedGeodeticPoint extends GeodeticPoint implements TimeStamped, TimeShiftable<TimeStampedGeodeticPoint> {
  28.     /**
  29.      * Date at which the {@link GeodeticPoint} is set.
  30.      */
  31.     private final AbsoluteDate date;

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

  45.     /**
  46.      * Build a new instance from a {@link GeodeticPoint}.
  47.      *
  48.      * @param date      date of the point
  49.      * @param point     geodetic point
  50.      */
  51.     public TimeStampedGeodeticPoint(final AbsoluteDate date, final GeodeticPoint point) {
  52.         this(date, point.getLatitude(), point.getLongitude(), point.getAltitude());
  53.     }

  54.     @Override
  55.     public AbsoluteDate getDate() {
  56.         return date;
  57.     }

  58.     @Override
  59.     public String toString() {
  60.         return "{" +
  61.                 "date: " + date +
  62.                 ", lat: " + FastMath.toDegrees(getLatitude()) +
  63.                 " deg, lon: " + FastMath.toDegrees(getLongitude()) +
  64.                 " deg, alt: " + getAltitude() +
  65.                 "}";
  66.     }

  67.     @Override
  68.     public boolean equals(final Object object) {
  69.         if (object instanceof TimeStampedGeodeticPoint) {
  70.             final TimeStampedGeodeticPoint other = (TimeStampedGeodeticPoint) object;
  71.             return other.date.isEqualTo(date) && super.equals(other);
  72.         } else {
  73.             return false;
  74.         }
  75.     }

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

  80.     @Override
  81.     public TimeStampedGeodeticPoint shiftedBy(final double dt) {
  82.         return new TimeStampedGeodeticPoint(date.shiftedBy(dt), getLatitude(), getLongitude(), getAltitude());
  83.     }
  84. }