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.orekit.files.rinex.navigation.IonosphereAij;
20  import org.orekit.files.rinex.navigation.IonosphereNavICNeQuickNMessage;
21  import org.orekit.files.rinex.navigation.RegionalAij;
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.utils.units.Unit;
26  
27  /** Parser for NavIC NeQuick N ionosphere.
28   * @author Luc Maisonobe
29   * @since 14.0
30   */
31  public class NavICNeQuickNParser
32      extends RecordLineParser {
33  
34      /** Container for parsing data. */
35      private final ParseInfo parseInfo;
36  
37      /** Container for NavIC NeQuick N message. */
38      private final IonosphereNavICNeQuickNMessage message;
39  
40      /** Simple constructor.
41       * @param parseInfo container for parsing data
42       * @param message container for navigation message
43       */
44      public NavICNeQuickNParser(final ParseInfo parseInfo, final IonosphereNavICNeQuickNMessage message) {
45          this.parseInfo = parseInfo;
46          this.message   = message;
47      }
48  
49      /** {@inheritDoc} */
50      @Override
51      public void parseLine00() {
52          message.setTransmitTime(parseInfo.parseDate(message.getSystem()));
53          message.setIOD(parseInfo.parseDouble2(Unit.ONE));
54      }
55  
56      /** {@inheritDoc} */
57      @Override
58      public void parseLine01() {
59          parseAij(message.getRegion1());
60      }
61  
62      /** {@inheritDoc} */
63      @Override
64      public void parseLine02() {
65          parseBoundaries(message.getRegion1());
66      }
67  
68      /** {@inheritDoc} */
69      @Override
70      public void parseLine03() {
71          parseAij(message.getRegion2());
72      }
73  
74      /** {@inheritDoc} */
75      @Override
76      public void parseLine04() {
77          parseBoundaries(message.getRegion2());
78      }
79  
80      /** {@inheritDoc} */
81      @Override
82      public void parseLine05() {
83          parseAij(message.getRegion3());
84      }
85  
86      /** {@inheritDoc} */
87      @Override
88      public void parseLine06() {
89          parseBoundaries(message.getRegion3());
90          parseInfo.closePendingRecord();
91      }
92  
93      /** Parse the aᵢⱼ coefficients for a region.
94       * @param region region to parse
95       */
96      private void parseAij(final RegionalAij region) {
97          region.setAi0(parseInfo.parseDouble1(IonosphereAij.SFU));
98          region.setAi1(parseInfo.parseDouble2(IonosphereAij.SFU_PER_DEG));
99          region.setAi2(parseInfo.parseDouble3(IonosphereAij.SFU_PER_DEG2));
100         region.setIDF(parseInfo.parseDouble4(Unit.ONE));
101 
102     }
103 
104     /** Parse the the boundaries of a region.
105      * @param region region to parse
106      */
107     private void parseBoundaries(final RegionalAij region) {
108         region.setLonMin(parseInfo.parseDouble1(Unit.DEGREE));
109         region.setLonMax(parseInfo.parseDouble2(Unit.DEGREE));
110         region.setModipMin(parseInfo.parseDouble3(Unit.DEGREE));
111         region.setModipMax(parseInfo.parseDouble4(Unit.DEGREE));
112     }
113 
114     /** {@inheritDoc} */
115     @Override
116     public void closeRecord(final RinexNavigation file) {
117         file.addNavICNeQuickNMessage(message);
118     }
119 
120 }