1   /* Copyright 2002-2025 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.rinex.navigation.parsers;
18  
19  import org.orekit.files.rinex.navigation.EarthOrientationParameterMessage;
20  import org.orekit.files.rinex.navigation.RinexNavigation;
21  import org.orekit.files.rinex.navigation.RinexNavigationParser;
22  import org.orekit.utils.units.Unit;
23  
24  /** Parser for Earth Orientation Parameter.
25   * @author Luc Maisonobe
26   * @since 14.0
27   */
28  public class EarthOrientationParameterParser
29      extends RecordLineParser {
30  
31      /** Container for parsing data. */
32      private final ParseInfo parseInfo;
33  
34      /** Container for Earth Orientation Parameter message. */
35      private final EarthOrientationParameterMessage message;
36  
37      /** Simple constructor.
38       * @param parseInfo container for parsing data
39       * @param message container for navigation message
40       */
41      public EarthOrientationParameterParser(final ParseInfo parseInfo, final EarthOrientationParameterMessage message) {
42          this.parseInfo = parseInfo;
43          this.message   = message;
44      }
45  
46      /** {@inheritDoc} */
47      @Override
48      public void parseLine00() {
49          message.setReferenceEpoch(parseInfo.parseDate(message.getSystem()));
50          message.setXp(parseInfo.parseDouble2(Unit.ARC_SECOND));
51          message.setXpDot(parseInfo.parseDouble3(RinexNavigationParser.AS_PER_DAY));
52          message.setXpDotDot(parseInfo.parseDouble4(RinexNavigationParser.AS_PER_DAY2));
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public void parseLine01() {
58          message.setYp(parseInfo.parseDouble2(Unit.ARC_SECOND));
59          message.setYpDot(parseInfo.parseDouble3(RinexNavigationParser.AS_PER_DAY));
60          message.setYpDotDot(parseInfo.parseDouble4(RinexNavigationParser.AS_PER_DAY2));
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      public void parseLine02() {
66          message.setTransmissionTime(parseInfo.parseDouble1(Unit.SECOND));
67          message.setDut1(parseInfo.parseDouble2(Unit.SECOND));
68          message.setDut1Dot(parseInfo.parseDouble3(RinexNavigationParser.S_PER_DAY));
69          message.setDut1DotDot(parseInfo.parseDouble4(RinexNavigationParser.S_PER_DAY2));
70          parseInfo.closePendingRecord();
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public void closeRecord(final RinexNavigation file) {
76          file.addEarthOrientationParameter(message);
77      }
78  
79  }