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