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.gnss.metric.ntrip;
18  
19  import org.hipparchus.util.FastMath;
20  
21  /** Caster record in source table.
22   * @author Luc Maisonobe
23   * @since 11.0
24   */
25  public class CasterRecord extends Record {
26  
27      /** Port number. */
28      private final int port;
29  
30      /** Fallback port number. */
31      private final int fallbackPort;
32  
33      /** Indicator for NMEA reception. */
34      private final boolean canReceiveNMEA;
35  
36      /** Latitude (rad). */
37      private final double latitude;
38  
39      /** Longitude (rad). */
40      private final double longitude;
41  
42      /** Build a caster record by parsing a source table line.
43       * @param line source table line
44       */
45      public CasterRecord(final String line) {
46          super(line);
47          this.port           = Integer.parseInt(getField(2));
48          this.canReceiveNMEA = Integer.parseInt(getField(5)) != 0;
49          this.latitude       = FastMath.toRadians(Double.parseDouble(getField(7)));
50          this.longitude      = FastMath.toRadians(Double.parseDouble(getField(8)));
51          this.fallbackPort   = Integer.parseInt(getField(10));
52      }
53  
54      /** {@inheritDoc} */
55      @Override
56      public RecordType getRecordType() {
57          return RecordType.CAS;
58      }
59  
60      /** Get the host or IP address.
61       * @return host or IP address
62       */
63      public String getHostOrIPAddress() {
64          return getField(1);
65      }
66  
67      /** Get the port number.
68       * @return port number
69       */
70      public int getPort() {
71          return port;
72      }
73  
74      /** Get the source identifier.
75       * @return source identifier
76       */
77      public String getSourceIdentifier() {
78          return getField(3);
79      }
80  
81      /** Get the institution/agency/company operating the caster.
82       * @return institution/agency/company operating the caster
83       */
84      public String getOperator() {
85          return getField(4);
86      }
87  
88      /** Check if caster can receive NMEA messages.
89       * @return true if caster can receive NMEA messages
90       */
91      public boolean canReceiveNMEA() {
92          return canReceiveNMEA;
93      }
94  
95      /** Get the country.
96       * @return country
97       */
98      public String getCountry() {
99          return getField(6);
100     }
101 
102     /** Get the latitude.
103      * @return latitude (rad)
104      */
105     public double getLatitude() {
106         return latitude;
107     }
108 
109     /** Get the longitude.
110      * @return longitude (rad)
111      */
112     public double getLongitude() {
113         return longitude;
114     }
115 
116     /** Get the fallback host or IP address.
117      * @return fallback host or IP address
118      */
119     public String getFallbackHostOrIPAddress() {
120         return getField(9);
121     }
122 
123     /** Get the fallback port number.
124      * @return fallback port number
125      */
126     public int getFallbackPort() {
127         return fallbackPort;
128     }
129 
130 }