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

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

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

File size: 49.8 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 else if ( iLine == 7 ) {
301 if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
302 _checkState = bad;
303 return;
304 }
[8926]305 // fitInterval is not valid for IRNSS
306 if (type() != t_eph::IRNSS) {
307 double fitIntervalRnx;
308 readDbl(line, pos[1], fieldLen, fitIntervalRnx);
[8932]309 if (type() == t_eph::GPS) { // in RINEX specified allways as time period for GPS
[8929]310 _fitInterval = fitIntervalRnx;
[8932]311 } else if (type() == t_eph::QZSS) { // specified as flag for QZSS
312 if (rnxVersion == 3.02) {
313 _fitInterval = fitIntervalRnx; // specified as time period
[8929]314 }
[8932]315 else {
316 _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::QZSS);
317 }
[8926]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
[8930]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 {
[8932]497 // for GPS and QZSS in version 3.02 specified in hours
498 double fitIntervalRnx = _fitInterval;
499 // otherwise specified as flag
500 if (type() == t_eph::QZSS && version != 3.02) {
[8926]501 (_fitInterval == 2.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0;
502 }
[8167]503 out << QString(fmt)
[8926]504 .arg(tot, 19, 'e', 12)
505 .arg(fitIntervalRnx, 19, 'e', 12)
506 .arg("", 19, QChar(' '))
507 .arg("", 19, QChar(' '));
[8167]508 }
[6801]509
510 return rnxStr;
[2221]511}
512
[6801]513// Constructor
514//////////////////////////////////////////////////////////////////////////////
515t_ephGlo::t_ephGlo(float rnxVersion, const QStringList& lines) {
[2221]516
[6801]517 const int nLines = 4;
518
519 if (lines.size() != nLines) {
520 _checkState = bad;
521 return;
[6518]522 }
523
[6801]524 // RINEX Format
525 // ------------
526 int fieldLen = 19;
[2221]527
[6801]528 int pos[4];
529 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
530 pos[1] = pos[0] + fieldLen;
531 pos[2] = pos[1] + fieldLen;
532 pos[3] = pos[2] + fieldLen;
[2221]533
[6801]534 // Read four lines
535 // ---------------
536 for (int iLine = 0; iLine < nLines; iLine++) {
537 QString line = lines[iLine];
[2221]538
[6801]539 if ( iLine == 0 ) {
540 QTextStream in(line.left(pos[1]).toAscii());
[6213]541
[6801]542 int year, month, day, hour, min;
543 double sec;
[2221]544
[7139]545 QString prnStr, n;
[6880]546 in >> prnStr;
[7639]547 if (prnStr.size() == 1 && prnStr[0] == 'R') {
[7139]548 in >> n;
549 prnStr.append(n);
[6880]550 }
551 in >> year >> month >> day >> hour >> min >> sec;
[6801]552 if (prnStr.at(0) == 'R') {
553 _prn.set('R', prnStr.mid(1).toInt());
554 }
555 else {
556 _prn.set('R', prnStr.toInt());
557 }
[2221]558
[6801]559 if (year < 80) {
560 year += 2000;
561 }
562 else if (year < 100) {
563 year += 1900;
564 }
[2221]565
[6801]566 _gps_utc = gnumleap(year, month, day);
[2221]567
[6801]568 _TOC.set(year, month, day, hour, min, sec);
569 _TOC = _TOC + _gps_utc;
[8804]570 int nd = int((_TOC.gpssec())) / (24.0*60.0*60.0);
[6801]571 if ( readDbl(line, pos[1], fieldLen, _tau ) ||
572 readDbl(line, pos[2], fieldLen, _gamma) ||
573 readDbl(line, pos[3], fieldLen, _tki ) ) {
574 _checkState = bad;
575 return;
576 }
[8804]577 _tki -= nd * 86400.0;
578 _tau = -_tau;
[6801]579 }
580
581 else if ( iLine == 1 ) {
582 if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
583 readDbl(line, pos[1], fieldLen, _x_velocity ) ||
584 readDbl(line, pos[2], fieldLen, _x_acceleration) ||
585 readDbl(line, pos[3], fieldLen, _health ) ) {
586 _checkState = bad;
587 return;
588 }
589 }
590
591 else if ( iLine == 2 ) {
592 if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
593 readDbl(line, pos[1], fieldLen, _y_velocity ) ||
594 readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
595 readDbl(line, pos[3], fieldLen, _frequency_number) ) {
596 _checkState = bad;
597 return;
598 }
599 }
600
601 else if ( iLine == 3 ) {
602 if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
603 readDbl(line, pos[1], fieldLen, _z_velocity ) ||
604 readDbl(line, pos[2], fieldLen, _z_acceleration) ||
605 readDbl(line, pos[3], fieldLen, _E ) ) {
606 _checkState = bad;
607 return;
608 }
609 }
610 }
611
612 // Initialize status vector
613 // ------------------------
614 _tt = _TOC;
[8697]615 _xv.ReSize(6); _xv = 0.0;
[6801]616 _xv(1) = _x_pos * 1.e3;
617 _xv(2) = _y_pos * 1.e3;
618 _xv(3) = _z_pos * 1.e3;
619 _xv(4) = _x_velocity * 1.e3;
620 _xv(5) = _y_velocity * 1.e3;
621 _xv(6) = _z_velocity * 1.e3;
[2221]622}
623
[6801]624// Compute Glonass Satellite Position (virtual)
[2771]625////////////////////////////////////////////////////////////////////////////
[6801]626t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
[2771]627
[6801]628 static const double nominalStep = 10.0;
[2771]629
[8541]630 memset(xc, 0, 6*sizeof(double));
[2771]631 memset(vv, 0, 3*sizeof(double));
632
[6801]633 double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
634
[8690]635 if (fabs(dtPos) > 24 * 3600.0) {
[6213]636 return failure;
[2771]637 }
638
[6801]639 int nSteps = int(fabs(dtPos) / nominalStep) + 1;
640 double step = dtPos / nSteps;
[4018]641
[6801]642 double acc[3];
643 acc[0] = _x_acceleration * 1.e3;
644 acc[1] = _y_acceleration * 1.e3;
645 acc[2] = _z_acceleration * 1.e3;
646 for (int ii = 1; ii <= nSteps; ii++) {
647 _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
648 _tt = _tt + step;
649 }
[4018]650
[6801]651 // Position and Velocity
652 // ---------------------
653 xc[0] = _xv(1);
654 xc[1] = _xv(2);
655 xc[2] = _xv(3);
[2771]656
[6801]657 vv[0] = _xv(4);
658 vv[1] = _xv(5);
659 vv[2] = _xv(6);
[2771]660
[6801]661 // Clock Correction
662 // ----------------
663 double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
664 xc[3] = -_tau + _gamma * dtClk;
[2771]665
[8541]666 xc[4] = _gamma;
667 xc[5] = 0.0;
[8484]668
[6213]669 return success;
[2771]670}
671
[6801]672// RINEX Format String
[3659]673//////////////////////////////////////////////////////////////////////////////
[6801]674QString t_ephGlo::toString(double version) const {
[3664]675
[8804]676 QString rnxStr = rinexDateStr(_TOC -_gps_utc, _prn, version);
677 int nd = int((_TOC - _gps_utc).gpssec()) / (24.0*60.0*60.0);
[6801]678 QTextStream out(&rnxStr);
[3664]679
[6801]680 out << QString("%1%2%3\n")
[8804]681 .arg(-_tau, 19, 'e', 12)
682 .arg(_gamma, 19, 'e', 12)
683 .arg(_tki+nd*86400.0, 19, 'e', 12);
[3668]684
[6801]685 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
[3664]686
[6801]687 out << QString(fmt)
688 .arg(_x_pos, 19, 'e', 12)
689 .arg(_x_velocity, 19, 'e', 12)
690 .arg(_x_acceleration, 19, 'e', 12)
691 .arg(_health, 19, 'e', 12);
[3664]692
[6801]693 out << QString(fmt)
694 .arg(_y_pos, 19, 'e', 12)
695 .arg(_y_velocity, 19, 'e', 12)
696 .arg(_y_acceleration, 19, 'e', 12)
697 .arg(_frequency_number, 19, 'e', 12);
[3666]698
[6801]699 out << QString(fmt)
700 .arg(_z_pos, 19, 'e', 12)
701 .arg(_z_velocity, 19, 'e', 12)
702 .arg(_z_acceleration, 19, 'e', 12)
703 .arg(_E, 19, 'e', 12);
[3666]704
[6801]705 return rnxStr;
[3659]706}
707
[6801]708// Derivative of the state vector using a simple force model (static)
709////////////////////////////////////////////////////////////////////////////
710ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector& xv,
711 double* acc) {
[3659]712
[6801]713 // State vector components
714 // -----------------------
715 ColumnVector rr = xv.rows(1,3);
716 ColumnVector vv = xv.rows(4,6);
[3699]717
[6801]718 // Acceleration
[3699]719 // ------------
[6801]720 static const double gmWGS = 398.60044e12;
721 static const double AE = 6378136.0;
722 static const double OMEGA = 7292115.e-11;
723 static const double C20 = -1082.6257e-6;
[3699]724
[6801]725 double rho = rr.norm_Frobenius();
726 double t1 = -gmWGS/(rho*rho*rho);
727 double t2 = 3.0/2.0 * C20 * (gmWGS*AE*AE) / (rho*rho*rho*rho*rho);
728 double t3 = OMEGA * OMEGA;
729 double t4 = 2.0 * OMEGA;
730 double z2 = rr(3) * rr(3);
[3699]731
[6801]732 // Vector of derivatives
733 // ---------------------
734 ColumnVector va(6);
735 va(1) = vv(1);
736 va(2) = vv(2);
737 va(3) = vv(3);
738 va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2) + acc[0];
739 va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1) + acc[1];
740 va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho)) ) * rr(3) + acc[2];
[3699]741
[6801]742 return va;
743}
[3699]744
[6801]745// IOD of Glonass Ephemeris (virtual)
746////////////////////////////////////////////////////////////////////////////
[7169]747unsigned int t_ephGlo::IOD() const {
[6801]748 bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
[7054]749 return (unsigned long)tMoscow.daysec() / 900;
[3659]750}
751
[8188]752// Health status of Glonass Ephemeris (virtual)
753////////////////////////////////////////////////////////////////////////////
754unsigned int t_ephGlo::isUnhealthy() const {
[8216]755
[8218]756 if (_almanac_health_availablility_indicator) {
[8216]757 if ((_health == 0 && _almanac_health == 0) ||
758 (_health == 1 && _almanac_health == 0) ||
759 (_health == 1 && _almanac_health == 1)) {
760 return 1;
761 }
[8188]762 }
[8218]763 else if (!_almanac_health_availablility_indicator) {
764 if (_health) {
765 return 1;
766 }
767 }
[8216]768 return 0; /* (_health == 0 && _almanac_health == 1) or (_health == 0) */
[8188]769}
770
[3659]771// Constructor
772//////////////////////////////////////////////////////////////////////////////
[4891]773t_ephGal::t_ephGal(float rnxVersion, const QStringList& lines) {
[6809]774 int year, month, day, hour, min;
775 double sec;
776 QString prnStr;
[4891]777 const int nLines = 8;
778 if (lines.size() != nLines) {
[6518]779 _checkState = bad;
[4891]780 return;
781 }
782
783 // RINEX Format
784 // ------------
785 int fieldLen = 19;
[6792]786 double SVhealth = 0.0;
787 double datasource = 0.0;
[6798]788
[4891]789 int pos[4];
790 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
791 pos[1] = pos[0] + fieldLen;
792 pos[2] = pos[1] + fieldLen;
793 pos[3] = pos[2] + fieldLen;
794
795 // Read eight lines
796 // ----------------
797 for (int iLine = 0; iLine < nLines; iLine++) {
798 QString line = lines[iLine];
799
800 if ( iLine == 0 ) {
801 QTextStream in(line.left(pos[1]).toAscii());
[7140]802 QString n;
[6880]803 in >> prnStr;
[7639]804 if (prnStr.size() == 1 && prnStr[0] == 'E') {
[7139]805 in >> n;
806 prnStr.append(n);
[6880]807 }
808 in >> year >> month >> day >> hour >> min >> sec;
[4891]809 if (year < 80) {
810 year += 2000;
811 }
812 else if (year < 100) {
813 year += 1900;
814 }
815
816 _TOC.set(year, month, day, hour, min, sec);
817
818 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
819 readDbl(line, pos[2], fieldLen, _clock_drift ) ||
820 readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
[6518]821 _checkState = bad;
[4891]822 return;
823 }
824 }
825
826 else if ( iLine == 1 ) {
827 if ( readDbl(line, pos[0], fieldLen, _IODnav ) ||
828 readDbl(line, pos[1], fieldLen, _Crs ) ||
829 readDbl(line, pos[2], fieldLen, _Delta_n) ||
830 readDbl(line, pos[3], fieldLen, _M0 ) ) {
[6518]831 _checkState = bad;
[4891]832 return;
833 }
834 }
835
836 else if ( iLine == 2 ) {
837 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
838 readDbl(line, pos[1], fieldLen, _e ) ||
839 readDbl(line, pos[2], fieldLen, _Cus ) ||
840 readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
[6518]841 _checkState = bad;
[4891]842 return;
843 }
844 }
845
846 else if ( iLine == 3 ) {
847 if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
848 readDbl(line, pos[1], fieldLen, _Cic ) ||
849 readDbl(line, pos[2], fieldLen, _OMEGA0) ||
850 readDbl(line, pos[3], fieldLen, _Cis ) ) {
[6518]851 _checkState = bad;
[4891]852 return;
853 }
854 }
855
856 else if ( iLine == 4 ) {
857 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
858 readDbl(line, pos[1], fieldLen, _Crc ) ||
859 readDbl(line, pos[2], fieldLen, _omega ) ||
860 readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
[6518]861 _checkState = bad;
[4891]862 return;
863 }
864 }
865
866 else if ( iLine == 5 ) {
[6792]867 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
868 readDbl(line, pos[1], fieldLen, datasource) ||
869 readDbl(line, pos[2], fieldLen, _TOEweek ) ) {
[6518]870 _checkState = bad;
[4891]871 return;
[6792]872 } else {
873 if (int(datasource) & (1<<8)) {
[6812]874 _fnav = true;
875 _inav = false;
[6792]876 } else if (int(datasource) & (1<<9)) {
[6812]877 _fnav = false;
878 _inav = true;
[6792]879 }
[6892]880 _TOEweek -= 1024.0;
[4891]881 }
882 }
883
884 else if ( iLine == 6 ) {
885 if ( readDbl(line, pos[0], fieldLen, _SISA ) ||
[6792]886 readDbl(line, pos[1], fieldLen, SVhealth) ||
[4891]887 readDbl(line, pos[2], fieldLen, _BGD_1_5A) ||
888 readDbl(line, pos[3], fieldLen, _BGD_1_5B) ) {
[6518]889 _checkState = bad;
[4891]890 return;
[6792]891 } else {
892 // Bit 0
[6812]893 _e1DataInValid = (int(SVhealth) & (1<<0));
[6792]894 // Bit 1-2
[6802]895 _E1_bHS = double((int(SVhealth) >> 1) & 0x3);
[6792]896 // Bit 3
[6812]897 _e5aDataInValid = (int(SVhealth) & (1<<3));
[6792]898 // Bit 4-5
[6802]899 _E5aHS = double((int(SVhealth) >> 4) & 0x3);
[6792]900 // Bit 6
[6812]901 _e5bDataInValid = (int(SVhealth) & (1<<6));
[6792]902 // Bit 7-8
[6802]903 _E5bHS = double((int(SVhealth) >> 7) & 0x3);
[6809]904
905 if (prnStr.at(0) == 'E') {
[7140]906 _prn.set('E', prnStr.mid(1).toInt(), _inav ? 1 : 0);
[6809]907 }
[4891]908 }
909 }
910
911 else if ( iLine == 7 ) {
912 if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
[6518]913 _checkState = bad;
[4891]914 return;
915 }
916 }
917 }
[3659]918}
[4013]919
[6801]920// Compute Galileo Satellite Position (virtual)
921////////////////////////////////////////////////////////////////////////////
922t_irc t_ephGal::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
[4013]923
[6801]924 static const double omegaEarth = 7292115.1467e-11;
[8213]925 static const double gmWGS = 398.6004418e12;
[4023]926
[8541]927 memset(xc, 0, 6*sizeof(double));
[6801]928 memset(vv, 0, 3*sizeof(double));
[4023]929
[6801]930 double a0 = _sqrt_A * _sqrt_A;
931 if (a0 == 0) {
932 return failure;
933 }
[4023]934
[6801]935 double n0 = sqrt(gmWGS/(a0*a0*a0));
[4023]936
[6801]937 bncTime tt(GPSweek, GPSweeks);
938 double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
[4023]939
[6801]940 double n = n0 + _Delta_n;
941 double M = _M0 + n*tk;
942 double E = M;
943 double E_last;
[8370]944 int nLoop = 0;
[6801]945 do {
946 E_last = E;
947 E = M + _e*sin(E);
[8370]948
949 if (++nLoop == 100) {
950 return failure;
951 }
[6801]952 } while ( fabs(E-E_last)*a0 > 0.001 );
953 double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
954 double u0 = v + _omega;
955 double sin2u0 = sin(2*u0);
956 double cos2u0 = cos(2*u0);
957 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
958 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
959 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
960 double xp = r*cos(u);
961 double yp = r*sin(u);
962 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
963 omegaEarth*_TOEsec;
[4023]964
[6801]965 double sinom = sin(OM);
966 double cosom = cos(OM);
967 double sini = sin(i);
968 double cosi = cos(i);
969 xc[0] = xp*cosom - yp*cosi*sinom;
970 xc[1] = xp*sinom + yp*cosi*cosom;
971 xc[2] = yp*sini;
[4023]972
[6801]973 double tc = tt - _TOC;
974 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
[4023]975
[6801]976 // Velocity
977 // --------
978 double tanv2 = tan(v/2);
979 double dEdM = 1 / (1 - _e*cos(E));
980 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
981 * dEdM * n;
982 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
983 double dotom = _OMEGADOT - omegaEarth;
984 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
985 double dotr = a0 * _e*sin(E) * dEdM * n
986 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
987 double dotx = dotr*cos(u) - r*sin(u)*dotu;
988 double doty = dotr*sin(u) + r*cos(u)*dotu;
[4023]989
[6801]990 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
991 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
992 + yp*sini*sinom*doti; // dX / di
993
994 vv[1] = sinom *dotx + cosi*cosom *doty
995 + xp*cosom*dotom - yp*cosi*sinom*dotom
996 - yp*sini*cosom*doti;
997
998 vv[2] = sini *doty + yp*cosi *doti;
999
1000 // Relativistic Correction
1001 // -----------------------
[7481]1002 // correspondent to Galileo ICD and to SSR standard
1003 xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
1004 // correspondent to IGS convention
1005 //xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
[6801]1006
[8541]1007 xc[4] = _clock_drift + _clock_driftrate*tc;
1008 xc[5] = _clock_driftrate;
1009
[6801]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
1303 bncTime tt(GPSweek, GPSweeks);
1304 double dt = tt - _TOC;
1305
[7278]1306 xc[0] = _x_pos + _x_velocity * dt + _x_acceleration * dt * dt / 2.0;
1307 xc[1] = _y_pos + _y_velocity * dt + _y_acceleration * dt * dt / 2.0;
1308 xc[2] = _z_pos + _z_velocity * dt + _z_acceleration * dt * dt / 2.0;
[6386]1309
1310 vv[0] = _x_velocity + _x_acceleration * dt;
1311 vv[1] = _y_velocity + _y_acceleration * dt;
1312 vv[2] = _z_velocity + _z_acceleration * dt;
1313
1314 xc[3] = _agf0 + _agf1 * dt;
1315
[8541]1316 xc[4] = _agf1;
1317 xc[5] = 0.0;
[8484]1318
[6386]1319 return success;
[6385]1320}
1321
1322// RINEX Format String
1323//////////////////////////////////////////////////////////////////////////////
[6388]1324QString t_ephSBAS::toString(double version) const {
1325
1326 QString rnxStr = rinexDateStr(_TOC, _prn, version);
1327
1328 QTextStream out(&rnxStr);
1329
1330 out << QString("%1%2%3\n")
[6390]1331 .arg(_agf0, 19, 'e', 12)
1332 .arg(_agf1, 19, 'e', 12)
[8455]1333 .arg(_TOT, 19, 'e', 12);
[6388]1334
1335 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
1336
1337 out << QString(fmt)
1338 .arg(1.e-3*_x_pos, 19, 'e', 12)
1339 .arg(1.e-3*_x_velocity, 19, 'e', 12)
1340 .arg(1.e-3*_x_acceleration, 19, 'e', 12)
[6390]1341 .arg(_health, 19, 'e', 12);
[6388]1342
1343 out << QString(fmt)
1344 .arg(1.e-3*_y_pos, 19, 'e', 12)
1345 .arg(1.e-3*_y_velocity, 19, 'e', 12)
1346 .arg(1.e-3*_y_acceleration, 19, 'e', 12)
[6390]1347 .arg(_ura, 19, 'e', 12);
[6388]1348
1349 out << QString(fmt)
1350 .arg(1.e-3*_z_pos, 19, 'e', 12)
1351 .arg(1.e-3*_z_velocity, 19, 'e', 12)
1352 .arg(1.e-3*_z_acceleration, 19, 'e', 12)
[6536]1353 .arg(double(_IODN), 19, 'e', 12);
[6388]1354
1355 return rnxStr;
[6385]1356}
[6400]1357
1358// Constructor
1359//////////////////////////////////////////////////////////////////////////////
[6600]1360t_ephBDS::t_ephBDS(float rnxVersion, const QStringList& lines) {
[6400]1361
1362 const int nLines = 8;
1363
1364 if (lines.size() != nLines) {
[6518]1365 _checkState = bad;
[6400]1366 return;
1367 }
1368
1369 // RINEX Format
1370 // ------------
1371 int fieldLen = 19;
1372
1373 int pos[4];
1374 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
1375 pos[1] = pos[0] + fieldLen;
1376 pos[2] = pos[1] + fieldLen;
1377 pos[3] = pos[2] + fieldLen;
1378
1379 // Read eight lines
1380 // ----------------
1381 for (int iLine = 0; iLine < nLines; iLine++) {
1382 QString line = lines[iLine];
1383
1384 if ( iLine == 0 ) {
1385 QTextStream in(line.left(pos[1]).toAscii());
1386
1387 int year, month, day, hour, min;
1388 double sec;
[6880]1389
[7139]1390 QString prnStr, n;
[6880]1391 in >> prnStr;
[7639]1392 if (prnStr.size() == 1 && prnStr[0] == 'C') {
[7139]1393 in >> n;
1394 prnStr.append(n);
[6880]1395 }
1396 in >> year >> month >> day >> hour >> min >> sec;
[6400]1397 if (prnStr.at(0) == 'C') {
1398 _prn.set('C', prnStr.mid(1).toInt());
1399 }
1400 else {
1401 _prn.set('C', prnStr.toInt());
1402 }
1403
1404 if (year < 80) {
1405 year += 2000;
1406 }
1407 else if (year < 100) {
1408 year += 1900;
1409 }
1410
[6812]1411 _TOC.setBDS(year, month, day, hour, min, sec);
[6400]1412
1413 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
1414 readDbl(line, pos[2], fieldLen, _clock_drift ) ||
1415 readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
[6518]1416 _checkState = bad;
[6400]1417 return;
1418 }
1419 }
1420
1421 else if ( iLine == 1 ) {
1422 double aode;
1423 if ( readDbl(line, pos[0], fieldLen, aode ) ||
1424 readDbl(line, pos[1], fieldLen, _Crs ) ||
1425 readDbl(line, pos[2], fieldLen, _Delta_n) ||
1426 readDbl(line, pos[3], fieldLen, _M0 ) ) {
[6518]1427 _checkState = bad;
[6400]1428 return;
1429 }
1430 _AODE = int(aode);
1431 }
1432
1433 else if ( iLine == 2 ) {
1434 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
1435 readDbl(line, pos[1], fieldLen, _e ) ||
1436 readDbl(line, pos[2], fieldLen, _Cus ) ||
1437 readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
[6518]1438 _checkState = bad;
[6400]1439 return;
1440 }
1441 }
1442
1443 else if ( iLine == 3 ) {
[6812]1444 if ( readDbl(line, pos[0], fieldLen, _TOEsec ) ||
[6400]1445 readDbl(line, pos[1], fieldLen, _Cic ) ||
1446 readDbl(line, pos[2], fieldLen, _OMEGA0) ||
1447 readDbl(line, pos[3], fieldLen, _Cis ) ) {
[6518]1448 _checkState = bad;
[6400]1449 return;
1450 }
1451 }
1452
1453 else if ( iLine == 4 ) {
1454 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
1455 readDbl(line, pos[1], fieldLen, _Crc ) ||
1456 readDbl(line, pos[2], fieldLen, _omega ) ||
1457 readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
[6518]1458 _checkState = bad;
[6400]1459 return;
1460 }
1461 }
1462
1463 else if ( iLine == 5 ) {
1464 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
[6812]1465 readDbl(line, pos[2], fieldLen, _TOEweek)) {
[6518]1466 _checkState = bad;
[6400]1467 return;
1468 }
1469 }
1470
1471 else if ( iLine == 6 ) {
1472 double SatH1;
[6755]1473 if ( readDbl(line, pos[0], fieldLen, _URA ) ||
1474 readDbl(line, pos[1], fieldLen, SatH1) ||
[6400]1475 readDbl(line, pos[2], fieldLen, _TGD1) ||
1476 readDbl(line, pos[3], fieldLen, _TGD2) ) {
[6518]1477 _checkState = bad;
[6400]1478 return;
1479 }
1480 _SatH1 = int(SatH1);
1481 }
1482
1483 else if ( iLine == 7 ) {
1484 double aodc;
[6812]1485 if ( readDbl(line, pos[0], fieldLen, _TOT) ||
[6400]1486 readDbl(line, pos[1], fieldLen, aodc) ) {
[6518]1487 _checkState = bad;
[6400]1488 return;
1489 }
[6812]1490 if (_TOT == 0.9999e9) { // 0.9999e9 means not known (RINEX standard)
1491 _TOT = _TOEsec;
[6400]1492 }
1493 _AODC = int(aodc);
1494 }
1495 }
1496
[7138]1497 _TOE.setBDS(int(_TOEweek), _TOEsec);
1498
[6400]1499 // remark: actually should be computed from second_tot
1500 // but it seems to be unreliable in RINEX files
[6843]1501 //_TOT = _TOC.bdssec();
[6400]1502}
1503
[7054]1504// IOD of BDS Ephemeris (virtual)
1505////////////////////////////////////////////////////////////////////////////
[7169]1506unsigned int t_ephBDS::IOD() const {
[7054]1507 unsigned char buffer[80];
1508 int size = 0;
1509 int numbits = 0;
1510 long long bitbuffer = 0;
1511 unsigned char *startbuffer = buffer;
1512
1513 BDSADDBITSFLOAT(14, this->_IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
1514 BDSADDBITSFLOAT(11, this->_clock_driftrate, 1.0/static_cast<double>(1<<30)
1515 /static_cast<double>(1<<30)/static_cast<double>(1<<6))
1516 BDSADDBITSFLOAT(22, this->_clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<20))
1517 BDSADDBITSFLOAT(24, this->_clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
1518 BDSADDBITSFLOAT(18, this->_Crs, 1.0/static_cast<double>(1<<6))
1519 BDSADDBITSFLOAT(16, this->_Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
1520 BDSADDBITSFLOAT(32, this->_M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1521 BDSADDBITSFLOAT(18, this->_Cuc, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1522 BDSADDBITSFLOAT(32, this->_e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
1523 BDSADDBITSFLOAT(18, this->_Cus, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1524 BDSADDBITSFLOAT(32, this->_sqrt_A, 1.0/static_cast<double>(1<<19))
1525 BDSADDBITSFLOAT(18, this->_Cic, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1526 BDSADDBITSFLOAT(32, this->_OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1527 BDSADDBITSFLOAT(18, this->_Cis, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1528 BDSADDBITSFLOAT(32, this->_i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1529 BDSADDBITSFLOAT(18, this->_Crc, 1.0/static_cast<double>(1<<6))
1530 BDSADDBITSFLOAT(32, this->_omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
1531 BDSADDBITSFLOAT(24, this->_OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
1532 BDSADDBITS(5, 0) // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
1533
1534 return CRC24(size, startbuffer);
1535}
1536
[6601]1537// Compute BDS Satellite Position (virtual)
[6400]1538//////////////////////////////////////////////////////////////////////////////
[6600]1539t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
[6400]1540
[6602]1541 static const double gmBDS = 398.6004418e12;
1542 static const double omegaBDS = 7292115.0000e-11;
[6400]1543
1544 xc[0] = xc[1] = xc[2] = xc[3] = 0.0;
1545 vv[0] = vv[1] = vv[2] = 0.0;
1546
1547 bncTime tt(GPSweek, GPSweeks);
1548
1549 if (_sqrt_A == 0) {
1550 return failure;
1551 }
1552 double a0 = _sqrt_A * _sqrt_A;
1553
[6602]1554 double n0 = sqrt(gmBDS/(a0*a0*a0));
[6400]1555 double tk = tt - _TOE;
1556 double n = n0 + _Delta_n;
1557 double M = _M0 + n*tk;
1558 double E = M;
1559 double E_last;
1560 int nLoop = 0;
1561 do {
1562 E_last = E;
1563 E = M + _e*sin(E);
1564
1565 if (++nLoop == 100) {
1566 return failure;
1567 }
1568 } while ( fabs(E-E_last)*a0 > 0.001 );
1569
1570 double v = atan2(sqrt(1-_e*_e) * sin(E), cos(E) - _e);
1571 double u0 = v + _omega;
1572 double sin2u0 = sin(2*u0);
1573 double cos2u0 = cos(2*u0);
1574 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
1575 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
1576 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
1577 double xp = r*cos(u);
1578 double yp = r*sin(u);
1579 double toesec = (_TOE.gpssec() - 14.0);
1580 double sinom = 0;
1581 double cosom = 0;
1582 double sini = 0;
1583 double cosi = 0;
[7278]1584
[7481]1585 // Velocity
1586 // --------
1587 double tanv2 = tan(v/2);
1588 double dEdM = 1 / (1 - _e*cos(E));
1589 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2)
1590 / (1 + tanv2*tanv2) * dEdM * n;
1591 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
1592 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
1593 double dotr = a0 * _e*sin(E) * dEdM * n
1594 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
1595
1596 double dotx = dotr*cos(u) - r*sin(u)*dotu;
1597 double doty = dotr*sin(u) + r*cos(u)*dotu;
1598
[6400]1599 const double iMaxGEO = 10.0 / 180.0 * M_PI;
1600
1601 // MEO/IGSO satellite
1602 // ------------------
1603 if (_i0 > iMaxGEO) {
[6602]1604 double OM = _OMEGA0 + (_OMEGADOT - omegaBDS)*tk - omegaBDS*toesec;
[6400]1605
1606 sinom = sin(OM);
1607 cosom = cos(OM);
1608 sini = sin(i);
1609 cosi = cos(i);
1610
1611 xc[0] = xp*cosom - yp*cosi*sinom;
1612 xc[1] = xp*sinom + yp*cosi*cosom;
[7278]1613 xc[2] = yp*sini;
[7481]1614
1615 // Velocity
1616 // --------
1617
1618 double dotom = _OMEGADOT - t_CST::omega;
1619
1620 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
1621 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
1622 + yp*sini*sinom*doti; // dX / di
1623
1624 vv[1] = sinom *dotx + cosi*cosom *doty
1625 + xp*cosom*dotom - yp*cosi*sinom*dotom
1626 - yp*sini*cosom*doti;
1627
1628 vv[2] = sini *doty + yp*cosi *doti;
1629
[6400]1630 }
1631
1632 // GEO satellite
1633 // -------------
1634 else {
[6602]1635 double OM = _OMEGA0 + _OMEGADOT*tk - omegaBDS*toesec;
1636 double ll = omegaBDS*tk;
[6400]1637
1638 sinom = sin(OM);
1639 cosom = cos(OM);
1640 sini = sin(i);
1641 cosi = cos(i);
1642
1643 double xx = xp*cosom - yp*cosi*sinom;
1644 double yy = xp*sinom + yp*cosi*cosom;
[7278]1645 double zz = yp*sini;
[6400]1646
[7487]1647 Matrix RX = BNC_PPP::t_astro::rotX(-5.0 / 180.0 * M_PI);
1648 Matrix RZ = BNC_PPP::t_astro::rotZ(ll);
[6400]1649
1650 ColumnVector X1(3); X1 << xx << yy << zz;
[7487]1651 ColumnVector X2 = RZ*RX*X1;
[6400]1652
1653 xc[0] = X2(1);
1654 xc[1] = X2(2);
1655 xc[2] = X2(3);
[7278]1656
[7481]1657 double dotom = _OMEGADOT;
[6400]1658
[7481]1659 double vx = cosom *dotx - cosi*sinom *doty
1660 - xp*sinom*dotom - yp*cosi*cosom*dotom
1661 + yp*sini*sinom*doti;
[6400]1662
[7481]1663 double vy = sinom *dotx + cosi*cosom *doty
1664 + xp*cosom*dotom - yp*cosi*sinom*dotom
1665 - yp*sini*cosom*doti;
[7278]1666
[7501]1667 double vz = sini *doty + yp*cosi *doti;
[6400]1668
[7501]1669 ColumnVector V(3); V << vx << vy << vz;
[7481]1670
[7487]1671 Matrix RdotZ(3,3);
[7481]1672 double C = cos(ll);
1673 double S = sin(ll);
1674 Matrix UU(3,3);
1675 UU[0][0] = -S; UU[0][1] = +C; UU[0][2] = 0.0;
1676 UU[1][0] = -C; UU[1][1] = -S; UU[1][2] = 0.0;
1677 UU[2][0] = 0.0; UU[2][1] = 0.0; UU[2][2] = 0.0;
[7487]1678 RdotZ = omegaBDS * UU;
[7481]1679
1680 ColumnVector VV(3);
[7487]1681 VV = RZ*RX*V + RdotZ*RX*X1;
[7481]1682
1683 vv[0] = VV(1);
1684 vv[1] = VV(2);
1685 vv[2] = VV(3);
1686 }
1687
1688 double tc = tt - _TOC;
1689 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
1690
[7278]1691 // dotC = _clock_drift + _clock_driftrate*tc
[6400]1692 // - 4.442807633e-10*_e*sqrt(a0)*cos(E) * dEdM * n;
1693
[7481]1694 // Relativistic Correction
1695 // -----------------------
1696 // correspondent to BDS ICD and to SSR standard
[8541]1697 xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
[7481]1698 // correspondent to IGS convention
1699 // xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
1700
[8541]1701 xc[4] = _clock_drift + _clock_driftrate*tc;
1702 xc[5] = _clock_driftrate;
1703
[6400]1704 return success;
1705}
1706
1707// RINEX Format String
1708//////////////////////////////////////////////////////////////////////////////
[6600]1709QString t_ephBDS::toString(double version) const {
[6400]1710
[6812]1711 QString rnxStr = rinexDateStr(_TOC-14.0, _prn, version);
[6400]1712
1713 QTextStream out(&rnxStr);
1714
1715 out << QString("%1%2%3\n")
1716 .arg(_clock_bias, 19, 'e', 12)
1717 .arg(_clock_drift, 19, 'e', 12)
1718 .arg(_clock_driftrate, 19, 'e', 12);
1719
1720 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
1721
1722 out << QString(fmt)
1723 .arg(double(_AODE), 19, 'e', 12)
1724 .arg(_Crs, 19, 'e', 12)
1725 .arg(_Delta_n, 19, 'e', 12)
1726 .arg(_M0, 19, 'e', 12);
1727
1728 out << QString(fmt)
1729 .arg(_Cuc, 19, 'e', 12)
1730 .arg(_e, 19, 'e', 12)
1731 .arg(_Cus, 19, 'e', 12)
1732 .arg(_sqrt_A, 19, 'e', 12);
1733
[6843]1734 double toes = 0.0;
1735 if (_TOEweek > -1.0) {// RINEX input
1736 toes = _TOEsec;
1737 }
1738 else {// RTCM stream input
[6812]1739 toes = _TOE.bdssec();
[6755]1740 }
[6400]1741 out << QString(fmt)
[6843]1742 .arg(toes, 19, 'e', 12)
[6755]1743 .arg(_Cic, 19, 'e', 12)
1744 .arg(_OMEGA0, 19, 'e', 12)
1745 .arg(_Cis, 19, 'e', 12);
[6400]1746
1747 out << QString(fmt)
1748 .arg(_i0, 19, 'e', 12)
1749 .arg(_Crc, 19, 'e', 12)
1750 .arg(_omega, 19, 'e', 12)
1751 .arg(_OMEGADOT, 19, 'e', 12);
1752
[6843]1753 double toew = 0.0;
1754 if (_TOEweek > -1.0) {// RINEX input
1755 toew = _TOEweek;
1756 }
1757 else {// RTCM stream input
1758 toew = double(_TOE.bdsw());
1759 }
[6400]1760 out << QString(fmt)
[6843]1761 .arg(_IDOT, 19, 'e', 12)
1762 .arg(0.0, 19, 'e', 12)
1763 .arg(toew, 19, 'e', 12)
1764 .arg(0.0, 19, 'e', 12);
[6400]1765
1766 out << QString(fmt)
[6798]1767 .arg(_URA, 19, 'e', 12)
[6400]1768 .arg(double(_SatH1), 19, 'e', 12)
1769 .arg(_TGD1, 19, 'e', 12)
1770 .arg(_TGD2, 19, 'e', 12);
1771
[6843]1772 double tots = 0.0;
1773 if (_TOEweek > -1.0) {// RINEX input
1774 tots = _TOT;
1775 }
1776 else {// RTCM stream input
[6812]1777 tots = _TOE.bdssec();
[6755]1778 }
[6400]1779 out << QString(fmt)
[6792]1780 .arg(tots, 19, 'e', 12)
[6755]1781 .arg(double(_AODC), 19, 'e', 12)
1782 .arg("", 19, QChar(' '))
1783 .arg("", 19, QChar(' '));
[6400]1784 return rnxStr;
1785}
Note: See TracBrowser for help on using the repository browser.