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.time.AbsoluteDate;
20 import org.orekit.utils.Constants;
21
22 import java.util.function.Predicate;
23
24 /** Predicates for station coordinates blocks.
25 * @author Luc Maisonobe
26 * @since 13.0
27 */
28 enum StationPredicate implements Predicate<SinexParseInfo> {
29
30 /** Predicate for STAX line. */
31 STAX {
32 /** {@inheritDoc} */
33 @Override
34 protected void store(final SinexParseInfo parseInfo, final double coordinate, final Station station,
35 final AbsoluteDate epoch) {
36 parseInfo.setPx(coordinate, station, epoch);
37 }
38 },
39
40 /** Predicate for STAY line. */
41 STAY {
42 /** {@inheritDoc} */
43 @Override
44 protected void store(final SinexParseInfo parseInfo, final double coordinate, final Station station,
45 final AbsoluteDate epoch) {
46 parseInfo.setPy(coordinate, station, epoch);
47 }
48 },
49
50 /** Predicate for STAZ line. */
51 STAZ {
52 /** {@inheritDoc} */
53 @Override
54 protected void store(final SinexParseInfo parseInfo, final double coordinate, final Station station,
55 final AbsoluteDate epoch) {
56 parseInfo.setPz(coordinate, station, epoch);
57 }
58 },
59
60 /** Predicate for VELX line. */
61 VELX {
62 /** {@inheritDoc} */
63 @Override
64 protected void store(final SinexParseInfo parseInfo, final double coordinate, final Station station,
65 final AbsoluteDate epoch) {
66 parseInfo.setVx(coordinate / Constants.JULIAN_YEAR, station);
67 }
68 },
69
70 /** Predicate for VELY line. */
71 VELY {
72 /** {@inheritDoc} */
73 @Override
74 protected void store(final SinexParseInfo parseInfo, final double coordinate, final Station station,
75 final AbsoluteDate epoch) {
76 parseInfo.setVy(coordinate / Constants.JULIAN_YEAR, station);
77 }
78 },
79
80 /** Predicate for VELZ line. */
81 VELZ {
82 /** {@inheritDoc} */
83 @Override
84 protected void store(final SinexParseInfo parseInfo, final double coordinate, final Station station,
85 final AbsoluteDate epoch) {
86 parseInfo.setVz(coordinate / Constants.JULIAN_YEAR, station);
87 }
88 };
89
90 /** {@inheritDoc} */
91 @Override
92 public boolean test(final SinexParseInfo parseInfo) {
93 if (name().equals(parseInfo.parseString(7, 6))) {
94 // this is the data type we are concerned with
95 store(parseInfo, parseInfo.parseDouble(47, 22),
96 parseInfo.getCurrentLineStation(14),
97 parseInfo.stringEpochToAbsoluteDate(parseInfo.parseString(27, 12), false));
98 return true;
99 } else {
100 // it is a data type for another predicate
101 return false;
102 }
103 }
104
105 /** Store parsed fields.
106 * @param parseInfo container for parse info
107 * @param coordinate station coordinate
108 * @param station station
109 * @param epoch current epoch
110 */
111 protected abstract void store(SinexParseInfo parseInfo, double coordinate, Station station, AbsoluteDate epoch);
112
113 }