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