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

Last change on this file since 10993 was 10993, checked in by stuerze, 9 days ago

minor changes to allow different formulas for the computation of the relativistic effects in GPS position determination for RTCM-SSR and IGS-SSR

File size: 16.0 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 << ' ' // m
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
67 char sys = corr._prn.system();
68 int num = corr._prn.number();
69 int flag = t_corrSSR::getSsrNavTypeFlag(sys, num);
70 corr._prn.setFlag(flag);
71
72 corr._dClk /= (t_CST::c);
73 corr._dotDClk /= (t_CST::c * 1.e3);
74 corr._dotDotDClk /= (t_CST::c * 1.e3);
75
76 corrList.push_back(corr);
77 }
78}
79
80// Constructor
81////////////////////////////////////////////////////////////////////////////
82t_orbCorr::t_orbCorr() {
83 _updateInt = 0;
84 _iod = 0;
85 _system = 'R';
86 _xr.ReSize(3); _xr = 0.0;
87 _dotXr.ReSize(3); _dotXr = 0.0;
88 _rtcmSsr = false;
89}
90
91//
92////////////////////////////////////////////////////////////////////////////
93void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
94 if (!out || corrList.size() == 0) {
95 return;
96 }
97 out->setf(ios::fixed);
98 bncTime epoTime;
99 QListIterator<t_orbCorr> it(corrList);
100 while (it.hasNext()) {
101 const t_orbCorr& corr = it.next();
102 if (!epoTime.valid()) {
103 epoTime = corr._time;
104 *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
105 << corr._updateInt << " "
106 << corrList.size() << ' ' << corr._staID << endl;
107 }
108 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
109 << setw(10) << setprecision(4) << corr._xr[0] << ' '
110 << setw(10) << setprecision(4) << corr._xr[1] << ' '
111 << setw(10) << setprecision(4) << corr._xr[2] << " "
112 << setw(10) << setprecision(4) << corr._dotXr[0] * 1.e3 << ' ' // m/s => mm/s
113 << setw(10) << setprecision(4) << corr._dotXr[1] * 1.e3 << ' ' // m/s => mm/s
114 << setw(10) << setprecision(4) << corr._dotXr[2] * 1.e3 << ' ' // m/s => mm/s
115 << (corr._rtcmSsr ? 1 : 0) << endl;
116 }
117 out->flush();
118}
119
120//
121////////////////////////////////////////////////////////////////////////////
122void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
123 bncTime epoTime;
124 unsigned int updateInt;
125 int numCorr;
126 string staID;
127 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::orbCorr) {
128 return;
129 }
130 for (int ii = 0; ii < numCorr; ii++) {
131 t_orbCorr corr;
132 corr._time = epoTime;
133 corr._updateInt = updateInt;
134 corr._staID = staID;
135
136 string line;
137 getline(inStream, line);
138 istringstream in(line.c_str());
139
140 in >> corr._prn >> corr._iod
141 >> corr._xr[0] >> corr._xr[1] >> corr._xr[2]
142 >> corr._dotXr[0] >> corr._dotXr[1] >> corr._dotXr[2];
143
144 char sys = corr._prn.system();
145 int num = corr._prn.number();
146 int flag = t_corrSSR::getSsrNavTypeFlag(sys, num);
147 corr._prn.setFlag(flag);
148
149 corr._dotXr[0] /= 1.e3; // mm/s => m/s
150 corr._dotXr[1] /= 1.e3; // mm/s => m/s
151 corr._dotXr[2] /= 1.e3; // mm/s => m/s
152
153 // Optional trailing column - absent in files written before this field
154 // existed, in which case the source format is unknown and defaults to
155 // the classic eccentricity-based relativistic correction.
156 int rtcmSsrFlag = 0;
157 if (in >> rtcmSsrFlag) {
158 corr._rtcmSsr = (rtcmSsrFlag != 0);
159 }
160 else {
161 corr._rtcmSsr = false;
162 }
163
164 corrList.push_back(corr);
165 }
166}
167
168// Constructor
169////////////////////////////////////////////////////////////////////////////
170t_URA::t_URA() {
171 _updateInt = 0;
172 _iod = 0;
173 _ura = 0.0;
174}
175
176//
177////////////////////////////////////////////////////////////////////////////
178void t_URA::writeEpoch(ostream* out, const QList<t_URA>& corrList) {
179 if (!out || corrList.size() == 0) {
180 return;
181 }
182 out->setf(ios::fixed);
183 bncTime epoTime;
184 QListIterator<t_URA> it(corrList);
185 while (it.hasNext()) {
186 const t_URA& corr = it.next();
187 if (!epoTime.valid()) {
188 epoTime = corr._time;
189 *out << "> URA " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
190 << corr._updateInt << " "
191 << corrList.size() << ' ' << corr._staID << endl;
192 }
193 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
194 << setw(10) << setprecision(4) << corr._ura << endl;
195 }
196 out->flush();
197}
198
199//
200////////////////////////////////////////////////////////////////////////////
201void t_URA::readEpoch(const string& epoLine, istream& inStream, QList<t_URA>& corrList) {
202 bncTime epoTime;
203 unsigned int updateInt;
204 int numCorr;
205 string staID;
206 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::URA) {
207 return;
208 }
209 for (int ii = 0; ii < numCorr; ii++) {
210 t_URA corr;
211 corr._time = epoTime;
212 corr._updateInt = updateInt;
213 corr._staID = staID;
214
215 string line;
216 getline(inStream, line);
217 istringstream in(line.c_str());
218
219 in >> corr._prn >> corr._iod >> corr._ura;
220
221 char sys = corr._prn.system();
222 int num = corr._prn.number();
223 int flag = t_corrSSR::getSsrNavTypeFlag(sys, num);
224 corr._prn.setFlag(flag);
225
226 corrList.push_back(corr);
227 }
228}
229
230//
231////////////////////////////////////////////////////////////////////////////
232void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
233 if (!out || biasList.size() == 0) {
234 return;
235 }
236 out->setf(ios::fixed);
237 bncTime epoTime;
238 QListIterator<t_satCodeBias> it(biasList);
239 while (it.hasNext()) {
240 const t_satCodeBias& satCodeBias = it.next();
241 if (!epoTime.valid()) {
242 epoTime = satCodeBias._time;
243 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
244 << satCodeBias._updateInt << " "
245 << biasList.size() << ' ' << satCodeBias._staID << endl;
246 }
247 *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
248 for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
249 const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
250 *out << " " << frqCodeBias._rnxType2ch << ' '
251 << setw(10) << setprecision(4) << frqCodeBias._value;
252 }
253 *out << endl;
254 }
255 out->flush();
256}
257
258//
259////////////////////////////////////////////////////////////////////////////
260void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
261 bncTime epoTime;
262 unsigned int updateInt;
263 int numSat;
264 string staID;
265 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::codeBias) {
266 return;
267 }
268 for (int ii = 0; ii < numSat; ii++) {
269 t_satCodeBias satCodeBias;
270 satCodeBias._time = epoTime;
271 satCodeBias._updateInt = updateInt;
272 satCodeBias._staID = staID;
273
274 string line;
275 getline(inStream, line);
276 istringstream in(line.c_str());
277
278 int numBias;
279 in >> satCodeBias._prn >> numBias;
280
281 char sys = satCodeBias._prn.system();
282 int num = satCodeBias._prn.number();
283 int flag = t_corrSSR::getSsrNavTypeFlag(sys, num);
284 satCodeBias._prn.setFlag(flag);
285
286 while (in.good()) {
287 t_frqCodeBias frqCodeBias;
288 in >> frqCodeBias._rnxType2ch >> frqCodeBias._value;
289 if (!frqCodeBias._rnxType2ch.empty()) {
290 satCodeBias._bias.push_back(frqCodeBias);
291 }
292 }
293
294 biasList.push_back(satCodeBias);
295 }
296}
297
298//
299////////////////////////////////////////////////////////////////////////////
300void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
301 if (!out || biasList.size() == 0) {
302 return;
303 }
304 out->setf(ios::fixed);
305 bncTime epoTime;
306 QListIterator<t_satPhaseBias> it(biasList);
307 while (it.hasNext()) {
308 const t_satPhaseBias& satPhaseBias = it.next();
309 if (!epoTime.valid()) {
310 epoTime = satPhaseBias._time;
311 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
312 << satPhaseBias._updateInt << " "
313 << biasList.size() << ' ' << satPhaseBias._staID << endl;
314 *out << " " << satPhaseBias._dispBiasConstistInd << " "
315 << satPhaseBias._MWConsistInd << endl;
316 }
317 *out << satPhaseBias._prn.toString() << ' '
318 << setw(12) << setprecision(8) << satPhaseBias._yaw * 180.0 / M_PI << ' '
319 << setw(12) << setprecision(8) << satPhaseBias._yawRate * 180.0 / M_PI<< " "
320 << setw(2) << satPhaseBias._bias.size();
321 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
322 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
323 *out << " " << frqPhaseBias._rnxType2ch << ' '
324 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
325 << setw(3) << frqPhaseBias._fixIndicator << ' '
326 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
327 << setw(3) << frqPhaseBias._jumpCounter;
328 }
329 *out << endl;
330 }
331 out->flush();
332}
333
334//
335////////////////////////////////////////////////////////////////////////////
336void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
337 bncTime epoTime;
338 unsigned int updateInt;
339 int numSat;
340 string staID;
341 unsigned int dispInd;
342 unsigned int mwInd;
343 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
344 return;
345 }
346 for (int ii = 0; ii <= numSat; ii++) {
347 t_satPhaseBias satPhaseBias;
348 satPhaseBias._time = epoTime;
349 satPhaseBias._updateInt = updateInt;
350 satPhaseBias._staID = staID;
351
352 string line;
353 getline(inStream, line);
354 istringstream in(line.c_str());
355
356 if (ii == 0) {
357 in >> dispInd >> mwInd;
358 continue;
359 }
360 satPhaseBias._dispBiasConstistInd = dispInd;
361 satPhaseBias._MWConsistInd = mwInd;
362
363 int numBias;
364 double yawDeg, yawDegRate;
365 in >> satPhaseBias._prn >> yawDeg >> yawDegRate >> numBias;
366 satPhaseBias._yaw = yawDeg * M_PI / 180.0;
367 satPhaseBias._yawRate = yawDegRate * M_PI / 180.0;
368
369 char sys = satPhaseBias._prn.system();
370 int num = satPhaseBias._prn.number();
371 int flag = t_corrSSR::getSsrNavTypeFlag(sys, num);
372 satPhaseBias._prn.setFlag(flag);
373
374 while (in.good()) {
375 t_frqPhaseBias frqPhaseBias;
376 in >> frqPhaseBias._rnxType2ch >> frqPhaseBias._value
377 >> frqPhaseBias._fixIndicator >> frqPhaseBias._fixWideLaneIndicator
378 >> frqPhaseBias._jumpCounter;
379 if (!frqPhaseBias._rnxType2ch.empty()) {
380 satPhaseBias._bias.push_back(frqPhaseBias);
381 }
382 }
383
384 biasList.push_back(satPhaseBias);
385 }
386}
387
388//
389////////////////////////////////////////////////////////////////////////////
390void t_vTec::write(ostream* out, const t_vTec& vTec) {
391 if (!out || vTec._layers.size() == 0) {
392 return;
393 }
394 out->setf(ios::fixed);
395 bncTime epoTime = vTec._time;
396 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
397 << vTec._updateInt << " "
398 << vTec._layers.size() << ' ' << vTec._staID << endl;
399 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
400 const t_vTecLayer& layer = vTec._layers[ii];
401 *out << setw(2) << ii+1 << ' '
402 << setw(2) << layer._C.Nrows()-1 << ' '
403 << setw(2) << layer._C.Ncols()-1 << ' '
404 << setw(10) << setprecision(1) << layer._height << endl
405 << setw(10) << setprecision(4) << layer._C
406 << setw(10) << setprecision(4) << layer._S;
407 }
408 out->flush();
409}
410
411//
412////////////////////////////////////////////////////////////////////////////
413void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
414 bncTime epoTime;
415 unsigned int updateInt;
416 int numLayers;
417 string staID;
418 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numLayers, staID) != t_corrSSR::vTec) {
419 return;
420 }
421 if (numLayers <= 0) {
422 return;
423 }
424 vTec._time = epoTime;
425 vTec._updateInt = updateInt;
426 vTec._staID = staID;
427 for (int ii = 0; ii < numLayers; ii++) {
428 t_vTecLayer layer;
429
430 string line;
431 getline(inStream, line);
432 istringstream in(line.c_str());
433
434 int dummy, maxDeg, maxOrd;
435 in >> dummy >> maxDeg >> maxOrd >> layer._height;
436
437 layer._C.ReSize(maxDeg+1, maxOrd+1);
438 layer._S.ReSize(maxDeg+1, maxOrd+1);
439
440 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
441 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
442 inStream >> layer._C[iDeg][iOrd];
443 }
444 }
445 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
446 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
447 inStream >> layer._S[iDeg][iOrd];
448 }
449 }
450
451 vTec._layers.push_back(layer);
452 }
453}
454
455//
456////////////////////////////////////////////////////////////////////////////
457t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
458 unsigned int& updateInt, int& numEntries,
459 string& staID) {
460
461 istringstream inLine(line.c_str());
462
463 char epoChar;
464 string typeString;
465 int year, month, day, hour, min;
466 double sec;
467
468 inLine >> epoChar >> typeString
469 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
470
471 if (epoChar == '>') {
472 epoTime.set(year, month, day, hour, min, sec);
473 if (typeString == "CLOCK") {
474 return clkCorr;
475 }
476 else if (typeString == "ORBIT") {
477 return orbCorr;
478 }
479 else if (typeString == "CODE_BIAS") {
480 return codeBias;
481 }
482 else if (typeString == "PHASE_BIAS") {
483 return phaseBias;
484 }
485 else if (typeString == "VTEC") {
486 return vTec;
487 }
488 else if (typeString == "URA") {
489 return URA;
490 }
491 }
492
493 return unknown;
494}
495
496// Set NAV type to force NAVtype usage according SSR standard
497/////////////////////////////////////////////////////////////
498t_eph::e_type t_corrSSR::getSsrNavTypeFlag(char sys, int num) {
499
500 t_eph::e_type flag = t_eph::undefined;
501
502 switch (sys) {
503 case 'G':
504 case 'J':
505 case 'I': // not part of the SSR standard
506 flag = t_eph::LNAV;
507 break;
508 case 'R':
509 flag = t_eph::FDMA_M;
510 break;
511 case 'E':
512 flag = t_eph::INAV;
513 break;
514 case 'C':
515 if (num < 6) {// GEO
516 flag = t_eph::D2;
517 }
518 else if (num > 58 && num < 63) { // GEO
519 flag = t_eph::D2;
520 }
521 else {
522 flag = t_eph::D1;
523 }
524 break;
525 case 'S':
526 flag = t_eph::SBASL1;
527 break;
528 }
529
530 return flag;
531}
Note: See TracBrowser for help on using the repository browser.