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
19 import org.hipparchus.util.FastMath;
20 import org.orekit.time.AbsoluteDate;
21 import org.orekit.time.TimeShiftable;
22 import org.orekit.time.TimeStamped;
23
24 /**
25 * Implements a time-stamped {@link GeodeticPoint}.
26 * @author Jérôme Tabeaud
27 * @since 13.1
28 */
29 public class TimeStampedGeodeticPoint extends GeodeticPoint implements TimeStamped, TimeShiftable<TimeStampedGeodeticPoint> {
30 /**
31 * Date at which the {@link GeodeticPoint} is set.
32 */
33 private final AbsoluteDate date;
34
35 /**
36 * Build a new instance from geodetic coordinates.
37 *
38 * @param date date of the point
39 * @param latitude geodetic latitude (rad)
40 * @param longitude geodetic longitude (rad)
41 * @param altitude altitude above ellipsoid (m)
42 */
43 public TimeStampedGeodeticPoint(final AbsoluteDate date, final double latitude, final double longitude,
44 final double altitude) {
45 super(latitude, longitude, altitude);
46 this.date = date;
47 }
48
49 /**
50 * Build a new instance from a {@link GeodeticPoint}.
51 *
52 * @param date date of the point
53 * @param point geodetic point
54 */
55 public TimeStampedGeodeticPoint(final AbsoluteDate date, final GeodeticPoint point) {
56 this(date, point.getLatitude(), point.getLongitude(), point.getAltitude());
57 }
58
59 @Override
60 public AbsoluteDate getDate() {
61 return date;
62 }
63
64 @Override
65 public String toString() {
66 return "{" +
67 "date: " + date +
68 ", lat: " + FastMath.toDegrees(getLatitude()) +
69 " deg, lon: " + FastMath.toDegrees(getLongitude()) +
70 " deg, alt: " + getAltitude() +
71 "}";
72 }
73
74 @Override
75 public boolean equals(final Object object) {
76 if (object instanceof TimeStampedGeodeticPoint) {
77 final TimeStampedGeodeticPoint other = (TimeStampedGeodeticPoint) object;
78 return other.date.isEqualTo(date) && super.equals(other);
79 } else {
80 return false;
81 }
82 }
83
84 @Override
85 public int hashCode() {
86 return date.hashCode() + super.hashCode();
87 }
88
89 @Override
90 public TimeStampedGeodeticPoint shiftedBy(final double dt) {
91 return new TimeStampedGeodeticPoint(date.shiftedBy(dt), getLatitude(), getLongitude(), getAltitude());
92 }
93 }