1 /* Copyright 2022-2025 Luc Maisonobe
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.sinex;
18
19 import org.orekit.gnss.TimeSystem;
20
21 import java.util.function.Predicate;
22
23 /** Predicates for bias description blocks.
24 * @author Luc Maisonobe
25 * @since 13.0
26 */
27 enum BiasDescriptionPredicate implements Predicate<SinexBiasParseInfo> {
28
29 /** Predicate for OBSERVATION_SAMPLING line. */
30 OBSERVATION_SAMPLING {
31 /** {@inheritDoc} */
32 @Override
33 protected void store(final SinexBiasParseInfo parseInfo) {
34 parseInfo.getDescription().setObservationSampling(parseInfo.parseInt(41, 12));
35 }
36 },
37
38 /** Predicate for PARAMETER_SPACING line. */
39 PARAMETER_SPACING {
40 /** {@inheritDoc} */
41 @Override
42 protected void store(final SinexBiasParseInfo parseInfo) {
43 parseInfo.getDescription().setParameterSpacing(parseInfo.parseInt(41, 12));
44 }
45 },
46
47 /** Predicate for DETERMINATION_METHOD line. */
48 DETERMINATION_METHOD {
49 /** {@inheritDoc} */
50 @Override
51 protected void store(final SinexBiasParseInfo parseInfo) {
52 parseInfo.getDescription().setDeterminationMethod(parseInfo.parseString(41, 39));
53 }
54 },
55
56 /** Predicate for BIAS_MODE line. */
57 BIAS_MODE {
58 /** {@inheritDoc} */
59 @Override
60 protected void store(final SinexBiasParseInfo parseInfo) {
61 parseInfo.getDescription().setBiasMode(parseInfo.parseString(41, 39));
62 }
63 },
64
65 /** Predicate for TIME_SYSTEM line. */
66 TIME_SYSTEM {
67 /** {@inheritDoc} */
68 @Override
69 protected void store(final SinexBiasParseInfo parseInfo) {
70 final String ts = parseInfo.parseString(41, 3);
71 if ("UTC".equals(ts)) {
72 parseInfo.setTimeSystem(TimeSystem.UTC);
73 } else if ("TAI".equals(ts)) {
74 parseInfo.setTimeSystem(TimeSystem.TAI);
75 } else {
76 parseInfo.setTimeSystem(TimeSystem.parseOneLetterCode(ts));
77 }
78 }
79 };
80
81 /** {@inheritDoc} */
82 @Override
83 public boolean test(final SinexBiasParseInfo parseInfo) {
84 if (name().equals(parseInfo.parseString(1, 39))) {
85 // this is the data type we are concerned with
86 store(parseInfo);
87 return true;
88 } else {
89 // it is a data type for another predicate
90 return false;
91 }
92 }
93
94 /** Store parsed fields.
95 * @param parseInfo container for parse info
96 */
97 protected abstract void store(SinexBiasParseInfo parseInfo);
98
99 }