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