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

Last change on this file since 8488 was 8488, checked in by stuerze, 6 years ago

minor changes

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