source: ntrip/branches/BNC_2.12/src/ephemeris.cpp@ 8929

Last change on this file since 8929 was 8929, checked in by stuerze, 4 years ago

GPS fit intervall: different specifications in differet RINEX versions are now considerred

File size: 50.0 KB
RevLine 
[1025]1#include <sstream>
[2234]2#include <iostream>
[1025]3#include <iomanip>
[1239]4#include <cstring>
[1025]5
[2234]6#include <newmatio.h>
7
[1025]8#include "ephemeris.h"
[2221]9#include "bncutils.h"
[2285]10#include "bnctime.h"
[5070]11#include "bnccore.h"
[5839]12#include "bncutils.h"
[6141]13#include "satObs.h"
[6044]14#include "pppInclude.h"
[6400]15#include "pppModel.h"
[1025]16
17using namespace std;
18
[5749]19// Constructor
20////////////////////////////////////////////////////////////////////////////
21t_eph::t_eph() {
[6518]22 _checkState = unchecked;
23 _orbCorr = 0;
24 _clkCorr = 0;
[5749]25}
[7278]26// Destructor
27////////////////////////////////////////////////////////////////////////////
28t_eph::~t_eph() {
29 if (_orbCorr)
30 delete _orbCorr;
31 if (_clkCorr)
32 delete _clkCorr;
33}
[5749]34
[7481]35//
[5749]36////////////////////////////////////////////////////////////////////////////
[6141]37void t_eph::setOrbCorr(const t_orbCorr* orbCorr) {
[8006]38 if (_orbCorr) {
39 delete _orbCorr;
40 _orbCorr = 0;
41 }
[6141]42 _orbCorr = new t_orbCorr(*orbCorr);
[5749]43}
44
[7481]45//
[5749]46////////////////////////////////////////////////////////////////////////////
[6141]47void t_eph::setClkCorr(const t_clkCorr* clkCorr) {
[8006]48 if (_clkCorr) {
49 delete _clkCorr;
50 _clkCorr = 0;
51 }
[6141]52 _clkCorr = new t_clkCorr(*clkCorr);
[5749]53}
54
[7481]55//
[5749]56////////////////////////////////////////////////////////////////////////////
[6109]57t_irc t_eph::getCrd(const bncTime& tt, ColumnVector& xc, ColumnVector& vv, bool useCorr) const {
[6518]58
[8420]59 if (_checkState == bad ||
[8615]60 _checkState == unhealthy ||
61 _checkState == outdated) {
[6518]62 return failure;
63 }
[6556]64 const QVector<int> updateInt = QVector<int>() << 1 << 2 << 5 << 10 << 15 << 30
65 << 60 << 120 << 240 << 300 << 600
66 << 900 << 1800 << 3600 << 7200
67 << 10800;
[8541]68 xc.ReSize(6);
[5749]69 vv.ReSize(3);
[6213]70 if (position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data()) != success) {
71 return failure;
72 }
[5789]73 if (useCorr) {
[5839]74 if (_orbCorr && _clkCorr) {
[5849]75 double dtO = tt - _orbCorr->_time;
[6556]76 if (_orbCorr->_updateInt) {
77 dtO -= (0.5 * updateInt[_orbCorr->_updateInt]);
78 }
[5839]79 ColumnVector dx(3);
[5849]80 dx[0] = _orbCorr->_xr[0] + _orbCorr->_dotXr[0] * dtO;
81 dx[1] = _orbCorr->_xr[1] + _orbCorr->_dotXr[1] * dtO;
82 dx[2] = _orbCorr->_xr[2] + _orbCorr->_dotXr[2] * dtO;
83
[7133]84 RSW_to_XYZ(xc.Rows(1,3), vv.Rows(1,3), dx, dx);
[5849]85
[5839]86 xc[0] -= dx[0];
87 xc[1] -= dx[1];
88 xc[2] -= dx[2];
[5849]89
[7133]90 ColumnVector dv(3);
91 RSW_to_XYZ(xc.Rows(1,3), vv.Rows(1,3), _orbCorr->_dotXr, dv);
92
93 vv[0] -= dv[0];
94 vv[1] -= dv[1];
95 vv[2] -= dv[2];
96
[5849]97 double dtC = tt - _clkCorr->_time;
[6556]98 if (_clkCorr->_updateInt) {
99 dtC -= (0.5 * updateInt[_clkCorr->_updateInt]);
100 }
[7014]101 xc[3] += _clkCorr->_dClk + _clkCorr->_dotDClk * dtC + _clkCorr->_dotDotDClk * dtC * dtC;
[5839]102 }
103 else {
104 return failure;
105 }
[5749]106 }
107 return success;
108}
109
[6801]110//
111//////////////////////////////////////////////////////////////////////////////
112QString t_eph::rinexDateStr(const bncTime& tt, const t_prn& prn, double version) {
113 QString prnStr(prn.toString().c_str());
114 return rinexDateStr(tt, prnStr, version);
115}
116
117//
118//////////////////////////////////////////////////////////////////////////////
119QString t_eph::rinexDateStr(const bncTime& tt, const QString& prnStr, double version) {
120
121 QString datStr;
122
123 unsigned year, month, day, hour, min;
124 double sec;
125 tt.civil_date(year, month, day);
126 tt.civil_time(hour, min, sec);
127
128 QTextStream out(&datStr);
129
130 if (version < 3.0) {
131 QString prnHlp = prnStr.mid(1,2); if (prnHlp[0] == '0') prnHlp[0] = ' ';
132 out << prnHlp << QString(" %1 %2 %3 %4 %5%6")
133 .arg(year % 100, 2, 10, QChar('0'))
134 .arg(month, 2)
135 .arg(day, 2)
136 .arg(hour, 2)
137 .arg(min, 2)
138 .arg(sec, 5, 'f',1);
139 }
140 else {
141 out << prnStr << QString(" %1 %2 %3 %4 %5 %6")
142 .arg(year, 4)
143 .arg(month, 2, 10, QChar('0'))
144 .arg(day, 2, 10, QChar('0'))
145 .arg(hour, 2, 10, QChar('0'))
146 .arg(min, 2, 10, QChar('0'))
147 .arg(int(sec), 2, 10, QChar('0'));
148 }
149
150 return datStr;
151}
152
153// Constructor
154//////////////////////////////////////////////////////////////////////////////
155t_ephGPS::t_ephGPS(float rnxVersion, const QStringList& lines) {
156
157 const int nLines = 8;
158
159 if (lines.size() != nLines) {
160 _checkState = bad;
161 return;
162 }
163
164 // RINEX Format
165 // ------------
166 int fieldLen = 19;
167
168 int pos[4];
169 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
170 pos[1] = pos[0] + fieldLen;
171 pos[2] = pos[1] + fieldLen;
172 pos[3] = pos[2] + fieldLen;
173
174 // Read eight lines
175 // ----------------
176 for (int iLine = 0; iLine < nLines; iLine++) {
177 QString line = lines[iLine];
178
179 if ( iLine == 0 ) {
180 QTextStream in(line.left(pos[1]).toAscii());
181 int year, month, day, hour, min;
182 double sec;
183
[7139]184 QString prnStr, n;
[6880]185 in >> prnStr;
[7639]186
187 if (prnStr.size() == 1 &&
[8167]188 (prnStr[0] == 'G' ||
189 prnStr[0] == 'J' ||
190 prnStr[0] == 'I')) {
[7139]191 in >> n;
192 prnStr.append(n);
[6880]193 }
[7639]194
[6880]195 in >> year >> month >> day >> hour >> min >> sec;
[6801]196 if (prnStr.at(0) == 'G') {
197 _prn.set('G', prnStr.mid(1).toInt());
198 }
199 else if (prnStr.at(0) == 'J') {
200 _prn.set('J', prnStr.mid(1).toInt());
201 }
[8167]202 else if (prnStr.at(0) == 'I') {
203 _prn.set('I', prnStr.mid(1).toInt());
204 }
[6801]205 else {
206 _prn.set('G', prnStr.toInt());
207 }
208
209 if (year < 80) {
210 year += 2000;
211 }
212 else if (year < 100) {
213 year += 1900;
214 }
215
216 _TOC.set(year, month, day, hour, min, sec);
217
218 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
219 readDbl(line, pos[2], fieldLen, _clock_drift ) ||
220 readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
221 _checkState = bad;
222 return;
223 }
224 }
225
226 else if ( iLine == 1 ) {
227 if ( readDbl(line, pos[0], fieldLen, _IODE ) ||
228 readDbl(line, pos[1], fieldLen, _Crs ) ||
229 readDbl(line, pos[2], fieldLen, _Delta_n) ||
230 readDbl(line, pos[3], fieldLen, _M0 ) ) {
231 _checkState = bad;
232 return;
233 }
234 }
235
236 else if ( iLine == 2 ) {
237 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
238 readDbl(line, pos[1], fieldLen, _e ) ||
239 readDbl(line, pos[2], fieldLen, _Cus ) ||
240 readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
241 _checkState = bad;
242 return;
243 }
244 }
245
246 else if ( iLine == 3 ) {
247 if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
248 readDbl(line, pos[1], fieldLen, _Cic ) ||
249 readDbl(line, pos[2], fieldLen, _OMEGA0) ||
250 readDbl(line, pos[3], fieldLen, _Cis ) ) {
251 _checkState = bad;
252 return;
253 }
254 }
255
256 else if ( iLine == 4 ) {
257 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
258 readDbl(line, pos[1], fieldLen, _Crc ) ||
259 readDbl(line, pos[2], fieldLen, _omega ) ||
260 readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
261 _checkState = bad;
262 return;
263 }
264 }
265
[8167]266 else if ( iLine == 5 && type() != t_eph::IRNSS) {
[6801]267 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
268 readDbl(line, pos[1], fieldLen, _L2Codes) ||
269 readDbl(line, pos[2], fieldLen, _TOEweek ) ||
270 readDbl(line, pos[3], fieldLen, _L2PFlag) ) {
271 _checkState = bad;
272 return;
273 }
274 }
[8167]275 else if ( iLine == 5 && type() == t_eph::IRNSS) {
276 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
277 readDbl(line, pos[2], fieldLen, _TOEweek) ) {
278 _checkState = bad;
279 return;
280 }
281 }
[6801]282
[8167]283 else if ( iLine == 6 && type() != t_eph::IRNSS) {
[6801]284 if ( readDbl(line, pos[0], fieldLen, _ura ) ||
285 readDbl(line, pos[1], fieldLen, _health) ||
286 readDbl(line, pos[2], fieldLen, _TGD ) ||
287 readDbl(line, pos[3], fieldLen, _IODC ) ) {
288 _checkState = bad;
289 return;
290 }
291 }
[8167]292 else if ( iLine == 6 && type() == t_eph::IRNSS) {
293 if ( readDbl(line, pos[0], fieldLen, _ura ) ||
294 readDbl(line, pos[1], fieldLen, _health) ||
295 readDbl(line, pos[2], fieldLen, _TGD ) ) {
296 _checkState = bad;
297 return;
298 }
299 }
[6801]300
301 else if ( iLine == 7 ) {
302 if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
303 _checkState = bad;
304 return;
305 }
[8926]306 // fitInterval is not valid for IRNSS
307 if (type() != t_eph::IRNSS) {
308 double fitIntervalRnx;
309 readDbl(line, pos[1], fieldLen, fitIntervalRnx);
[8929]310 if (type() == t_eph::GPS) {
311 if (rnxVersion < 3.03) {// specified as flag for GPS
312 _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::GPS);
313 } else { // specified as time period for GPS since 3.03
314 _fitInterval = fitIntervalRnx;
315 }
[8926]316 } else if (type() == t_eph::QZSS) { // specified as flag for QZSS
317 _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::QZSS);
318 }
319 }
[6801]320 }
321 }
322}
323
[2222]324// Compute GPS Satellite Position (virtual)
[1025]325////////////////////////////////////////////////////////////////////////////
[6213]326t_irc t_ephGPS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
[1025]327
[1098]328 static const double omegaEarth = 7292115.1467e-11;
[5277]329 static const double gmGRS = 398.6005e12;
[1025]330
[8541]331 memset(xc, 0, 6*sizeof(double));
[1025]332 memset(vv, 0, 3*sizeof(double));
333
334 double a0 = _sqrt_A * _sqrt_A;
335 if (a0 == 0) {
[6213]336 return failure;
[1025]337 }
338
[5277]339 double n0 = sqrt(gmGRS/(a0*a0*a0));
[4018]340
341 bncTime tt(GPSweek, GPSweeks);
[4543]342 double tk = tt - bncTime(int(_TOEweek), _TOEsec);
[4018]343
[1025]344 double n = n0 + _Delta_n;
345 double M = _M0 + n*tk;
346 double E = M;
347 double E_last;
[8370]348 int nLoop = 0;
[1025]349 do {
350 E_last = E;
351 E = M + _e*sin(E);
[8455]352
[8370]353 if (++nLoop == 100) {
354 return failure;
355 }
[1025]356 } while ( fabs(E-E_last)*a0 > 0.001 );
357 double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
358 double u0 = v + _omega;
359 double sin2u0 = sin(2*u0);
360 double cos2u0 = cos(2*u0);
361 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
362 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
363 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
364 double xp = r*cos(u);
365 double yp = r*sin(u);
[7481]366 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
[4018]367 omegaEarth*_TOEsec;
[7278]368
[1025]369 double sinom = sin(OM);
370 double cosom = cos(OM);
371 double sini = sin(i);
372 double cosi = cos(i);
373 xc[0] = xp*cosom - yp*cosi*sinom;
374 xc[1] = xp*sinom + yp*cosi*cosom;
[7481]375 xc[2] = yp*sini;
376
[4018]377 double tc = tt - _TOC;
[2429]378 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
[1025]379
380 // Velocity
381 // --------
382 double tanv2 = tan(v/2);
383 double dEdM = 1 / (1 - _e*cos(E));
[7278]384 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
[1025]385 * dEdM * n;
386 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
387 double dotom = _OMEGADOT - omegaEarth;
388 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
[7278]389 double dotr = a0 * _e*sin(E) * dEdM * n
[1025]390 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
391 double dotx = dotr*cos(u) - r*sin(u)*dotu;
392 double doty = dotr*sin(u) + r*cos(u)*dotu;
393
394 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
395 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
396 + yp*sini*sinom*doti; // dX / di
397
398 vv[1] = sinom *dotx + cosi*cosom *doty
399 + xp*cosom*dotom - yp*cosi*sinom*dotom
400 - yp*sini*cosom*doti;
401
402 vv[2] = sini *doty + yp*cosi *doti;
[2429]403
404 // Relativistic Correction
405 // -----------------------
[7481]406 // correspondent to IGS convention and GPS ICD (and SSR standard)
[2429]407 xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
[6213]408
[8541]409 xc[4] = _clock_drift + _clock_driftrate*tc;
410 xc[5] = _clock_driftrate;
411
[6213]412 return success;
[1025]413}
414
[6801]415// RINEX Format String
416//////////////////////////////////////////////////////////////////////////////
417QString t_ephGPS::toString(double version) const {
[2221]418
[6801]419 QString rnxStr = rinexDateStr(_TOC, _prn, version);
[2221]420
[6801]421 QTextStream out(&rnxStr);
[2221]422
[6801]423 out << QString("%1%2%3\n")
424 .arg(_clock_bias, 19, 'e', 12)
425 .arg(_clock_drift, 19, 'e', 12)
426 .arg(_clock_driftrate, 19, 'e', 12);
[2221]427
[6801]428 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
[2221]429
[8167]430 out << QString(fmt)
[6801]431 .arg(_IODE, 19, 'e', 12)
432 .arg(_Crs, 19, 'e', 12)
433 .arg(_Delta_n, 19, 'e', 12)
434 .arg(_M0, 19, 'e', 12);
435
436 out << QString(fmt)
437 .arg(_Cuc, 19, 'e', 12)
438 .arg(_e, 19, 'e', 12)
439 .arg(_Cus, 19, 'e', 12)
440 .arg(_sqrt_A, 19, 'e', 12);
441
442 out << QString(fmt)
443 .arg(_TOEsec, 19, 'e', 12)
444 .arg(_Cic, 19, 'e', 12)
445 .arg(_OMEGA0, 19, 'e', 12)
446 .arg(_Cis, 19, 'e', 12);
447
448 out << QString(fmt)
449 .arg(_i0, 19, 'e', 12)
450 .arg(_Crc, 19, 'e', 12)
451 .arg(_omega, 19, 'e', 12)
452 .arg(_OMEGADOT, 19, 'e', 12);
453
[8167]454 if (type() == t_eph::IRNSS) {
455 out << QString(fmt)
456 .arg(_IDOT, 19, 'e', 12)
[8804]457 .arg(0.0, 19, 'e', 12)
[8167]458 .arg(_TOEweek, 19, 'e', 12)
[8804]459 .arg(0.0, 19, 'e', 12);
[8167]460 }
461 else {
462 out << QString(fmt)
463 .arg(_IDOT, 19, 'e', 12)
464 .arg(_L2Codes, 19, 'e', 12)
465 .arg(_TOEweek, 19, 'e', 12)
466 .arg(_L2PFlag, 19, 'e', 12);
467 }
[6801]468
[8167]469 if (type() == t_eph::IRNSS) {
470 out << QString(fmt)
471 .arg(_ura, 19, 'e', 12)
472 .arg(_health, 19, 'e', 12)
473 .arg(_TGD, 19, 'e', 12)
[8804]474 .arg(0.0, 19, 'e', 12);
[8167]475 }
476 else {
477 out << QString(fmt)
478 .arg(_ura, 19, 'e', 12)
479 .arg(_health, 19, 'e', 12)
480 .arg(_TGD, 19, 'e', 12)
481 .arg(_IODC, 19, 'e', 12);
482 }
[6801]483
[7923]484 double tot = _TOT;
485 if (tot == 0.9999e9 && version < 3.0) {
486 tot = 0.0;
487 }
[8926]488 // fitInterval
[8929]489 if (type() == t_eph::IRNSS) { // not valid for IRNSS
[8167]490 out << QString(fmt)
491 .arg(tot, 19, 'e', 12)
[8804]492 .arg(0.0, 19, 'e', 12)
[8167]493 .arg("", 19, QChar(' '))
494 .arg("", 19, QChar(' '));
495 }
496 else {
[8929]497 double fitIntervalRnx = _fitInterval; // specified as time period in hours for GPS since RINEX 3.03
498 if (type() == t_eph::GPS && version < 3.03) { // specified as flag in versions < 3.03
499 (_fitInterval == 4.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0;
500 }
501 else if (type() == t_eph::QZSS) { // specified as flag for QZSS
[8926]502 (_fitInterval == 2.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0;
503 }
[8167]504 out << QString(fmt)
[8926]505 .arg(tot, 19, 'e', 12)
506 .arg(fitIntervalRnx, 19, 'e', 12)
507 .arg("", 19, QChar(' '))
508 .arg("", 19, QChar(' '));
[8167]509 }
[6801]510
511 return rnxStr;
[2221]512}
513
[6801]514// Constructor
515//////////////////////////////////////////////////////////////////////////////
516t_ephGlo::t_ephGlo(float rnxVersion, const QStringList& lines) {
[2221]517
[6801]518 const int nLines = 4;
519
520 if (lines.size() != nLines) {
521 _checkState = bad;
522 return;
[6518]523 }
524
[6801]525 // RINEX Format
526 // ------------
527 int fieldLen = 19;
[2221]528
[6801]529 int pos[4];
530 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
531 pos[1] = pos[0] + fieldLen;
532 pos[2] = pos[1] + fieldLen;
533 pos[3] = pos[2] + fieldLen;
[2221]534
[6801]535 // Read four lines
536 // ---------------
537 for (int iLine = 0; iLine < nLines; iLine++) {
538 QString line = lines[iLine];
[2221]539
[6801]540 if ( iLine == 0 ) {
541 QTextStream in(line.left(pos[1]).toAscii());
[6213]542
[6801]543 int year, month, day, hour, min;
544 double sec;
[2221]545
[7139]546 QString prnStr, n;
[6880]547 in >> prnStr;
[7639]548 if (prnStr.size() == 1 && prnStr[0] == 'R') {
[7139]549 in >> n;
550 prnStr.append(n);
[6880]551 }
552 in >> year >> month >> day >> hour >> min >> sec;
[6801]553 if (prnStr.at(0) == 'R') {
554 _prn.set('R', prnStr.mid(1).toInt());
555 }
556 else {
557 _prn.set('R', prnStr.toInt());
558 }
[2221]559
[6801]560 if (year < 80) {
561 year += 2000;
562 }
563 else if (year < 100) {
564 year += 1900;
565 }
[2221]566
[6801]567 _gps_utc = gnumleap(year, month, day);
[2221]568
[6801]569 _TOC.set(year, month, day, hour, min, sec);
570 _TOC = _TOC + _gps_utc;
[8804]571 int nd = int((_TOC.gpssec())) / (24.0*60.0*60.0);
[6801]572 if ( readDbl(line, pos[1], fieldLen, _tau ) ||
573 readDbl(line, pos[2], fieldLen, _gamma) ||
574 readDbl(line, pos[3], fieldLen, _tki ) ) {
575 _checkState = bad;
576 return;
577 }
[8804]578 _tki -= nd * 86400.0;
579 _tau = -_tau;
[6801]580 }
581
582 else if ( iLine == 1 ) {
583 if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
584 readDbl(line, pos[1], fieldLen, _x_velocity ) ||
585 readDbl(line, pos[2], fieldLen, _x_acceleration) ||
586 readDbl(line, pos[3], fieldLen, _health ) ) {
587 _checkState = bad;
588 return;
589 }
590 }
591
592 else if ( iLine == 2 ) {
593 if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
594 readDbl(line, pos[1], fieldLen, _y_velocity ) ||
595 readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
596 readDbl(line, pos[3], fieldLen, _frequency_number) ) {
597 _checkState = bad;
598 return;
599 }
600 }
601
602 else if ( iLine == 3 ) {
603 if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
604 readDbl(line, pos[1], fieldLen, _z_velocity ) ||
605 readDbl(line, pos[2], fieldLen, _z_acceleration) ||
606 readDbl(line, pos[3], fieldLen, _E ) ) {
607 _checkState = bad;
608 return;
609 }
610 }
611 }
612
613 // Initialize status vector
614 // ------------------------
615 _tt = _TOC;
[8697]616 _xv.ReSize(6); _xv = 0.0;
[6801]617 _xv(1) = _x_pos * 1.e3;
618 _xv(2) = _y_pos * 1.e3;
619 _xv(3) = _z_pos * 1.e3;
620 _xv(4) = _x_velocity * 1.e3;
621 _xv(5) = _y_velocity * 1.e3;
622 _xv(6) = _z_velocity * 1.e3;
[2221]623}
624
[6801]625// Compute Glonass Satellite Position (virtual)
[2771]626////////////////////////////////////////////////////////////////////////////
[6801]627t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
[2771]628
[6801]629 static const double nominalStep = 10.0;
[2771]630
[8541]631 memset(xc, 0, 6*sizeof(double));
[2771]632 memset(vv, 0, 3*sizeof(double));
633
[6801]634 double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
635
[8690]636 if (fabs(dtPos) > 24 * 3600.0) {
[6213]637 return failure;
[2771]638 }
639
[6801]640 int nSteps = int(fabs(dtPos) / nominalStep) + 1;
641 double step = dtPos / nSteps;
[4018]642
[6801]643 double acc[3];
644 acc[0] = _x_acceleration * 1.e3;
645 acc[1] = _y_acceleration * 1.e3;
646 acc[2] = _z_acceleration * 1.e3;
647 for (int ii = 1; ii <= nSteps; ii++) {
648 _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
649 _tt = _tt + step;
650 }
[4018]651
[6801]652 // Position and Velocity
653 // ---------------------
654 xc[0] = _xv(1);
655 xc[1] = _xv(2);
656 xc[2] = _xv(3);
[2771]657
[6801]658 vv[0] = _xv(4);
659 vv[1] = _xv(5);
660 vv[2] = _xv(6);
[2771]661
[6801]662 // Clock Correction
663 // ----------------
664 double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
665 xc[3] = -_tau + _gamma * dtClk;
[2771]666
[8541]667 xc[4] = _gamma;
668 xc[5] = 0.0;
[8484]669
[6213]670 return success;
[2771]671}
672
[6801]673// RINEX Format String
[3659]674//////////////////////////////////////////////////////////////////////////////
[6801]675QString t_ephGlo::toString(double version) const {
[3664]676
[8804]677 QString rnxStr = rinexDateStr(_TOC -_gps_utc, _prn, version);
678 int nd = int((_TOC - _gps_utc).gpssec()) / (24.0*60.0*60.0);
[6801]679 QTextStream out(&rnxStr);
[3664]680
[6801]681 out << QString("%1%2%3\n")
[8804]682 .arg(-_tau, 19, 'e', 12)
683 .arg(_gamma, 19, 'e', 12)
684 .arg(_tki+nd*86400.0, 19, 'e', 12);
[3668]685
[6801]686 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
[3664]687
[6801]688 out << QString(fmt)
689 .arg(_x_pos, 19, 'e', 12)
690 .arg(_x_velocity, 19, 'e', 12)
691 .arg(_x_acceleration, 19, 'e', 12)
692 .arg(_health, 19, 'e', 12);
[3664]693
[6801]694 out << QString(fmt)
695 .arg(_y_pos, 19, 'e', 12)
696 .arg(_y_velocity, 19, 'e', 12)
697 .arg(_y_acceleration, 19, 'e', 12)
698 .arg(_frequency_number, 19, 'e', 12);
[3666]699
[6801]700 out << QString(fmt)
701 .arg(_z_pos, 19, 'e', 12)
702 .arg(_z_velocity, 19, 'e', 12)
703 .arg(_z_acceleration, 19, 'e', 12)
704 .arg(_E, 19, 'e', 12);
[3666]705
[6801]706 return rnxStr;
[3659]707}
708
[6801]709// Derivative of the state vector using a simple force model (static)
710////////////////////////////////////////////////////////////////////////////
711ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector& xv,
712 double* acc) {
[3659]713
[6801]714 // State vector components
715 // -----------------------
716 ColumnVector rr = xv.rows(1,3);
717 ColumnVector vv = xv.rows(4,6);
[3699]718
[6801]719 // Acceleration
[3699]720 // ------------
[6801]721 static const double gmWGS = 398.60044e12;
722 static const double AE = 6378136.0;
723 static const double OMEGA = 7292115.e-11;
724 static const double C20 = -1082.6257e-6;
[3699]725
[6801]726 double rho = rr.norm_Frobenius();
727 double t1 = -gmWGS/(rho*rho*rho);
728 double t2 = 3.0/2.0 * C20 * (gmWGS*AE*AE) / (rho*rho*rho*rho*rho);
729 double t3 = OMEGA * OMEGA;
730 double t4 = 2.0 * OMEGA;
731 double z2 = rr(3) * rr(3);
[3699]732
[6801]733 // Vector of derivatives
734 // ---------------------
735 ColumnVector va(6);
736 va(1) = vv(1);
737 va(2) = vv(2);
738 va(3) = vv(3);
739 va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2) + acc[0];
740 va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1) + acc[1];
741 va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho)) ) * rr(3) + acc[2];
[3699]742
[6801]743 return va;
744}
[3699]745
[6801]746// IOD of Glonass Ephemeris (virtual)
747////////////////////////////////////////////////////////////////////////////
[7169]748unsigned int t_ephGlo::IOD() const {
[6801]749 bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
[7054]750 return (unsigned long)tMoscow.daysec() / 900;
[3659]751}
752
[8188]753// Health status of Glonass Ephemeris (virtual)
754////////////////////////////////////////////////////////////////////////////
755unsigned int t_ephGlo::isUnhealthy() const {
[8216]756
[8218]757 if (_almanac_health_availablility_indicator) {
[8216]758 if ((_health == 0 && _almanac_health == 0) ||
759 (_health == 1 && _almanac_health == 0) ||
760 (_health == 1 && _almanac_health == 1)) {
761 return 1;
762 }
[8188]763 }
[8218]764 else if (!_almanac_health_availablility_indicator) {
765 if (_health) {
766 return 1;
767 }
768 }
[8216]769 return 0; /* (_health == 0 && _almanac_health == 1) or (_health == 0) */
[8188]770}
771
[3659]772// Constructor
773//////////////////////////////////////////////////////////////////////////////
[4891]774t_ephGal::t_ephGal(float rnxVersion, const QStringList& lines) {
[6809]775 int year, month, day, hour, min;
776 double sec;
777 QString prnStr;
[4891]778 const int nLines = 8;
779 if (lines.size() != nLines) {
[6518]780 _checkState = bad;
[4891]781 return;
782 }
783
784 // RINEX Format
785 // ------------
786 int fieldLen = 19;
[6792]787 double SVhealth = 0.0;
788 double datasource = 0.0;
[6798]789
[4891]790 int pos[4];
791 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
792 pos[1] = pos[0] + fieldLen;
793 pos[2] = pos[1] + fieldLen;
794 pos[3] = pos[2] + fieldLen;
795
796 // Read eight lines
797 // ----------------
798 for (int iLine = 0; iLine < nLines; iLine++) {
799 QString line = lines[iLine];
800
801 if ( iLine == 0 ) {
802 QTextStream in(line.left(pos[1]).toAscii());
[7140]803 QString n;
[6880]804 in >> prnStr;
[7639]805 if (prnStr.size() == 1 && prnStr[0] == 'E') {
[7139]806 in >> n;
807 prnStr.append(n);
[6880]808 }
809 in >> year >> month >> day >> hour >> min >> sec;
[4891]810 if (year < 80) {
811 year += 2000;
812 }
813 else if (year < 100) {
814 year += 1900;
815 }
816
817 _TOC.set(year, month, day, hour, min, sec);
818
819 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
820 readDbl(line, pos[2], fieldLen, _clock_drift ) ||
821 readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
[6518]822 _checkState = bad;
[4891]823 return;
824 }
825 }
826
827 else if ( iLine == 1 ) {
828 if ( readDbl(line, pos[0], fieldLen, _IODnav ) ||
829 readDbl(line, pos[1], fieldLen, _Crs ) ||
830 readDbl(line, pos[2], fieldLen, _Delta_n) ||
831 readDbl(line, pos[3], fieldLen, _M0 ) ) {
[6518]832 _checkState = bad;
[4891]833 return;
834 }
835 }
836
837 else if ( iLine == 2 ) {
838 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
839 readDbl(line, pos[1], fieldLen, _e ) ||
840 readDbl(line, pos[2], fieldLen, _Cus ) ||
841 readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
[6518]842 _checkState = bad;
[4891]843 return;
844 }
845 }
846
847 else if ( iLine == 3 ) {
848 if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
849 readDbl(line, pos[1], fieldLen, _Cic ) ||
850 readDbl(line, pos[2], fieldLen, _OMEGA0) ||
851 readDbl(line, pos[3], fieldLen, _Cis ) ) {
[6518]852 _checkState = bad;
[4891]853 return;
854 }
855 }
856
857 else if ( iLine == 4 ) {
858 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
859 readDbl(line, pos[1], fieldLen, _Crc ) ||
860 readDbl(line, pos[2], fieldLen, _omega ) ||
861 readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
[6518]862 _checkState = bad;
[4891]863 return;
864 }
865 }
866
867 else if ( iLine == 5 ) {
[6792]868 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
869 readDbl(line, pos[1], fieldLen, datasource) ||
870 readDbl(line, pos[2], fieldLen, _TOEweek ) ) {
[6518]871 _checkState = bad;
[4891]872 return;
[6792]873 } else {
874 if (int(datasource) & (1<<8)) {
[6812]875 _fnav = true;
876 _inav = false;
[6792]877 } else if (int(datasource) & (1<<9)) {
[6812]878 _fnav = false;
879 _inav = true;
[6792]880 }
[6892]881 _TOEweek -= 1024.0;
[4891]882 }
883 }
884
885 else if ( iLine == 6 ) {
886 if ( readDbl(line, pos[0], fieldLen, _SISA ) ||
[6792]887 readDbl(line, pos[1], fieldLen, SVhealth) ||
[4891]888 readDbl(line, pos[2], fieldLen, _BGD_1_5A) ||
889 readDbl(line, pos[3], fieldLen, _BGD_1_5B) ) {
[6518]890 _checkState = bad;
[4891]891 return;
[6792]892 } else {
893 // Bit 0
[6812]894 _e1DataInValid = (int(SVhealth) & (1<<0));
[6792]895 // Bit 1-2
[6802]896 _E1_bHS = double((int(SVhealth) >> 1) & 0x3);
[6792]897 // Bit 3
[6812]898 _e5aDataInValid = (int(SVhealth) & (1<<3));
[6792]899 // Bit 4-5
[6802]900 _E5aHS = double((int(SVhealth) >> 4) & 0x3);
[6792]901 // Bit 6
[6812]902 _e5bDataInValid = (int(SVhealth) & (1<<6));
[6792]903 // Bit 7-8
[6802]904 _E5bHS = double((int(SVhealth) >> 7) & 0x3);
[6809]905
906 if (prnStr.at(0) == 'E') {
[7140]907 _prn.set('E', prnStr.mid(1).toInt(), _inav ? 1 : 0);
[6809]908 }
[4891]909 }
910 }
911
912 else if ( iLine == 7 ) {
913 if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
[6518]914 _checkState = bad;
[4891]915 return;
916 }
917 }
918 }
[3659]919}
[4013]920
[6801]921// Compute Galileo Satellite Position (virtual)
922////////////////////////////////////////////////////////////////////////////
923t_irc t_ephGal::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
[4013]924
[6801]925 static const double omegaEarth = 7292115.1467e-11;
[8213]926 static const double gmWGS = 398.6004418e12;
[4023]927
[8541]928 memset(xc, 0, 6*sizeof(double));
[6801]929 memset(vv, 0, 3*sizeof(double));
[4023]930
[6801]931 double a0 = _sqrt_A * _sqrt_A;
932 if (a0 == 0) {
933 return failure;
934 }
[4023]935
[6801]936 double n0 = sqrt(gmWGS/(a0*a0*a0));
[4023]937
[6801]938 bncTime tt(GPSweek, GPSweeks);
939 double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
[4023]940
[6801]941 double n = n0 + _Delta_n;
942 double M = _M0 + n*tk;
943 double E = M;
944 double E_last;
[8370]945 int nLoop = 0;
[6801]946 do {
947 E_last = E;
948 E = M + _e*sin(E);
[8370]949
950 if (++nLoop == 100) {
951 return failure;
952 }
[6801]953 } while ( fabs(E-E_last)*a0 > 0.001 );
954 double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
955 double u0 = v + _omega;
956 double sin2u0 = sin(2*u0);
957 double cos2u0 = cos(2*u0);
958 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
959 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
960 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
961 double xp = r*cos(u);
962 double yp = r*sin(u);
963 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
964 omegaEarth*_TOEsec;
[4023]965
[6801]966 double sinom = sin(OM);
967 double cosom = cos(OM);
968 double sini = sin(i);
969 double cosi = cos(i);
970 xc[0] = xp*cosom - yp*cosi*sinom;
971 xc[1] = xp*sinom + yp*cosi*cosom;
972 xc[2] = yp*sini;
[4023]973
[6801]974 double tc = tt - _TOC;
975 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
[4023]976
[6801]977 // Velocity
978 // --------
979 double tanv2 = tan(v/2);
980 double dEdM = 1 / (1 - _e*cos(E));
981 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
982 * dEdM * n;
983 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
984 double dotom = _OMEGADOT - omegaEarth;
985 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
986 double dotr = a0 * _e*sin(E) * dEdM * n
987 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
988 double dotx = dotr*cos(u) - r*sin(u)*dotu;
989 double doty = dotr*sin(u) + r*cos(u)*dotu;
[4023]990
[6801]991 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
992 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
993 + yp*sini*sinom*doti; // dX / di
994
995 vv[1] = sinom *dotx + cosi*cosom *doty
996 + xp*cosom*dotom - yp*cosi*sinom*dotom
997 - yp*sini*cosom*doti;
998
999 vv[2] = sini *doty + yp*cosi *doti;
1000
1001 // Relativistic Correction
1002 // -----------------------
[7481]1003 // correspondent to Galileo ICD and to SSR standard
1004 xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
1005 // correspondent to IGS convention
1006 //xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
[6801]1007
[8541]1008 xc[4] = _clock_drift + _clock_driftrate*tc;
1009 xc[5] = _clock_driftrate;
1010
[6801]1011 return success;
[4023]1012}
1013
[8188]1014// Health status of Galileo Ephemeris (virtual)
1015////////////////////////////////////////////////////////////////////////////
1016unsigned int t_ephGal::isUnhealthy() const {
1017 if (_E5aHS && _E5bHS && _E1_bHS) {
1018 return 1;
1019 }
1020 return 0;
1021}
1022
[4023]1023// RINEX Format String
1024//////////////////////////////////////////////////////////////////////////////
1025QString t_ephGal::toString(double version) const {
1026
[4029]1027 QString rnxStr = rinexDateStr(_TOC, _prn, version);
[4023]1028
1029 QTextStream out(&rnxStr);
1030
1031 out << QString("%1%2%3\n")
1032 .arg(_clock_bias, 19, 'e', 12)
1033 .arg(_clock_drift, 19, 'e', 12)
1034 .arg(_clock_driftrate, 19, 'e', 12);
1035
1036 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
1037
1038 out << QString(fmt)
1039 .arg(_IODnav, 19, 'e', 12)
1040 .arg(_Crs, 19, 'e', 12)
1041 .arg(_Delta_n, 19, 'e', 12)
1042 .arg(_M0, 19, 'e', 12);
1043
1044 out << QString(fmt)
1045 .arg(_Cuc, 19, 'e', 12)
1046 .arg(_e, 19, 'e', 12)
1047 .arg(_Cus, 19, 'e', 12)
1048 .arg(_sqrt_A, 19, 'e', 12);
1049
1050 out << QString(fmt)
1051 .arg(_TOEsec, 19, 'e', 12)
1052 .arg(_Cic, 19, 'e', 12)
1053 .arg(_OMEGA0, 19, 'e', 12)
1054 .arg(_Cis, 19, 'e', 12);
1055
1056 out << QString(fmt)
1057 .arg(_i0, 19, 'e', 12)
1058 .arg(_Crc, 19, 'e', 12)
1059 .arg(_omega, 19, 'e', 12)
1060 .arg(_OMEGADOT, 19, 'e', 12);
1061
[6792]1062 int dataSource = 0;
1063 int SVhealth = 0;
1064 double BGD_1_5A = _BGD_1_5A;
1065 double BGD_1_5B = _BGD_1_5B;
[6812]1066 if (_fnav) {
[6792]1067 dataSource |= (1<<1);
1068 dataSource |= (1<<8);
1069 BGD_1_5B = 0.0;
1070 // SVhealth
1071 // Bit 3 : E5a DVS
[6812]1072 if (_e5aDataInValid) {
[6792]1073 SVhealth |= (1<<3);
1074 }
1075 // Bit 4-5: E5a HS
1076 if (_E5aHS == 1.0) {
1077 SVhealth |= (1<<4);
1078 }
1079 else if (_E5aHS == 2.0) {
1080 SVhealth |= (1<<5);
1081 }
1082 else if (_E5aHS == 3.0) {
1083 SVhealth |= (1<<4);
1084 SVhealth |= (1<<5);
1085 }
1086 }
[6812]1087 else if(_inav) {
[6803]1088 // Bit 2 and 0 are set because from MT1046 the data source cannot be determined
1089 // and RNXv3.03 says both can be set if the navigation messages were merged
[5539]1090 dataSource |= (1<<0);
[6792]1091 dataSource |= (1<<2);
[5540]1092 dataSource |= (1<<9);
[6792]1093 // SVhealth
1094 // Bit 0 : E1-B DVS
[6812]1095 if (_e1DataInValid) {
[6792]1096 SVhealth |= (1<<0);
1097 }
1098 // Bit 1-2: E1-B HS
1099 if (_E1_bHS == 1.0) {
1100 SVhealth |= (1<<1);
1101 }
1102 else if (_E1_bHS == 2.0) {
1103 SVhealth |= (1<<2);
1104 }
[6803]1105 else if (_E1_bHS == 3.0) {
[6792]1106 SVhealth |= (1<<1);
1107 SVhealth |= (1<<2);
1108 }
[6802]1109 // Bit 3 : E5a DVS
[6812]1110 if (_e5aDataInValid) {
[6802]1111 SVhealth |= (1<<3);
1112 }
1113 // Bit 4-5: E5a HS
1114 if (_E5aHS == 1.0) {
1115 SVhealth |= (1<<4);
1116 }
1117 else if (_E5aHS == 2.0) {
1118 SVhealth |= (1<<5);
1119 }
[6803]1120 else if (_E5aHS == 3.0) {
[6802]1121 SVhealth |= (1<<4);
1122 SVhealth |= (1<<5);
1123 }
[6792]1124 // Bit 6 : E5b DVS
[6812]1125 if (_e5bDataInValid) {
[6792]1126 SVhealth |= (1<<6);
1127 }
1128 // Bit 7-8: E5b HS
1129 if (_E5bHS == 1.0) {
1130 SVhealth |= (1<<7);
1131 }
1132 else if (_E5bHS == 2.0) {
1133 SVhealth |= (1<<8);
1134 }
[6803]1135 else if (_E5bHS == 3.0) {
[6792]1136 SVhealth |= (1<<7);
1137 SVhealth |= (1<<8);
1138 }
[5539]1139 }
[6792]1140
[4023]1141 out << QString(fmt)
[5532]1142 .arg(_IDOT, 19, 'e', 12)
1143 .arg(double(dataSource), 19, 'e', 12)
[6892]1144 .arg(_TOEweek + 1024.0, 19, 'e', 12)
[5532]1145 .arg(0.0, 19, 'e', 12);
[4023]1146
1147 out << QString(fmt)
[6798]1148 .arg(_SISA, 19, 'e', 12)
[6792]1149 .arg(double(SVhealth), 19, 'e', 12)
1150 .arg(BGD_1_5A, 19, 'e', 12)
1151 .arg(BGD_1_5B, 19, 'e', 12);
[4023]1152
[7923]1153 double tot = _TOT;
1154 if (tot == 0.9999e9 && version < 3.0) {
1155 tot = 0.0;
1156 }
[4023]1157 out << QString(fmt)
[7923]1158 .arg(tot, 19, 'e', 12)
[4024]1159 .arg("", 19, QChar(' '))
1160 .arg("", 19, QChar(' '))
1161 .arg("", 19, QChar(' '));
[4023]1162
1163 return rnxStr;
1164}
1165
[6385]1166// Constructor
1167//////////////////////////////////////////////////////////////////////////////
[6390]1168t_ephSBAS::t_ephSBAS(float rnxVersion, const QStringList& lines) {
1169
1170 const int nLines = 4;
1171
1172 if (lines.size() != nLines) {
[6518]1173 _checkState = bad;
[6390]1174 return;
1175 }
1176
1177 // RINEX Format
1178 // ------------
1179 int fieldLen = 19;
1180
1181 int pos[4];
1182 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
1183 pos[1] = pos[0] + fieldLen;
1184 pos[2] = pos[1] + fieldLen;
1185 pos[3] = pos[2] + fieldLen;
1186
1187 // Read four lines
1188 // ---------------
1189 for (int iLine = 0; iLine < nLines; iLine++) {
1190 QString line = lines[iLine];
1191
1192 if ( iLine == 0 ) {
1193 QTextStream in(line.left(pos[1]).toAscii());
1194
1195 int year, month, day, hour, min;
1196 double sec;
[6880]1197
[7139]1198 QString prnStr, n;
[6880]1199 in >> prnStr;
[7639]1200 if (prnStr.size() == 1 && prnStr[0] == 'S') {
[7139]1201 in >> n;
1202 prnStr.append(n);
[6880]1203 }
1204 in >> year >> month >> day >> hour >> min >> sec;
[6390]1205 if (prnStr.at(0) == 'S') {
1206 _prn.set('S', prnStr.mid(1).toInt());
1207 }
1208 else {
1209 _prn.set('S', prnStr.toInt());
1210 }
1211
1212 if (year < 80) {
1213 year += 2000;
1214 }
1215 else if (year < 100) {
1216 year += 1900;
1217 }
1218
1219 _TOC.set(year, month, day, hour, min, sec);
1220
1221 if ( readDbl(line, pos[1], fieldLen, _agf0 ) ||
1222 readDbl(line, pos[2], fieldLen, _agf1 ) ||
[8455]1223 readDbl(line, pos[3], fieldLen, _TOT ) ) {
[6518]1224 _checkState = bad;
[6390]1225 return;
1226 }
1227 }
1228
1229 else if ( iLine == 1 ) {
1230 if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
1231 readDbl(line, pos[1], fieldLen, _x_velocity ) ||
1232 readDbl(line, pos[2], fieldLen, _x_acceleration) ||
1233 readDbl(line, pos[3], fieldLen, _health ) ) {
[6518]1234 _checkState = bad;
[6390]1235 return;
1236 }
1237 }
1238
1239 else if ( iLine == 2 ) {
1240 if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
1241 readDbl(line, pos[1], fieldLen, _y_velocity ) ||
1242 readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
1243 readDbl(line, pos[3], fieldLen, _ura ) ) {
[6518]1244 _checkState = bad;
[6390]1245 return;
1246 }
1247 }
1248
1249 else if ( iLine == 3 ) {
[6536]1250 double iodn;
[6390]1251 if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
1252 readDbl(line, pos[1], fieldLen, _z_velocity ) ||
1253 readDbl(line, pos[2], fieldLen, _z_acceleration) ||
[6536]1254 readDbl(line, pos[3], fieldLen, iodn ) ) {
[6518]1255 _checkState = bad;
[6390]1256 return;
[6891]1257 } else {
[6536]1258 _IODN = int(iodn);
[6390]1259 }
1260 }
1261 }
1262
[7278]1263 _x_pos *= 1.e3;
1264 _y_pos *= 1.e3;
1265 _z_pos *= 1.e3;
1266 _x_velocity *= 1.e3;
1267 _y_velocity *= 1.e3;
1268 _z_velocity *= 1.e3;
1269 _x_acceleration *= 1.e3;
1270 _y_acceleration *= 1.e3;
1271 _z_acceleration *= 1.e3;
[6385]1272}
1273
[7054]1274// IOD of SBAS Ephemeris (virtual)
1275////////////////////////////////////////////////////////////////////////////
1276
[7169]1277unsigned int t_ephSBAS::IOD() const {
[7054]1278 unsigned char buffer[80];
1279 int size = 0;
1280 int numbits = 0;
1281 long long bitbuffer = 0;
1282 unsigned char *startbuffer = buffer;
1283
1284 SBASADDBITSFLOAT(30, this->_x_pos, 0.08)
1285 SBASADDBITSFLOAT(30, this->_y_pos, 0.08)
1286 SBASADDBITSFLOAT(25, this->_z_pos, 0.4)
1287 SBASADDBITSFLOAT(17, this->_x_velocity, 0.000625)
1288 SBASADDBITSFLOAT(17, this->_y_velocity, 0.000625)
1289 SBASADDBITSFLOAT(18, this->_z_velocity, 0.004)
1290 SBASADDBITSFLOAT(10, this->_x_acceleration, 0.0000125)
1291 SBASADDBITSFLOAT(10, this->_y_acceleration, 0.0000125)
1292 SBASADDBITSFLOAT(10, this->_z_acceleration, 0.0000625)
1293 SBASADDBITSFLOAT(12, this->_agf0, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1294 SBASADDBITSFLOAT(8, this->_agf1, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<10))
1295 SBASADDBITS(5,0); // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
1296
1297 return CRC24(size, startbuffer);
1298}
1299
[6385]1300// Compute SBAS Satellite Position (virtual)
1301////////////////////////////////////////////////////////////////////////////
1302t_irc t_ephSBAS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
[6386]1303
1304 bncTime tt(GPSweek, GPSweeks);
1305 double dt = tt - _TOC;
1306
[7278]1307 xc[0] = _x_pos + _x_velocity * dt + _x_acceleration * dt * dt / 2.0;
1308 xc[1] = _y_pos + _y_velocity * dt + _y_acceleration * dt * dt / 2.0;
1309 xc[2] = _z_pos + _z_velocity * dt + _z_acceleration * dt * dt / 2.0;
[6386]1310
1311 vv[0] = _x_velocity + _x_acceleration * dt;
1312 vv[1] = _y_velocity + _y_acceleration * dt;
1313 vv[2] = _z_velocity + _z_acceleration * dt;
1314
1315 xc[3] = _agf0 + _agf1 * dt;
1316
[8541]1317 xc[4] = _agf1;
1318 xc[5] = 0.0;
[8484]1319
[6386]1320 return success;
[6385]1321}
1322
1323// RINEX Format String
1324//////////////////////////////////////////////////////////////////////////////
[6388]1325QString t_ephSBAS::toString(double version) const {
1326
1327 QString rnxStr = rinexDateStr(_TOC, _prn, version);
1328
1329 QTextStream out(&rnxStr);
1330
1331 out << QString("%1%2%3\n")
[6390]1332 .arg(_agf0, 19, 'e', 12)
1333 .arg(_agf1, 19, 'e', 12)
[8455]1334 .arg(_TOT, 19, 'e', 12);
[6388]1335
1336 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
1337
1338 out << QString(fmt)
1339 .arg(1.e-3*_x_pos, 19, 'e', 12)
1340 .arg(1.e-3*_x_velocity, 19, 'e', 12)
1341 .arg(1.e-3*_x_acceleration, 19, 'e', 12)
[6390]1342 .arg(_health, 19, 'e', 12);
[6388]1343
1344 out << QString(fmt)
1345 .arg(1.e-3*_y_pos, 19, 'e', 12)
1346 .arg(1.e-3*_y_velocity, 19, 'e', 12)
1347 .arg(1.e-3*_y_acceleration, 19, 'e', 12)
[6390]1348 .arg(_ura, 19, 'e', 12);
[6388]1349
1350 out << QString(fmt)
1351 .arg(1.e-3*_z_pos, 19, 'e', 12)
1352 .arg(1.e-3*_z_velocity, 19, 'e', 12)
1353 .arg(1.e-3*_z_acceleration, 19, 'e', 12)
[6536]1354 .arg(double(_IODN), 19, 'e', 12);
[6388]1355
1356 return rnxStr;
[6385]1357}
[6400]1358
1359// Constructor
1360//////////////////////////////////////////////////////////////////////////////
[6600]1361t_ephBDS::t_ephBDS(float rnxVersion, const QStringList& lines) {
[6400]1362
1363 const int nLines = 8;
1364
1365 if (lines.size() != nLines) {
[6518]1366 _checkState = bad;
[6400]1367 return;
1368 }
1369
1370 // RINEX Format
1371 // ------------
1372 int fieldLen = 19;
1373
1374 int pos[4];
1375 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
1376 pos[1] = pos[0] + fieldLen;
1377 pos[2] = pos[1] + fieldLen;
1378 pos[3] = pos[2] + fieldLen;
1379
1380 // Read eight lines
1381 // ----------------
1382 for (int iLine = 0; iLine < nLines; iLine++) {
1383 QString line = lines[iLine];
1384
1385 if ( iLine == 0 ) {
1386 QTextStream in(line.left(pos[1]).toAscii());
1387
1388 int year, month, day, hour, min;
1389 double sec;
[6880]1390
[7139]1391 QString prnStr, n;
[6880]1392 in >> prnStr;
[7639]1393 if (prnStr.size() == 1 && prnStr[0] == 'C') {
[7139]1394 in >> n;
1395 prnStr.append(n);
[6880]1396 }
1397 in >> year >> month >> day >> hour >> min >> sec;
[6400]1398 if (prnStr.at(0) == 'C') {
1399 _prn.set('C', prnStr.mid(1).toInt());
1400 }
1401 else {
1402 _prn.set('C', prnStr.toInt());
1403 }
1404
1405 if (year < 80) {
1406 year += 2000;
1407 }
1408 else if (year < 100) {
1409 year += 1900;
1410 }
1411
[6812]1412 _TOC.setBDS(year, month, day, hour, min, sec);
[6400]1413
1414 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
1415 readDbl(line, pos[2], fieldLen, _clock_drift ) ||
1416 readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
[6518]1417 _checkState = bad;
[6400]1418 return;
1419 }
1420 }
1421
1422 else if ( iLine == 1 ) {
1423 double aode;
1424 if ( readDbl(line, pos[0], fieldLen, aode ) ||
1425 readDbl(line, pos[1], fieldLen, _Crs ) ||
1426 readDbl(line, pos[2], fieldLen, _Delta_n) ||
1427 readDbl(line, pos[3], fieldLen, _M0 ) ) {
[6518]1428 _checkState = bad;
[6400]1429 return;
1430 }
1431 _AODE = int(aode);
1432 }
1433
1434 else if ( iLine == 2 ) {
1435 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
1436 readDbl(line, pos[1], fieldLen, _e ) ||
1437 readDbl(line, pos[2], fieldLen, _Cus ) ||
1438 readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
[6518]1439 _checkState = bad;
[6400]1440 return;
1441 }
1442 }
1443
1444 else if ( iLine == 3 ) {
[6812]1445 if ( readDbl(line, pos[0], fieldLen, _TOEsec ) ||
[6400]1446 readDbl(line, pos[1], fieldLen, _Cic ) ||
1447 readDbl(line, pos[2], fieldLen, _OMEGA0) ||
1448 readDbl(line, pos[3], fieldLen, _Cis ) ) {
[6518]1449 _checkState = bad;
[6400]1450 return;
1451 }
1452 }
1453
1454 else if ( iLine == 4 ) {
1455 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
1456 readDbl(line, pos[1], fieldLen, _Crc ) ||
1457 readDbl(line, pos[2], fieldLen, _omega ) ||
1458 readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
[6518]1459 _checkState = bad;
[6400]1460 return;
1461 }
1462 }
1463
1464 else if ( iLine == 5 ) {
1465 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
[6812]1466 readDbl(line, pos[2], fieldLen, _TOEweek)) {
[6518]1467 _checkState = bad;
[6400]1468 return;
1469 }
1470 }
1471
1472 else if ( iLine == 6 ) {
1473 double SatH1;
[6755]1474 if ( readDbl(line, pos[0], fieldLen, _URA ) ||
1475 readDbl(line, pos[1], fieldLen, SatH1) ||
[6400]1476 readDbl(line, pos[2], fieldLen, _TGD1) ||
1477 readDbl(line, pos[3], fieldLen, _TGD2) ) {
[6518]1478 _checkState = bad;
[6400]1479 return;
1480 }
1481 _SatH1 = int(SatH1);
1482 }
1483
1484 else if ( iLine == 7 ) {
1485 double aodc;
[6812]1486 if ( readDbl(line, pos[0], fieldLen, _TOT) ||
[6400]1487 readDbl(line, pos[1], fieldLen, aodc) ) {
[6518]1488 _checkState = bad;
[6400]1489 return;
1490 }
[6812]1491 if (_TOT == 0.9999e9) { // 0.9999e9 means not known (RINEX standard)
1492 _TOT = _TOEsec;
[6400]1493 }
1494 _AODC = int(aodc);
1495 }
1496 }
1497
[7138]1498 _TOE.setBDS(int(_TOEweek), _TOEsec);
1499
[6400]1500 // remark: actually should be computed from second_tot
1501 // but it seems to be unreliable in RINEX files
[6843]1502 //_TOT = _TOC.bdssec();
[6400]1503}
1504
[7054]1505// IOD of BDS Ephemeris (virtual)
1506////////////////////////////////////////////////////////////////////////////
[7169]1507unsigned int t_ephBDS::IOD() const {
[7054]1508 unsigned char buffer[80];
1509 int size = 0;
1510 int numbits = 0;
1511 long long bitbuffer = 0;
1512 unsigned char *startbuffer = buffer;
1513
1514 BDSADDBITSFLOAT(14, this->_IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
1515 BDSADDBITSFLOAT(11, this->_clock_driftrate, 1.0/static_cast<double>(1<<30)
1516 /static_cast<double>(1<<30)/static_cast<double>(1<<6))
1517 BDSADDBITSFLOAT(22, this->_clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<20))
1518 BDSADDBITSFLOAT(24, this->_clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
1519 BDSADDBITSFLOAT(18, this->_Crs, 1.0/static_cast<double>(1<<6))
1520 BDSADDBITSFLOAT(16, this->_Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
1521 BDSADDBITSFLOAT(32, this->_M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1522 BDSADDBITSFLOAT(18, this->_Cuc, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1523 BDSADDBITSFLOAT(32, this->_e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
1524 BDSADDBITSFLOAT(18, this->_Cus, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1525 BDSADDBITSFLOAT(32, this->_sqrt_A, 1.0/static_cast<double>(1<<19))
1526 BDSADDBITSFLOAT(18, this->_Cic, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1527 BDSADDBITSFLOAT(32, this->_OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1528 BDSADDBITSFLOAT(18, this->_Cis, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1529 BDSADDBITSFLOAT(32, this->_i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1530 BDSADDBITSFLOAT(18, this->_Crc, 1.0/static_cast<double>(1<<6))
1531 BDSADDBITSFLOAT(32, this->_omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1532 BDSADDBITSFLOAT(24, this->_OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
1533 BDSADDBITS(5, 0) // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
1534
1535 return CRC24(size, startbuffer);
1536}
1537
[6601]1538// Compute BDS Satellite Position (virtual)
[6400]1539//////////////////////////////////////////////////////////////////////////////
[6600]1540t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
[6400]1541
[6602]1542 static const double gmBDS = 398.6004418e12;
1543 static const double omegaBDS = 7292115.0000e-11;
[6400]1544
1545 xc[0] = xc[1] = xc[2] = xc[3] = 0.0;
1546 vv[0] = vv[1] = vv[2] = 0.0;
1547
1548 bncTime tt(GPSweek, GPSweeks);
1549
1550 if (_sqrt_A == 0) {
1551 return failure;
1552 }
1553 double a0 = _sqrt_A * _sqrt_A;
1554
[6602]1555 double n0 = sqrt(gmBDS/(a0*a0*a0));
[6400]1556 double tk = tt - _TOE;
1557 double n = n0 + _Delta_n;
1558 double M = _M0 + n*tk;
1559 double E = M;
1560 double E_last;
1561 int nLoop = 0;
1562 do {
1563 E_last = E;
1564 E = M + _e*sin(E);
1565
1566 if (++nLoop == 100) {
1567 return failure;
1568 }
1569 } while ( fabs(E-E_last)*a0 > 0.001 );
1570
1571 double v = atan2(sqrt(1-_e*_e) * sin(E), cos(E) - _e);
1572 double u0 = v + _omega;
1573 double sin2u0 = sin(2*u0);
1574 double cos2u0 = cos(2*u0);
1575 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
1576 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
1577 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
1578 double xp = r*cos(u);
1579 double yp = r*sin(u);
1580 double toesec = (_TOE.gpssec() - 14.0);
1581 double sinom = 0;
1582 double cosom = 0;
1583 double sini = 0;
1584 double cosi = 0;
[7278]1585
[7481]1586 // Velocity
1587 // --------
1588 double tanv2 = tan(v/2);
1589 double dEdM = 1 / (1 - _e*cos(E));
1590 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2)
1591 / (1 + tanv2*tanv2) * dEdM * n;
1592 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
1593 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
1594 double dotr = a0 * _e*sin(E) * dEdM * n
1595 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
1596
1597 double dotx = dotr*cos(u) - r*sin(u)*dotu;
1598 double doty = dotr*sin(u) + r*cos(u)*dotu;
1599
[6400]1600 const double iMaxGEO = 10.0 / 180.0 * M_PI;
1601
1602 // MEO/IGSO satellite
1603 // ------------------
1604 if (_i0 > iMaxGEO) {
[6602]1605 double OM = _OMEGA0 + (_OMEGADOT - omegaBDS)*tk - omegaBDS*toesec;
[6400]1606
1607 sinom = sin(OM);
1608 cosom = cos(OM);
1609 sini = sin(i);
1610 cosi = cos(i);
1611
1612 xc[0] = xp*cosom - yp*cosi*sinom;
1613 xc[1] = xp*sinom + yp*cosi*cosom;
[7278]1614 xc[2] = yp*sini;
[7481]1615
1616 // Velocity
1617 // --------
1618
1619 double dotom = _OMEGADOT - t_CST::omega;
1620
1621 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
1622 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
1623 + yp*sini*sinom*doti; // dX / di
1624
1625 vv[1] = sinom *dotx + cosi*cosom *doty
1626 + xp*cosom*dotom - yp*cosi*sinom*dotom
1627 - yp*sini*cosom*doti;
1628
1629 vv[2] = sini *doty + yp*cosi *doti;
1630
[6400]1631 }
1632
1633 // GEO satellite
1634 // -------------
1635 else {
[6602]1636 double OM = _OMEGA0 + _OMEGADOT*tk - omegaBDS*toesec;
1637 double ll = omegaBDS*tk;
[6400]1638
1639 sinom = sin(OM);
1640 cosom = cos(OM);
1641 sini = sin(i);
1642 cosi = cos(i);
1643
1644 double xx = xp*cosom - yp*cosi*sinom;
1645 double yy = xp*sinom + yp*cosi*cosom;
[7278]1646 double zz = yp*sini;
[6400]1647
[7487]1648 Matrix RX = BNC_PPP::t_astro::rotX(-5.0 / 180.0 * M_PI);
1649 Matrix RZ = BNC_PPP::t_astro::rotZ(ll);
[6400]1650
1651 ColumnVector X1(3); X1 << xx << yy << zz;
[7487]1652 ColumnVector X2 = RZ*RX*X1;
[6400]1653
1654 xc[0] = X2(1);
1655 xc[1] = X2(2);
1656 xc[2] = X2(3);
[7278]1657
[7481]1658 double dotom = _OMEGADOT;
[6400]1659
[7481]1660 double vx = cosom *dotx - cosi*sinom *doty
1661 - xp*sinom*dotom - yp*cosi*cosom*dotom
1662 + yp*sini*sinom*doti;
[6400]1663
[7481]1664 double vy = sinom *dotx + cosi*cosom *doty
1665 + xp*cosom*dotom - yp*cosi*sinom*dotom
1666 - yp*sini*cosom*doti;
[7278]1667
[7501]1668 double vz = sini *doty + yp*cosi *doti;
[6400]1669
[7501]1670 ColumnVector V(3); V << vx << vy << vz;
[7481]1671
[7487]1672 Matrix RdotZ(3,3);
[7481]1673 double C = cos(ll);
1674 double S = sin(ll);
1675 Matrix UU(3,3);
1676 UU[0][0] = -S; UU[0][1] = +C; UU[0][2] = 0.0;
1677 UU[1][0] = -C; UU[1][1] = -S; UU[1][2] = 0.0;
1678 UU[2][0] = 0.0; UU[2][1] = 0.0; UU[2][2] = 0.0;
[7487]1679 RdotZ = omegaBDS * UU;
[7481]1680
1681 ColumnVector VV(3);
[7487]1682 VV = RZ*RX*V + RdotZ*RX*X1;
[7481]1683
1684 vv[0] = VV(1);
1685 vv[1] = VV(2);
1686 vv[2] = VV(3);
1687 }
1688
1689 double tc = tt - _TOC;
1690 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
1691
[7278]1692 // dotC = _clock_drift + _clock_driftrate*tc
[6400]1693 // - 4.442807633e-10*_e*sqrt(a0)*cos(E) * dEdM * n;
1694
[7481]1695 // Relativistic Correction
1696 // -----------------------
1697 // correspondent to BDS ICD and to SSR standard
[8541]1698 xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
[7481]1699 // correspondent to IGS convention
1700 // xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
1701
[8541]1702 xc[4] = _clock_drift + _clock_driftrate*tc;
1703 xc[5] = _clock_driftrate;
1704
[6400]1705 return success;
1706}
1707
1708// RINEX Format String
1709//////////////////////////////////////////////////////////////////////////////
[6600]1710QString t_ephBDS::toString(double version) const {
[6400]1711
[6812]1712 QString rnxStr = rinexDateStr(_TOC-14.0, _prn, version);
[6400]1713
1714 QTextStream out(&rnxStr);
1715
1716 out << QString("%1%2%3\n")
1717 .arg(_clock_bias, 19, 'e', 12)
1718 .arg(_clock_drift, 19, 'e', 12)
1719 .arg(_clock_driftrate, 19, 'e', 12);
1720
1721 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
1722
1723 out << QString(fmt)
1724 .arg(double(_AODE), 19, 'e', 12)
1725 .arg(_Crs, 19, 'e', 12)
1726 .arg(_Delta_n, 19, 'e', 12)
1727 .arg(_M0, 19, 'e', 12);
1728
1729 out << QString(fmt)
1730 .arg(_Cuc, 19, 'e', 12)
1731 .arg(_e, 19, 'e', 12)
1732 .arg(_Cus, 19, 'e', 12)
1733 .arg(_sqrt_A, 19, 'e', 12);
1734
[6843]1735 double toes = 0.0;
1736 if (_TOEweek > -1.0) {// RINEX input
1737 toes = _TOEsec;
1738 }
1739 else {// RTCM stream input
[6812]1740 toes = _TOE.bdssec();
[6755]1741 }
[6400]1742 out << QString(fmt)
[6843]1743 .arg(toes, 19, 'e', 12)
[6755]1744 .arg(_Cic, 19, 'e', 12)
1745 .arg(_OMEGA0, 19, 'e', 12)
1746 .arg(_Cis, 19, 'e', 12);
[6400]1747
1748 out << QString(fmt)
1749 .arg(_i0, 19, 'e', 12)
1750 .arg(_Crc, 19, 'e', 12)
1751 .arg(_omega, 19, 'e', 12)
1752 .arg(_OMEGADOT, 19, 'e', 12);
1753
[6843]1754 double toew = 0.0;
1755 if (_TOEweek > -1.0) {// RINEX input
1756 toew = _TOEweek;
1757 }
1758 else {// RTCM stream input
1759 toew = double(_TOE.bdsw());
1760 }
[6400]1761 out << QString(fmt)
[6843]1762 .arg(_IDOT, 19, 'e', 12)
1763 .arg(0.0, 19, 'e', 12)
1764 .arg(toew, 19, 'e', 12)
1765 .arg(0.0, 19, 'e', 12);
[6400]1766
1767 out << QString(fmt)
[6798]1768 .arg(_URA, 19, 'e', 12)
[6400]1769 .arg(double(_SatH1), 19, 'e', 12)
1770 .arg(_TGD1, 19, 'e', 12)
1771 .arg(_TGD2, 19, 'e', 12);
1772
[6843]1773 double tots = 0.0;
1774 if (_TOEweek > -1.0) {// RINEX input
1775 tots = _TOT;
1776 }
1777 else {// RTCM stream input
[6812]1778 tots = _TOE.bdssec();
[6755]1779 }
[6400]1780 out << QString(fmt)
[6792]1781 .arg(tots, 19, 'e', 12)
[6755]1782 .arg(double(_AODC), 19, 'e', 12)
1783 .arg("", 19, QChar(' '))
1784 .arg("", 19, QChar(' '));
[6400]1785 return rnxStr;
1786}
Note: See TracBrowser for help on using the repository browser.