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