1 /* Copyright 2002-2026 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
18 package org.orekit.files.ccsds.ndm.odm.oem;
19
20 import java.util.Optional;
21
22 import org.orekit.annotation.Nullable;
23 import org.orekit.files.ccsds.definitions.CcsdsFrameMapper;
24 import org.orekit.files.ccsds.ndm.odm.OdmCommonMetadata;
25 import org.orekit.frames.Frame;
26 import org.orekit.time.AbsoluteDate;
27
28 /** Metadata for Orbit Ephemeris Messages.
29 * @author Luc Maisonobe
30 * @since 11.0
31 */
32 public class OemMetadata extends OdmCommonMetadata {
33
34 /** Start of total time span covered by ephemerides data and covariance data. */
35 private AbsoluteDate startTime;
36
37 /** End of total time span covered by ephemerides data and covariance data. */
38 private AbsoluteDate stopTime;
39
40 /** Start of useable time span covered by ephemerides data, it may be
41 * necessary to allow for proper interpolation.
42 */
43 @Nullable
44 private AbsoluteDate useableStartTime;
45
46 /** End of useable time span covered by ephemerides data, it may be
47 * necessary to allow for proper interpolation.
48 */
49 @Nullable
50 private AbsoluteDate useableStopTime;
51
52 /** The interpolation method to be used. */
53 @Nullable
54 private InterpolationMethod interpolationMethod;
55
56 /** The interpolation degree. */
57 private int interpolationDegree;
58
59 /**
60 * Simple constructor.
61 *
62 * @param defaultInterpolationDegree default interpolation degree
63 * @param frameMapper for creating a {@link Frame}.
64 * @since 13.1.5
65 */
66 public OemMetadata(final int defaultInterpolationDegree,
67 final CcsdsFrameMapper frameMapper) {
68 super(frameMapper);
69 this.interpolationDegree = defaultInterpolationDegree;
70 }
71
72 /** {@inheritDoc} */
73 @Override
74 public void validate(final double version) {
75 checkMandatoryEntriesExceptDates(version);
76 checkNotNull(startTime, OemMetadataKey.START_TIME.name());
77 checkNotNull(stopTime, OemMetadataKey.STOP_TIME.name());
78 }
79
80 /** Check is mandatory entries EXCEPT DATES have been initialized.
81 * <p>
82 * This method should throw an exception if some mandatory entry is missing
83 * </p>
84 * @param version format version
85 */
86 void checkMandatoryEntriesExceptDates(final double version) {
87 super.validate(version);
88 }
89
90 /** Get start of total time span covered by ephemerides data and
91 * covariance data.
92 * @return the start time
93 */
94 public AbsoluteDate getStartTime() {
95 return startTime;
96 }
97
98 /** Set start of total time span covered by ephemerides data and
99 * covariance data.
100 * @param startTime the time to be set
101 */
102 public void setStartTime(final AbsoluteDate startTime) {
103 refuseFurtherComments();
104 this.startTime = startTime;
105 }
106
107 /** Get end of total time span covered by ephemerides data and covariance
108 * data.
109 * @return the stop time
110 */
111 public AbsoluteDate getStopTime() {
112 return stopTime;
113 }
114
115 /** Set end of total time span covered by ephemerides data and covariance
116 * data.
117 * @param stopTime the time to be set
118 */
119 public void setStopTime(final AbsoluteDate stopTime) {
120 refuseFurtherComments();
121 this.stopTime = stopTime;
122 }
123
124 /** Get start of useable time span covered by ephemerides data, it may be
125 * necessary to allow for proper interpolation.
126 * @return the useable start time
127 */
128 public Optional<AbsoluteDate> getUseableStartTime() {
129 return Optional.ofNullable(useableStartTime);
130 }
131
132 /** Set start of useable time span covered by ephemerides data, it may be
133 * necessary to allow for proper interpolation.
134 * @param useableStartTime the time to be set
135 */
136 public void setUseableStartTime(final AbsoluteDate useableStartTime) {
137 refuseFurtherComments();
138 this.useableStartTime = useableStartTime;
139 }
140
141 /** Get end of useable time span covered by ephemerides data, it may be
142 * necessary to allow for proper interpolation.
143 * @return the useable stop time
144 */
145 public Optional<AbsoluteDate> getUseableStopTime() {
146 return Optional.ofNullable(useableStopTime);
147 }
148
149 /** Set end of useable time span covered by ephemerides data, it may be
150 * necessary to allow for proper interpolation.
151 * @param useableStopTime the time to be set
152 */
153 public void setUseableStopTime(final AbsoluteDate useableStopTime) {
154 refuseFurtherComments();
155 this.useableStopTime = useableStopTime;
156 }
157
158 /** Get the interpolation method to be used.
159 * @return the interpolation method
160 */
161 public Optional<InterpolationMethod> getInterpolationMethod() {
162 return Optional.ofNullable(interpolationMethod);
163 }
164
165 /** Set the interpolation method to be used.
166 * @param interpolationMethod the interpolation method to be set
167 */
168 public void setInterpolationMethod(final InterpolationMethod interpolationMethod) {
169 refuseFurtherComments();
170 this.interpolationMethod = interpolationMethod;
171 }
172
173 /** Get the interpolation degree.
174 * @return the interpolation degree
175 */
176 public int getInterpolationDegree() {
177 return interpolationDegree;
178 }
179
180 /** Set the interpolation degree.
181 * @param interpolationDegree the interpolation degree to be set
182 */
183 public void setInterpolationDegree(final int interpolationDegree) {
184 refuseFurtherComments();
185 this.interpolationDegree = interpolationDegree;
186 }
187
188 /** Copy the instance, making sure mandatory fields have been initialized.
189 * @param version format version
190 * @return a new copy
191 */
192 OemMetadata copy(final double version) {
193
194 checkMandatoryEntriesExceptDates(version);
195
196 // allocate new instance
197 final OemMetadata copy = new OemMetadata(getInterpolationDegree(), getFrameMapper());
198
199 // copy comments
200 for (String comment : getComments()) {
201 copy.addComment(comment);
202 }
203
204 // copy object
205 copy.setObjectName(getObjectName());
206 copy.setObjectID(getObjectID());
207 copy.setCenter(getCenter());
208
209 // copy frames
210 getFrameEpoch().ifPresent(copy::setFrameEpoch);
211 copy.setReferenceFrame(getReferenceFrame());
212
213 // copy time system only (ignore times themselves)
214 copy.setTimeSystem(getTimeSystem());
215
216 // copy interpolation (degree has already been set up at construction)
217 getInterpolationMethod().ifPresent(copy::setInterpolationMethod);
218
219 return copy;
220
221 }
222
223 }
224
225
226