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.ocm;
18  
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  import org.orekit.utils.units.Unit;
23  
24  
25  /** Keys for {@link OrbitCovarianceHistoryMetadata covariance history container} entries.
26   * @author Luc Maisonobe
27   * @since 11.0
28   */
29  public enum OrbitCovarianceHistoryMetadataKey {
30  
31      /** Comment entry. */
32      COMMENT((token, context, container) ->
33              token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
34  
35      /** Covariance identification number. */
36      COV_ID((token, context, container) -> token.processAsFreeTextString(container::setCovID)),
37  
38      /** Identification number of previous covariance. */
39      COV_PREV_ID((token, context, container) -> token.processAsFreeTextString(container::setCovPrevID)),
40  
41      /** Identification number of next covariance. */
42      COV_NEXT_ID((token, context, container) -> token.processAsFreeTextString(container::setCovNextID)),
43  
44      /** Basis of this covariance time history data. */
45      COV_BASIS((token, context, container) -> token.processAsFreeTextString(container::setCovBasis)),
46  
47      /** Identification number of the orbit determination or simulation upon which this covariance is based.*/
48      COV_BASIS_ID((token, context, container) -> token.processAsFreeTextString(container::setCovBasisID)),
49  
50      /** Reference frame of the covariance. */
51      COV_REF_FRAME((token, context, container) -> token.processAsFrame(container::setCovReferenceFrame, context, true, true, false)),
52  
53      /** Epoch of the {@link #COV_REF_FRAME covariance reference frame}. */
54      COV_FRAME_EPOCH((token, context, container) -> token.processAsDate(container::setCovFrameEpoch, context)),
55  
56      /** Minimum scale factor to apply to achieve realism. */
57      COV_SCALE_MIN((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
58                                                                         container::setCovScaleMin)),
59  
60      /** Maximum scale factor to apply to achieve realism. */
61      COV_SCALE_MAX((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
62                                                                         container::setCovScaleMax)),
63  
64      /** Masure of confidence in covariance error matching reality. */
65      COV_CONFIDENCE((token, context, container) -> token.processAsDouble(Unit.PERCENT, context.getParsedUnitsBehavior(),
66                                                                          container::setCovConfidence)),
67  
68      /** Covariance element set type.
69       * @see OrbitElementsType
70       */
71      COV_TYPE((token, context, container) -> token.processAsEnum(OrbitElementsType.class, container::setCovType)),
72  
73      /** Covariance ordering. */
74      COV_ORDERING((token, context, container) -> token.processAsEnum(Ordering.class, container::setCovOrdering)),
75  
76      /** SI units for each elements of the covariance. */
77      COV_UNITS((token, context, container) -> token.processAsUnitList(container::setCovUnits));
78  
79      /** Processing method. */
80      private final transient TokenProcessor processor;
81  
82      /** Simple constructor.
83       * @param processor processing method
84       */
85      OrbitCovarianceHistoryMetadataKey(final TokenProcessor processor) {
86          this.processor = processor;
87      }
88  
89      /** Process an token.
90       * @param token token to process
91       * @param context context binding
92       * @param container container to fill
93       * @return true of token was accepted
94       */
95      public boolean process(final ParseToken token, final ContextBinding context, final OrbitCovarianceHistoryMetadata container) {
96          return processor.process(token, context, container);
97      }
98  
99      /** Interface for processing one token. */
100     interface TokenProcessor {
101         /** Process one token.
102          * @param token token to process
103          * @param context context binding
104          * @param container container to fill
105          * @return true of token was accepted
106          */
107         boolean process(ParseToken token, ContextBinding context, OrbitCovarianceHistoryMetadata container);
108     }
109 
110 }