1   /* Copyright 2002-2024 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.files.ccsds.section.CommentsContainer;
21  
22  /** Container for TLE data.
23   * @author sports
24   * @since 6.1
25   */
26  public class OmmTle extends CommentsContainer {
27  
28      /** Constant for EPHEMERIS_TYPE SGP.
29       * @since 12.0
30       */
31      public static final int EPHEMERIS_TYPE_SGP = 0;
32  
33      /** Constant for EPHEMERIS_TYPE SGP4.
34       * @since 12.0
35       */
36      public static final int EPHEMERIS_TYPE_SGP4 = 2;
37  
38      /** Constant for EPHEMERIS_TYPE PPT3.
39       * @since 12.0
40       */
41      public static final int EPHEMERIS_TYPE_PPT3 = 3;
42  
43      /** Constant for EPHEMERIS_TYPE SGP4-XP.
44       * @since 12.0
45       */
46      public static final int EPHEMERIS_TYPE_SGP4_XP = 4;
47  
48      /** Constant for EPHEMERIS_TYPE Special Perturbations.
49       * @since 12.0
50       */
51      public static final int EPHEMERIS_TYPE_SPECIAL_PERTURBATIONS = 6;
52  
53      /** Ephemeris Type, only required if MEAN_ELEMENT_THEORY = SGP/SGP4. Some sources suggest the coding for
54       * the EPHEMERIS_TYPE keyword: 0 = SGP, 2 = SGP4, 3 = PPT3, 4 = SGP4-XP, 6 = Special Perturbations. Default value = 0.
55       */
56      private int ephemerisType;
57  
58      /** Classification Type, only required if MEAN_ELEMENT_THEORY = SGP/SGP4. Some sources suggest the
59       *  following coding for the CLASSIFICATION_TYPE keyword: U = unclassified, S = secret. Default value = U.
60       */
61      private char classificationType;
62  
63      /** NORAD Catalog Number ("Satellite Number"), an integer of up to nine digits. */
64      private int noradID;
65  
66      /** Element set number for this satellite, only required if MEAN_ELEMENT_THEORY = SGP/SGP4.
67       * Normally incremented sequentially, but may be out of sync if it is generated from a backup source.
68       * Used to distinguish different TLEs, and therefore only meaningful if TLE based data is being exchanged. */
69      private int elementSetNo;
70  
71      /** Revolution Number, only required if MEAN_ELEMENT_THEORY = SGP/SGP4. */
72      private int revAtEpoch;
73  
74      /** SGP/SGP4 drag-like coefficient (in units 1/[Earth radii]), only required if MEAN_ELEMENT_THEORY = SGP/SGP4. */
75      private double bStar;
76  
77      /** SGP4-XP drag-like coefficient (in m²/kg), only required if MEAN_ELEMENT_THEORY = SGP4-XP.
78       * @since 12.0
79       */
80      private double bTerm;
81  
82      /** First Time Derivative of the Mean Motion, only required if MEAN_ELEMENT_THEORY = SGP. */
83      private double meanMotionDot;
84  
85      /** Second Time Derivative of Mean Motion, only required if MEAN_ELEMENT_THEORY = SGP. */
86      private double meanMotionDotDot;
87  
88      /** SGP4-XP solar radiation pressure-like coefficient Aγ/m (in m²/kg), only required if MEAN_ELEMENT_THEORY = SGP4-XP.
89       * @since 12.0
90       */
91      private double agOm;
92  
93      /** Create an empty data set.
94       */
95      public OmmTle() {
96          ephemerisType      = EPHEMERIS_TYPE_SGP;
97          classificationType = 'U';
98          noradID            = -1;
99          elementSetNo       = -1;
100         revAtEpoch         = -1;
101         bStar              =  Double.NaN;
102         bTerm              =  Double.NaN;
103         meanMotionDot      =  Double.NaN;
104         meanMotionDotDot   =  Double.NaN;
105         agOm               =  Double.NaN;
106     }
107 
108     /** {@inheritDoc} */
109     @Override
110     public void validate(final double version) {
111         super.validate(version);
112 
113         checkNotNegative(noradID,      OmmTleKey.NORAD_CAT_ID.name());
114         checkNotNegative(elementSetNo, OmmTleKey.ELEMENT_SET_NO.name());
115         checkNotNegative(revAtEpoch,   OmmTleKey.REV_AT_EPOCH.name());
116 
117         if (ephemerisType == EPHEMERIS_TYPE_SGP4) {
118             checkNotNaN(bStar, OmmTleKey.BSTAR.name());
119         } else if (ephemerisType == EPHEMERIS_TYPE_SGP4_XP) {
120             checkNotNaN(bTerm, OmmTleKey.BTERM.name());
121         }
122 
123         if (ephemerisType == EPHEMERIS_TYPE_SGP  || ephemerisType == EPHEMERIS_TYPE_PPT3) {
124             checkNotNaN(meanMotionDot, OmmTleKey.MEAN_MOTION_DOT.name());
125         }
126 
127         if (ephemerisType == EPHEMERIS_TYPE_SGP  || ephemerisType == EPHEMERIS_TYPE_PPT3) {
128             checkNotNaN(meanMotionDotDot, OmmTleKey.MEAN_MOTION_DDOT.name());
129         } else if (ephemerisType == EPHEMERIS_TYPE_SGP4_XP) {
130             checkNotNaN(agOm, OmmTleKey.AGOM.name());
131         }
132 
133     }
134 
135     /** Get the ephemeris type.
136      * @return the ephemerisType
137      */
138     public int getEphemerisType() {
139         return ephemerisType;
140     }
141 
142     /** Set the ephemeris type.
143      * @param ephemerisType the ephemeris type to be set
144      */
145     public void setEphemerisType(final int ephemerisType) {
146         refuseFurtherComments();
147         this.ephemerisType = ephemerisType;
148     }
149 
150     /** Get the classification type.
151      * @return the classificationType
152      */
153     public char getClassificationType() {
154         return classificationType;
155     }
156 
157     /** Set the classification type.
158      * @param classificationType the classification type to be set
159      */
160     public void setClassificationType(final char classificationType) {
161         refuseFurtherComments();
162         this.classificationType = classificationType;
163     }
164 
165     /** Get the NORAD Catalog Number ("Satellite Number").
166      * @return the NORAD Catalog Number
167      */
168     public int getNoradID() {
169         return noradID;
170     }
171 
172     /** Set the NORAD Catalog Number ("Satellite Number").
173      * @param noradID the element set number to be set
174      */
175     public void setNoradID(final int noradID) {
176         refuseFurtherComments();
177         this.noradID = noradID;
178     }
179 
180     /** Get the element set number for this satellite.
181      * @return the element set number for this satellite
182      */
183     public int getElementSetNumber() {
184         return elementSetNo;
185     }
186 
187     /** Set the element set number for this satellite.
188      * @param elementSetNo the element set number to be set
189      */
190     public void setElementSetNo(final int elementSetNo) {
191         refuseFurtherComments();
192         this.elementSetNo = elementSetNo;
193     }
194 
195     /** Get the revolution rumber.
196      * @return the revolution rumber
197      */
198     public int getRevAtEpoch() {
199         return revAtEpoch;
200     }
201 
202     /** Set the revolution rumber.
203      * @param revAtEpoch the Revolution Number to be set
204      */
205     public void setRevAtEpoch(final int revAtEpoch) {
206         refuseFurtherComments();
207         this.revAtEpoch = revAtEpoch;
208     }
209 
210     /** Get the SGP/SGP4 drag-like coefficient.
211      * @return the SGP/SGP4 drag-like coefficient
212      */
213     public double getBStar() {
214         return bStar;
215     }
216 
217     /** Set the SGP/SGP4 drag-like coefficient.
218      * @param bstar the SGP/SGP4 drag-like coefficient to be set
219      */
220     public void setBStar(final double bstar) {
221         refuseFurtherComments();
222         this.bStar = bstar;
223     }
224 
225     /** Get the SGP4-XP drag-like coefficient.
226      * @return the SGP4-XP drag-like coefficient
227      * @since 12.0
228      */
229     public double getBTerm() {
230         return bTerm;
231     }
232 
233     /** Set the SGP4-XP drag-like coefficient.
234      * @param bterm the SGP4-XP drag-like coefficient to be set
235      * @since 12.0
236      */
237     public void setBTerm(final double bterm) {
238         refuseFurtherComments();
239         this.bTerm = bterm;
240     }
241 
242     /** Get the first time derivative of the mean motion.
243      * @return the first time derivative of the mean motion
244      */
245     public double getMeanMotionDot() {
246         return meanMotionDot;
247     }
248 
249     /** Set the first time derivative of the mean motion.
250      * @param meanMotionDot the first time derivative of the mean motion to be set
251      */
252     public void setMeanMotionDot(final double meanMotionDot) {
253         refuseFurtherComments();
254         this.meanMotionDot = meanMotionDot;
255     }
256 
257     /** Get the second time derivative of the mean motion.
258      * @return the second time derivative of the mean motion
259      */
260     public double getMeanMotionDotDot() {
261         return meanMotionDotDot;
262     }
263 
264     /** Set the second time derivative of the mean motion.
265      * @param meanMotionDotDot the second time derivative of the mean motion to be set
266      */
267     public void setMeanMotionDotDot(final double meanMotionDotDot) {
268         refuseFurtherComments();
269         this.meanMotionDotDot = meanMotionDotDot;
270     }
271 
272     /** Get the SGP4-XP solar radiation pressure-like coefficient Aγ/m.
273      * @return the SGP4-XP solar radiation pressure-like coefficient Aγ/m
274      * @since 12.0
275      */
276     public double getAGoM() {
277         return agOm;
278     }
279 
280     /** Set the SGP4-XP solar radiation pressure-like coefficient Aγ/m.
281      * @param agom the SGP4-XP solar radiation pressure-like coefficient Aγ/m to be set
282      * @since 12.0
283      */
284     public void setAGoM(final double agom) {
285         refuseFurtherComments();
286         this.agOm = agom;
287     }
288 
289 }