OmmTleKey.java

  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. package org.orekit.files.ccsds.ndm.odm.omm;

  18. import org.orekit.files.ccsds.definitions.Units;
  19. import org.orekit.files.ccsds.utils.ContextBinding;
  20. import org.orekit.files.ccsds.utils.lexical.ParseToken;
  21. import org.orekit.files.ccsds.utils.lexical.TokenType;


  22. /** Keys for {@link OmmTle TLE} entries.
  23.  * @author Luc Maisonobe
  24.  * @since 11.0
  25.  */
  26. public enum OmmTleKey {

  27.     /** Comment entry. */
  28.     COMMENT((token, context, container) ->
  29.             token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),

  30.     /** Ephemeris Type, only required if MEAN_ELEMENT_THEORY = SGP/SGP4. */
  31.     EPHEMERIS_TYPE((token, context, container) -> token.processAsInteger(container::setEphemerisType)),

  32.     /** Classifiation type. */
  33.     CLASSIFICATION_TYPE((token, context, container) -> token.processAsNormalizedCharacter(container::setClassificationType)),

  34.     /** NORAD Catalog Number. */
  35.     NORAD_CAT_ID((token, context, container) -> token.processAsInteger(container::setNoradID)),

  36.     /** Element set number for this satellite. */
  37.     ELEMENT_SET_NO((token, context, container) -> token.processAsInteger(container::setElementSetNo)),

  38.     /** Revolution number. */
  39.     REV_AT_EPOCH((token, context, container) -> token.processAsInteger(container::setRevAtEpoch)),

  40.     /** SGP/SGP4 drag-like coefficient. */
  41.     BSTAR((token, context, container) -> token.processAsDouble(Units.ONE_PER_ER, context.getParsedUnitsBehavior(),
  42.                                                                container::setBStar)),

  43.     /** SGP4-XP drag-like coefficient.
  44.      * @since 12.0
  45.      */
  46.     BTERM((token, context, container) -> token.processAsDouble(Units.M2_PER_KG, context.getParsedUnitsBehavior(),
  47.                                                                container::setBTerm)),

  48.     /** First time derivative of mean motion. */
  49.     MEAN_MOTION_DOT((token, context, container) -> token.processAsDouble(Units.REV_PER_DAY2_SCALED, context.getParsedUnitsBehavior(),
  50.                                                                          container::setMeanMotionDot)),

  51.     /** Second time derivative of mean motion. */
  52.     MEAN_MOTION_DDOT((token, context, container) -> token.processAsDouble(Units.REV_PER_DAY3_SCALED, context.getParsedUnitsBehavior(),
  53.                                                                           container::setMeanMotionDotDot)),

  54.     /** SGP4-XP solar radiation pressure-like coefficient.
  55.      * @since 12.0
  56.      */
  57.     AGOM((token, context, container) -> token.processAsDouble(Units.M2_PER_KG, context.getParsedUnitsBehavior(),
  58.                                                               container::setAGoM));

  59.     /** Processing method. */
  60.     private final transient TokenProcessor processor;

  61.     /** Simple constructor.
  62.      * @param processor processing method
  63.      */
  64.     OmmTleKey(final TokenProcessor processor) {
  65.         this.processor = processor;
  66.     }

  67.     /** Process one token.
  68.      * @param token token to process
  69.      * @param context context binding
  70.      * @param container container to fill
  71.      * @return true of token was accepted
  72.      */
  73.     public boolean process(final ParseToken token, final ContextBinding context, final OmmTle container) {
  74.         return processor.process(token, context, container);
  75.     }

  76.     /** Interface for processing one token. */
  77.     interface TokenProcessor {
  78.         /** Process one token.
  79.          * @param token token to process
  80.          * @param context context binding
  81.          * @param container container to fill
  82.          * @return true of token was accepted
  83.          */
  84.         boolean process(ParseToken token, ContextBinding context, OmmTle container);
  85.     }

  86. }