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;
19
20 import org.orekit.files.ccsds.definitions.BodyFacade;
21 import org.orekit.files.ccsds.definitions.CcsdsFrameMapper;
22 import org.orekit.files.ccsds.definitions.FrameFacade;
23 import org.orekit.files.ccsds.utils.ContextBinding;
24 import org.orekit.frames.Frame;
25 import org.orekit.time.AbsoluteDate;
26
27 /** Common metadata for Orbit Parameter/Ephemeris/Mean Messages.
28 * @author Luc Maisonobe
29 * @since 11.0
30 */
31 public class OdmCommonMetadata extends OdmMetadata {
32
33 /** Object identifier of the object for which the orbit state is provided. */
34 private String objectID;
35
36 /** Origin of reference frame. */
37 private BodyFacade center;
38
39 /** Reference frame in which data are given: used for state vector
40 * and Keplerian elements data (and for the covariance reference frame if none is given). */
41 private FrameFacade referenceFrame;
42
43 /** Epoch of reference frame, if not intrinsic to the definition of the
44 * reference frame. */
45 private String frameEpochString;
46
47 /** Epoch of reference frame, if not intrinsic to the definition of the
48 * reference frame. */
49 private AbsoluteDate frameEpoch;
50
51 /**
52 * Complete constructor.
53 *
54 * @param frameMapper for creating an Orekit {@link Frame}.
55 * @since 13.1.5
56 */
57 public OdmCommonMetadata(final CcsdsFrameMapper frameMapper) {
58 super(null, frameMapper);
59 }
60
61 /** {@inheritDoc} */
62 @Override
63 public void validate(final double version) {
64 super.validate(version);
65 checkNotNull(getObjectName(), OdmMetadataKey.OBJECT_NAME.name());
66 checkNotNull(objectID, CommonMetadataKey.OBJECT_ID.name());
67 checkNotNull(center, CommonMetadataKey.CENTER_NAME.name());
68 checkNotNull(referenceFrame, CommonMetadataKey.REF_FRAME.name());
69 }
70
71 /** Finalize the metadata.
72 * <p>
73 * ODM standard enforces {@code TIME_SYSTEM} to appear *after*
74 * {@code REF_FRAME_EPOCH}, despite it is needed to interpret it.
75 * We have to wait until parsing end to finalize this date.
76 * </p>
77 * @param context context binding
78 */
79 public void finalizeMetadata(final ContextBinding context) {
80 if (frameEpochString != null) {
81 frameEpoch = context.getTimeSystem().getConverter(context).parse(frameEpochString);
82 }
83 }
84
85 /** Get the spacecraft ID for which the orbit state is provided.
86 * @return the spacecraft ID
87 */
88 public String getObjectID() {
89 return objectID;
90 }
91
92 /** Set the spacecraft ID for which the orbit state is provided.
93 * @param objectID the spacecraft ID to be set
94 */
95 public void setObjectID(final String objectID) {
96 refuseFurtherComments();
97 this.objectID = objectID;
98 }
99
100 /** Get the launch year.
101 * @return launch year
102 */
103 public int getLaunchYear() {
104 return getLaunchYear(objectID);
105 }
106
107 /** Get the launch number.
108 * @return launch number
109 */
110 public int getLaunchNumber() {
111 return getLaunchNumber(objectID);
112 }
113
114 /** Get the piece of launch.
115 * @return piece of launch
116 */
117 public String getLaunchPiece() {
118 return getLaunchPiece(objectID);
119 }
120
121 /** Get the origin of reference frame.
122 * @return the origin of reference frame.
123 */
124 public BodyFacade getCenter() {
125 return center;
126 }
127
128 /** Set the origin of reference frame.
129 * @param center origin of reference frame to be set
130 */
131 public void setCenter(final BodyFacade center) {
132 refuseFurtherComments();
133 this.center = center;
134 }
135
136 /**
137 * Get the reference frame in which data are given: used for state vector and
138 * Keplerian elements data (and for the covariance reference frame if none is given).
139 *
140 * @return the reference frame
141 * @see #getFrameMapper()
142 */
143 public Frame getFrame() {
144 return getFrameMapper().buildCcsdsFrame(
145 getCenter(),
146 getReferenceFrame(),
147 getFrameEpoch());
148 }
149
150 /**
151 * Get the value of {@code REF_FRAME} as an Orekit {@link Frame}. The {@code
152 * CENTER_NAME} key word has not been applied yet, so the returned frame may not
153 * correspond to the reference frame of the data in the file.
154 *
155 * @return The reference frame specified by the {@code REF_FRAME} keyword.
156 * @see #getFrame()
157 */
158 public FrameFacade getReferenceFrame() {
159 return referenceFrame;
160 }
161
162 /** Set the reference frame in which data are given: used for state vector
163 * and Keplerian elements data (and for the covariance reference frame if none is given).
164 * @param referenceFrame the reference frame to be set
165 */
166 public void setReferenceFrame(final FrameFacade referenceFrame) {
167 refuseFurtherComments();
168 this.referenceFrame = referenceFrame;
169 }
170
171 /** Set epoch of reference frame, if not intrinsic to the definition of the
172 * reference frame.
173 * @param frameEpochString the epoch of reference frame to be set
174 */
175 public void setFrameEpochString(final String frameEpochString) {
176 refuseFurtherComments();
177 this.frameEpochString = frameEpochString;
178 }
179
180 /** Get epoch of reference frame, if not intrinsic to the definition of the
181 * reference frame.
182 * @return epoch of reference frame
183 */
184 public AbsoluteDate getFrameEpoch() {
185 return frameEpoch;
186 }
187
188 /** Set epoch of reference frame, if not intrinsic to the definition of the
189 * reference frame.
190 * @param frameEpoch the epoch of reference frame to be set
191 */
192 public void setFrameEpoch(final AbsoluteDate frameEpoch) {
193 refuseFurtherComments();
194 this.frameEpoch = frameEpoch;
195 }
196
197 }