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.omm;
19
20 import org.orekit.errors.OrekitException;
21 import org.orekit.errors.OrekitMessages;
22 import org.orekit.files.ccsds.ndm.odm.CartesianCovariance;
23 import org.orekit.files.ccsds.ndm.odm.KeplerianElements;
24 import org.orekit.files.ccsds.ndm.odm.KeplerianElementsKey;
25 import org.orekit.files.ccsds.ndm.odm.SpacecraftParameters;
26 import org.orekit.files.ccsds.ndm.odm.UserDefined;
27 import org.orekit.files.ccsds.section.Data;
28
29 /**
30 * Container for Orbit Mean-elements Message data.
31 * @author Luc Maisonobe
32 * @since 11.0
33 */
34 public class OmmData implements Data {
35
36 /** Keplerian elements block. */
37 private final KeplerianElements keplerianElementsBlock;
38
39 /** Spacecraft parameters block. */
40 private final SpacecraftParameters spacecraftParameters;
41
42 /** TLE block. */
43 private final OmmTle tleBlock;
44
45 /** Covariance matrix logical block being read. */
46 private final CartesianCovariance covarianceBlock;
47
48 /** User defined parameters. */
49 private final UserDefined userDefinedBlock;
50
51 /** Mass. */
52 private final double mass;
53
54 /** Simple constructor.
55 * @param keplerianElementsBlock Keplerian elements logical block
56 * @param spacecraftParameters spacecraft parameters logical block (may be null)
57 * @param tleBlock TLE logical block (may be null)
58 * @param covarianceBlock covariance matrix logical block (may be null)
59 * @param userDefinedBlock user-defined logical block
60 * @param mass mass (always defined, even if there is no {@code spacecraftParameters} block
61 */
62 public OmmData(final KeplerianElements keplerianElementsBlock,
63 final SpacecraftParameters spacecraftParameters,
64 final OmmTle tleBlock,
65 final CartesianCovariance covarianceBlock,
66 final UserDefined userDefinedBlock,
67 final double mass) {
68 this.keplerianElementsBlock = keplerianElementsBlock;
69 this.spacecraftParameters = spacecraftParameters;
70 this.tleBlock = tleBlock;
71 this.covarianceBlock = covarianceBlock;
72 this.userDefinedBlock = userDefinedBlock;
73 this.mass = mass;
74 }
75
76 /** {@inheritDoc} */
77 @Override
78 public void validate(final double version) {
79 if (keplerianElementsBlock == null) {
80 throw new OrekitException(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY,
81 KeplerianElementsKey.EPOCH);
82 }
83 keplerianElementsBlock.validate(version);
84 if (spacecraftParameters != null) {
85 spacecraftParameters.validate(version);
86 }
87 if (tleBlock == null) {
88 // semi-major axis was not checked above, we do it now
89 keplerianElementsBlock.checkNotNaN(keplerianElementsBlock.getA(),
90 KeplerianElementsKey.SEMI_MAJOR_AXIS.name());
91 } else {
92 // in OMM with TLE block, only mean motion is allowed, not semi-major axis
93 keplerianElementsBlock.checkNotNaN(keplerianElementsBlock.getMeanMotion(),
94 KeplerianElementsKey.MEAN_MOTION.name());
95 tleBlock.validate(version);
96 }
97 if (covarianceBlock != null) {
98 covarianceBlock.setEpoch(keplerianElementsBlock.getEpoch());
99 covarianceBlock.validate(version);
100 }
101 if (userDefinedBlock != null) {
102 userDefinedBlock.validate(version);
103 }
104 }
105
106 /** Get the Keplerian elements logical block.
107 * @return Keplerian elements block
108 */
109 public KeplerianElements getKeplerianElementsBlock() {
110 return keplerianElementsBlock;
111 }
112
113 /** Get the spacecraft parameters logical block.
114 * @return spacecraft parameters block (may be null)
115 */
116 public SpacecraftParameters getSpacecraftParametersBlock() {
117 return spacecraftParameters;
118 }
119
120 /** Get the TLE logical block.
121 * @return TLE block
122 */
123 public OmmTle getTLEBlock() {
124 return tleBlock;
125 }
126
127 /** Get the covariance matrix logical block.
128 * @return covariance matrix block (may be null)
129 */
130 public CartesianCovariance getCovarianceBlock() {
131 return covarianceBlock;
132 }
133
134 /** Get the user defined parameters logical block.
135 * @return user defined parameters block (may be null)
136 */
137 public UserDefined getUserDefinedBlock() {
138 return userDefinedBlock;
139 }
140
141 /** Get the mass.
142 * @return mass
143 */
144 public double getMass() {
145 return mass;
146 }
147
148 }