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