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