source: ntrip/trunk/BNC/src/satObs.cpp@ 10256

Last change on this file since 10256 was 9686, checked in by stuerze, 3 years ago

minor changes

File size: 14.3 KB
Line 
1#include <iostream>
2#include <iomanip>
3#include <sstream>
4#include <newmatio.h>
5
6#include "satObs.h"
7
8using namespace std;
9
10// Constructor
11////////////////////////////////////////////////////////////////////////////
12t_clkCorr::t_clkCorr() {
13 _updateInt = 0;
14 _iod = 0;
15 _dClk = 0.0;
16 _dotDClk = 0.0;
17 _dotDotDClk = 0.0;
18}
19
20//
21////////////////////////////////////////////////////////////////////////////
22void t_clkCorr::writeEpoch(ostream* out, const QList<t_clkCorr>& corrList) {
23 if (!out || corrList.size() == 0) {
24 return;
25 }
26 out->setf(ios::fixed);
27 bncTime epoTime;
28 QListIterator<t_clkCorr> it(corrList);
29 while (it.hasNext()) {
30 const t_clkCorr& corr = it.next();
31 if (!epoTime.valid()) {
32 epoTime = corr._time;
33 *out << "> CLOCK " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
34 << corr._updateInt << " "
35 << corrList.size() << ' ' << corr._staID << endl;
36 }
37 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
38 << setw(10) << setprecision(4) << corr._dClk * t_CST::c << ' '
39 << setw(10) << setprecision(4) << corr._dotDClk * t_CST::c * 1.e3 << ' ' // m/s => mm/s
40 << setw(10) << setprecision(4) << corr._dotDotDClk * t_CST::c * 1.e3 << endl; // m/s => mm/s
41 }
42 out->flush();
43}
44
45//
46////////////////////////////////////////////////////////////////////////////
47void t_clkCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_clkCorr>& corrList) {
48 bncTime epoTime;
49 unsigned int updateInt;
50 int numCorr;
51 string staID;
52 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::clkCorr) {
53 return;
54 }
55 for (int ii = 0; ii < numCorr; ii++) {
56 t_clkCorr corr;
57 corr._time = epoTime;
58 corr._updateInt = updateInt;
59 corr._staID = staID;
60
61 string line;
62 getline(inStream, line);
63 istringstream in(line.c_str());
64
65 in >> corr._prn >> corr._iod >> corr._dClk >> corr._dotDClk >> corr._dotDotDClk;
66 if (corr._prn.system() == 'E') {
67 corr._prn.setFlags(1);// I/NAV
68 }
69 corr._dClk /= (t_CST::c); // m
70 corr._dotDClk /= (t_CST::c * 1.e3); // mm/s
71 corr._dotDotDClk /= (t_CST::c * 1.e3); // mm/s²
72
73 corrList.push_back(corr);
74 }
75}
76
77// Constructor
78////////////////////////////////////////////////////////////////////////////
79t_orbCorr::t_orbCorr() {
80 _updateInt = 0;
81 _iod = 0;
82 _system = 'R';
83 _xr.ReSize(3); _xr = 0.0;
84 _dotXr.ReSize(3); _dotXr = 0.0;
85}
86
87//
88////////////////////////////////////////////////////////////////////////////
89void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
90 if (!out || corrList.size() == 0) {
91 return;
92 }
93 out->setf(ios::fixed);
94 bncTime epoTime;
95 QListIterator<t_orbCorr> it(corrList);
96 while (it.hasNext()) {
97 const t_orbCorr& corr = it.next();
98 if (!epoTime.valid()) {
99 epoTime = corr._time;
100 *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
101 << corr._updateInt << " "
102 << corrList.size() << ' ' << corr._staID << endl;
103 }
104 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
105 << setw(10) << setprecision(4) << corr._xr[0] << ' '
106 << setw(10) << setprecision(4) << corr._xr[1] << ' '
107 << setw(10) << setprecision(4) << corr._xr[2] << " "
108 << setw(10) << setprecision(4) << corr._dotXr[0] * 1.e3 << ' ' // m/s => mm/s
109 << setw(10) << setprecision(4) << corr._dotXr[1] * 1.e3 << ' ' // m/s => mm/s
110 << setw(10) << setprecision(4) << corr._dotXr[2] * 1.e3 << endl; // m/s => mm/s
111 }
112 out->flush();
113}
114
115//
116////////////////////////////////////////////////////////////////////////////
117void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
118 bncTime epoTime;
119 unsigned int updateInt;
120 int numCorr;
121 string staID;
122 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::orbCorr) {
123 return;
124 }
125 for (int ii = 0; ii < numCorr; ii++) {
126 t_orbCorr corr;
127 corr._time = epoTime;
128 corr._updateInt = updateInt;
129 corr._staID = staID;
130
131 string line;
132 getline(inStream, line);
133 istringstream in(line.c_str());
134
135 in >> corr._prn >> corr._iod
136 >> corr._xr[0] >> corr._xr[1] >> corr._xr[2]
137 >> corr._dotXr[0] >> corr._dotXr[1] >> corr._dotXr[2];
138
139 corr._dotXr[0] /= 1.e3; // mm/s => m/s
140 corr._dotXr[1] /= 1.e3; // mm/s => m/s
141 corr._dotXr[2] /= 1.e3; // mm/s => m/s
142
143 if (corr._prn.system() == 'E') {
144 corr._prn.setFlags(1);// I/NAV
145 }
146 corrList.push_back(corr);
147 }
148}
149
150// Constructor
151////////////////////////////////////////////////////////////////////////////
152t_URA::t_URA() {
153 _updateInt = 0;
154 _iod = 0;
155 _ura = 0.0;
156}
157
158//
159////////////////////////////////////////////////////////////////////////////
160void t_URA::writeEpoch(ostream* out, const QList<t_URA>& corrList) {
161 if (!out || corrList.size() == 0) {
162 return;
163 }
164 out->setf(ios::fixed);
165 bncTime epoTime;
166 QListIterator<t_URA> it(corrList);
167 while (it.hasNext()) {
168 const t_URA& corr = it.next();
169 if (!epoTime.valid()) {
170 epoTime = corr._time;
171 *out << "> URA " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
172 << corr._updateInt << " "
173 << corrList.size() << ' ' << corr._staID << endl;
174 }
175 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
176 << setw(10) << setprecision(4) << corr._ura << endl;
177 }
178 out->flush();
179}
180
181//
182////////////////////////////////////////////////////////////////////////////
183void t_URA::readEpoch(const string& epoLine, istream& inStream, QList<t_URA>& corrList) {
184 bncTime epoTime;
185 unsigned int updateInt;
186 int numCorr;
187 string staID;
188 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::URA) {
189 return;
190 }
191 for (int ii = 0; ii < numCorr; ii++) {
192 t_URA corr;
193 corr._time = epoTime;
194 corr._updateInt = updateInt;
195 corr._staID = staID;
196
197 string line;
198 getline(inStream, line);
199 istringstream in(line.c_str());
200
201 in >> corr._prn >> corr._iod >> corr._ura;
202
203 corrList.push_back(corr);
204 }
205}
206
207//
208////////////////////////////////////////////////////////////////////////////
209void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
210 if (!out || biasList.size() == 0) {
211 return;
212 }
213 out->setf(ios::fixed);
214 bncTime epoTime;
215 QListIterator<t_satCodeBias> it(biasList);
216 while (it.hasNext()) {
217 const t_satCodeBias& satCodeBias = it.next();
218 if (!epoTime.valid()) {
219 epoTime = satCodeBias._time;
220 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
221 << satCodeBias._updateInt << " "
222 << biasList.size() << ' ' << satCodeBias._staID << endl;
223 }
224 if (!satCodeBias._bias.size()) {
225 continue;
226 }
227 *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
228 for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
229 const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
230 *out << " " << frqCodeBias._rnxType2ch << ' '
231 << setw(10) << setprecision(4) << frqCodeBias._value;
232 }
233 *out << endl;
234 }
235 out->flush();
236}
237
238//
239////////////////////////////////////////////////////////////////////////////
240void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
241 bncTime epoTime;
242 unsigned int updateInt;
243 int numSat;
244 string staID;
245 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::codeBias) {
246 return;
247 }
248 for (int ii = 0; ii < numSat; ii++) {
249 t_satCodeBias satCodeBias;
250 satCodeBias._time = epoTime;
251 satCodeBias._updateInt = updateInt;
252 satCodeBias._staID = staID;
253
254 string line;
255 getline(inStream, line);
256 istringstream in(line.c_str());
257
258 int numBias;
259 in >> satCodeBias._prn >> numBias;
260
261 while (in.good()) {
262 t_frqCodeBias frqCodeBias;
263 in >> frqCodeBias._rnxType2ch >> frqCodeBias._value;
264 if (!frqCodeBias._rnxType2ch.empty()) {
265 satCodeBias._bias.push_back(frqCodeBias);
266 }
267 }
268
269 biasList.push_back(satCodeBias);
270 }
271}
272
273//
274////////////////////////////////////////////////////////////////////////////
275void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
276 if (!out || biasList.size() == 0) {
277 return;
278 }
279 out->setf(ios::fixed);
280 bncTime epoTime;
281 QListIterator<t_satPhaseBias> it(biasList);
282 while (it.hasNext()) {
283 const t_satPhaseBias& satPhaseBias = it.next();
284 if (!epoTime.valid()) {
285 epoTime = satPhaseBias._time;
286 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
287 << satPhaseBias._updateInt << " "
288 << biasList.size() << ' ' << satPhaseBias._staID << endl;
289 *out << " " << satPhaseBias._dispBiasConstistInd << " "
290 << satPhaseBias._MWConsistInd << endl;
291 }
292 *out << satPhaseBias._prn.toString() << ' '
293 << setw(12) << setprecision(8) << satPhaseBias._yaw * 180.0 / M_PI << ' '
294 << setw(12) << setprecision(8) << satPhaseBias._yawRate * 180.0 / M_PI<< " "
295 << setw(2) << satPhaseBias._bias.size();
296 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
297 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
298 *out << " " << frqPhaseBias._rnxType2ch << ' '
299 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
300 << setw(3) << frqPhaseBias._fixIndicator << ' '
301 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
302 << setw(3) << frqPhaseBias._jumpCounter;
303 }
304 *out << endl;
305 }
306 out->flush();
307}
308
309//
310////////////////////////////////////////////////////////////////////////////
311void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
312 bncTime epoTime;
313 unsigned int updateInt;
314 int numSat;
315 string staID;
316 unsigned int dispInd;
317 unsigned int mwInd;
318 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
319 return;
320 }
321 for (int ii = 0; ii <= numSat; ii++) {
322 t_satPhaseBias satPhaseBias;
323 satPhaseBias._time = epoTime;
324 satPhaseBias._updateInt = updateInt;
325 satPhaseBias._staID = staID;
326
327 string line;
328 getline(inStream, line);
329 istringstream in(line.c_str());
330
331 if (ii == 0) {
332 in >> dispInd >> mwInd;
333 continue;
334 }
335 satPhaseBias._dispBiasConstistInd = dispInd;
336 satPhaseBias._MWConsistInd = mwInd;
337
338 int numBias;
339 double yawDeg, yawDegRate;
340 in >> satPhaseBias._prn >> yawDeg >> yawDegRate >> numBias;
341 satPhaseBias._yaw = yawDeg * M_PI / 180.0;
342 satPhaseBias._yawRate = yawDegRate * M_PI / 180.0;
343
344 while (in.good()) {
345 t_frqPhaseBias frqPhaseBias;
346 in >> frqPhaseBias._rnxType2ch >> frqPhaseBias._value
347 >> frqPhaseBias._fixIndicator >> frqPhaseBias._fixWideLaneIndicator
348 >> frqPhaseBias._jumpCounter;
349 if (!frqPhaseBias._rnxType2ch.empty()) {
350 satPhaseBias._bias.push_back(frqPhaseBias);
351 }
352 }
353
354 biasList.push_back(satPhaseBias);
355 }
356}
357
358//
359////////////////////////////////////////////////////////////////////////////
360void t_vTec::write(ostream* out, const t_vTec& vTec) {
361 if (!out || vTec._layers.size() == 0) {
362 return;
363 }
364 out->setf(ios::fixed);
365 bncTime epoTime = vTec._time;
366 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
367 << vTec._updateInt << " "
368 << vTec._layers.size() << ' ' << vTec._staID << endl;
369 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
370 const t_vTecLayer& layer = vTec._layers[ii];
371 *out << setw(2) << ii+1 << ' '
372 << setw(2) << layer._C.Nrows()-1 << ' '
373 << setw(2) << layer._C.Ncols()-1 << ' '
374 << setw(10) << setprecision(1) << layer._height << endl
375 << setw(10) << setprecision(4) << layer._C
376 << setw(10) << setprecision(4) << layer._S;
377 }
378 out->flush();
379}
380
381//
382////////////////////////////////////////////////////////////////////////////
383void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
384 bncTime epoTime;
385 unsigned int updateInt;
386 int numLayers;
387 string staID;
388 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numLayers, staID) != t_corrSSR::vTec) {
389 return;
390 }
391 if (numLayers <= 0) {
392 return;
393 }
394 vTec._time = epoTime;
395 vTec._updateInt = updateInt;
396 vTec._staID = staID;
397 for (int ii = 0; ii < numLayers; ii++) {
398 t_vTecLayer layer;
399
400 string line;
401 getline(inStream, line);
402 istringstream in(line.c_str());
403
404 int dummy, maxDeg, maxOrd;
405 in >> dummy >> maxDeg >> maxOrd >> layer._height;
406
407 layer._C.ReSize(maxDeg+1, maxOrd+1);
408 layer._S.ReSize(maxDeg+1, maxOrd+1);
409
410 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
411 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
412 inStream >> layer._C[iDeg][iOrd];
413 }
414 }
415 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
416 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
417 inStream >> layer._S[iDeg][iOrd];
418 }
419 }
420
421 vTec._layers.push_back(layer);
422 }
423}
424
425//
426////////////////////////////////////////////////////////////////////////////
427t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
428 unsigned int& updateInt, int& numEntries,
429 string& staID) {
430
431 istringstream inLine(line.c_str());
432
433 char epoChar;
434 string typeString;
435 int year, month, day, hour, min;
436 double sec;
437
438 inLine >> epoChar >> typeString
439 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
440
441 if (epoChar == '>') {
442 epoTime.set(year, month, day, hour, min, sec);
443 if (typeString == "CLOCK") {
444 return clkCorr;
445 }
446 else if (typeString == "ORBIT") {
447 return orbCorr;
448 }
449 else if (typeString == "CODE_BIAS") {
450 return codeBias;
451 }
452 else if (typeString == "PHASE_BIAS") {
453 return phaseBias;
454 }
455 else if (typeString == "VTEC") {
456 return vTec;
457 }
458 else if (typeString == "URA") {
459 return URA;
460 }
461 }
462
463 return unknown;
464}
Note: See TracBrowser for help on using the repository browser.