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  package org.orekit.files.ccsds.ndm.odm.omm;
18  
19  import org.orekit.files.ccsds.definitions.Units;
20  import org.orekit.files.ccsds.utils.ContextBinding;
21  import org.orekit.files.ccsds.utils.lexical.ParseToken;
22  import org.orekit.files.ccsds.utils.lexical.TokenType;
23  
24  
25  /** Keys for {@link OmmTle TLE} entries.
26   * @author Luc Maisonobe
27   * @since 11.0
28   */
29  public enum OmmTleKey {
30  
31      /** Comment entry. */
32      COMMENT((token, context, container) ->
33              token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
34  
35      /** Ephemeris Type, only required if MEAN_ELEMENT_THEORY = SGP/SGP4. */
36      EPHEMERIS_TYPE((token, context, container) -> token.processAsInteger(container::setEphemerisType)),
37  
38      /** Classifiation type. */
39      CLASSIFICATION_TYPE((token, context, container) -> token.processAsNormalizedCharacter(container::setClassificationType)),
40  
41      /** NORAD Catalog Number. */
42      NORAD_CAT_ID((token, context, container) -> token.processAsInteger(container::setNoradID)),
43  
44      /** Element set number for this satellite. */
45      ELEMENT_SET_NO((token, context, container) -> token.processAsInteger(container::setElementSetNo)),
46  
47      /** Revolution number. */
48      REV_AT_EPOCH((token, context, container) -> token.processAsInteger(container::setRevAtEpoch)),
49  
50      /** SGP/SGP4 drag-like coefficient. */
51      BSTAR((token, context, container) -> token.processAsDouble(Units.ONE_PER_ER, context.getParsedUnitsBehavior(),
52                                                                 container::setBStar)),
53  
54      /** SGP4-XP drag-like coefficient.
55       * @since 12.0
56       */
57      BTERM((token, context, container) -> token.processAsDouble(Units.M2_PER_KG, context.getParsedUnitsBehavior(),
58                                                                 container::setBTerm)),
59  
60      /** First time derivative of mean motion. */
61      MEAN_MOTION_DOT((token, context, container) -> token.processAsDouble(Units.REV_PER_DAY2_SCALED, context.getParsedUnitsBehavior(),
62                                                                           container::setMeanMotionDot)),
63  
64      /** Second time derivative of mean motion. */
65      MEAN_MOTION_DDOT((token, context, container) -> token.processAsDouble(Units.REV_PER_DAY3_SCALED, context.getParsedUnitsBehavior(),
66                                                                            container::setMeanMotionDotDot)),
67  
68      /** SGP4-XP solar radiation pressure-like coefficient.
69       * @since 12.0
70       */
71      AGOM((token, context, container) -> token.processAsDouble(Units.M2_PER_KG, context.getParsedUnitsBehavior(),
72                                                                container::setAGoM));
73  
74      /** Processing method. */
75      private final transient TokenProcessor processor;
76  
77      /** Simple constructor.
78       * @param processor processing method
79       */
80      OmmTleKey(final TokenProcessor processor) {
81          this.processor = processor;
82      }
83  
84      /** Process one token.
85       * @param token token to process
86       * @param context context binding
87       * @param container container to fill
88       * @return true of token was accepted
89       */
90      public boolean process(final ParseToken token, final ContextBinding context, final OmmTle container) {
91          return processor.process(token, context, container);
92      }
93  
94      /** Interface for processing one token. */
95      interface TokenProcessor {
96          /** Process one token.
97           * @param token token to process
98           * @param context context binding
99           * @param container container to fill
100          * @return true of token was accepted
101          */
102         boolean process(ParseToken token, ContextBinding context, OmmTle container);
103     }
104 
105 }