1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.gnss.metric.ntrip;
18
19 import java.util.ArrayList;
20 import java.util.List;
21 import java.util.regex.Matcher;
22 import java.util.regex.Pattern;
23 import java.util.stream.Collectors;
24 import java.util.stream.Stream;
25
26 import org.hipparchus.util.FastMath;
27
28
29
30
31
32 public class DataStreamRecord extends Record {
33
34
35 private static final Pattern SEPARATOR = Pattern.compile(",");
36
37
38 private static final Pattern PATTERN = Pattern.compile("^([^()]+)(?:\\(([0-9]+)\\))?$");
39
40
41 private final DataFormat format;
42
43
44 private final List<StreamedMessage> formatDetails;
45
46
47 private final CarrierPhase carrierPhase;
48
49
50 private final List<NavigationSystem> systems;
51
52
53 private final double latitude;
54
55
56 private final double longitude;
57
58
59 private final boolean nmeaRequired;
60
61
62 private final boolean networked;
63
64
65 private final Authentication authentication;
66
67
68 private final boolean fees;
69
70
71 private int bitRate;
72
73
74
75
76 public DataStreamRecord(final String line) {
77 super(line);
78 this.format = DataFormat.getDataFormat(getField(3));
79
80 final String[] detailsFields = SEPARATOR.split(getField(4));
81 this.formatDetails = new ArrayList<>(detailsFields.length);
82 for (final String field : detailsFields) {
83 if (!field.isEmpty()) {
84 final Matcher matcher = PATTERN.matcher(field);
85 if (matcher.matches() && matcher.start(2) >= 0) {
86 formatDetails.add(new StreamedMessage(matcher.group(1),
87 Integer.parseInt(matcher.group(2))));
88 } else {
89 formatDetails.add(new StreamedMessage(field, -1));
90 }
91 }
92 }
93
94 this.carrierPhase = CarrierPhase.getCarrierPhase(getField(5));
95 this.systems = Stream.
96 of(getField(6).split("\\+")).
97 map(NavigationSystem::getNavigationSystem).
98 collect(Collectors.toList());
99 this.latitude = FastMath.toRadians(Double.parseDouble(getField(9)));
100 this.longitude = FastMath.toRadians(Double.parseDouble(getField(10)));
101 this.nmeaRequired = Integer.parseInt(getField(11)) != 0;
102 this.networked = Integer.parseInt(getField(12)) != 0;
103 this.authentication = Authentication.getAuthentication(getField(15));
104 this.fees = getField(16).equals("Y");
105 this.bitRate = Integer.parseInt(getField(17));
106 }
107
108
109 @Override
110 public RecordType getRecordType() {
111 return RecordType.STR;
112 }
113
114
115
116
117 public String getMountPoint() {
118 return getField(1);
119 }
120
121
122
123
124 public String getSourceIdentifier() {
125 return getField(2);
126 }
127
128
129
130
131 public DataFormat getFormat() {
132 return format;
133 }
134
135
136
137
138 public List<StreamedMessage> getFormatDetails() {
139 return formatDetails;
140 }
141
142
143
144
145 public CarrierPhase getCarrierPhase() {
146 return carrierPhase;
147 }
148
149
150
151
152 public List<NavigationSystem> getNavigationSystems() {
153 return systems;
154 }
155
156
157
158
159 public String getNetwork() {
160 return getField(7);
161 }
162
163
164
165
166 public String getCountry() {
167 return getField(8);
168 }
169
170
171
172
173 public double getLatitude() {
174 return latitude;
175 }
176
177
178
179
180 public double getLongitude() {
181 return longitude;
182 }
183
184
185
186
187 public boolean isNMEARequired() {
188 return nmeaRequired;
189 }
190
191
192
193
194 public boolean isNetworked() {
195 return networked;
196 }
197
198
199
200
201 public String getGenerator() {
202 return getField(13);
203 }
204
205
206
207
208 public String getCompressionEncryption() {
209 return getField(14);
210 }
211
212
213
214
215 public Authentication getAuthentication() {
216 return authentication;
217 }
218
219
220
221
222 public boolean areFeesRequired() {
223 return fees;
224 }
225
226
227
228
229 public int getBitRate() {
230 return bitRate;
231 }
232
233 }