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.ionosphere;
18  
19  import org.hipparchus.util.FastMath;
20  import org.orekit.files.rinex.navigation.IonosphereAij;
21  import org.orekit.files.rinex.navigation.IonosphereNequickGMessage;
22  import org.orekit.files.rinex.navigation.RinexNavigation;
23  import org.orekit.files.rinex.navigation.parsers.ParseInfo;
24  import org.orekit.files.rinex.navigation.parsers.RecordLineParser;
25  import org.orekit.files.rinex.utils.ParsingUtils;
26  
27  /** Parser for NeQuick G ionosphere.
28   * @author Luc Maisonobe
29   * @since 14.0
30   */
31  public class NeQuickGParser extends RecordLineParser {
32  
33      /** Container for parsing data. */
34      private final ParseInfo parseInfo;
35  
36      /** Container for NeQuick G message. */
37      private final IonosphereNequickGMessage message;
38  
39      /** Simple constructor.
40       * @param parseInfo container for parsing data
41       * @param message container for navigation message
42       */
43      public NeQuickGParser(final ParseInfo parseInfo, final IonosphereNequickGMessage message) {
44          this.parseInfo = parseInfo;
45          this.message   = message;
46      }
47  
48      /** {@inheritDoc} */
49      @Override
50      public void parseLine00() {
51          message.setTransmitTime(parseInfo.parseDate(message.getSystem()));
52          message.getAij().setAi0(parseInfo.parseDouble2(IonosphereAij.SFU));
53          message.getAij().setAi1(parseInfo.parseDouble3(IonosphereAij.SFU_PER_DEG));
54          message.getAij().setAi2(parseInfo.parseDouble4(IonosphereAij.SFU_PER_DEG2));
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public void parseLine01() {
60          message.setFlags((int) FastMath.rint(ParsingUtils.parseDouble(parseInfo.getLine(), 4, 19)));
61          parseInfo.closePendingRecord();
62      }
63  
64      /** {@inheritDoc} */
65      @Override
66      public void closeRecord(final RinexNavigation file) {
67          file.addNequickGMessage(message);
68      }
69  
70  }