source: ntrip/trunk/BNC/src/ephemeris.cpp@ 10605

Last change on this file since 10605 was 10603, checked in by stuerze, 6 days ago

minor changes

File size: 86.3 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"
[10533]16#include "RTCM3/bits.h"
[1025]17
18using namespace std;
19
[5749]20// Constructor
21////////////////////////////////////////////////////////////////////////////
22t_eph::t_eph() {
[6518]23 _checkState = unchecked;
[10587]24 _type = undefined;
[10577]25 _orbCorr = 0;
26 _clkCorr = 0;
[5749]27}
[7278]28// Destructor
29////////////////////////////////////////////////////////////////////////////
30t_eph::~t_eph() {
31 if (_orbCorr)
32 delete _orbCorr;
33 if (_clkCorr)
34 delete _clkCorr;
35}
[5749]36
[7481]37//
[5749]38////////////////////////////////////////////////////////////////////////////
[10577]39void t_eph::setOrbCorr(const t_orbCorr *orbCorr) {
[7888]40 if (_orbCorr) {
41 delete _orbCorr;
42 _orbCorr = 0;
43 }
[6141]44 _orbCorr = new t_orbCorr(*orbCorr);
[5749]45}
46
[7481]47//
[5749]48////////////////////////////////////////////////////////////////////////////
[10577]49void t_eph::setClkCorr(const t_clkCorr *clkCorr) {
[7888]50 if (_clkCorr) {
51 delete _clkCorr;
52 _clkCorr = 0;
53 }
[6141]54 _clkCorr = new t_clkCorr(*clkCorr);
[5749]55}
56
[7481]57//
[5749]58////////////////////////////////////////////////////////////////////////////
[10577]59t_irc t_eph::getCrd(const bncTime &tt, ColumnVector &xc, ColumnVector &vv,
60 bool useCorr) const {
[6518]61
[10577]62 if (_checkState == bad || _checkState == unhealthy
63 || _checkState == outdated) {
[6518]64 return failure;
65 }
[8903]66
[8542]67 xc.ReSize(6);
[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) {
[8903]76 dtO -= (0.5 * ssrUpdateInt[_orbCorr->_updateInt]);
[6556]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
[10577]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);
[10577]90 RSW_to_XYZ(xc.Rows(1, 3), vv.Rows(1, 3), _orbCorr->_dotXr, dv);
[7133]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) {
[8903]98 dtC -= (0.5 * ssrUpdateInt[_clkCorr->_updateInt]);
[6556]99 }
[10577]100 xc[3] += _clkCorr->_dClk + _clkCorr->_dotDClk * dtC
101 + _clkCorr->_dotDotDClk * dtC * dtC;
102 } else {
[5839]103 return failure;
104 }
[5749]105 }
106 return success;
107}
108
[6801]109//
110//////////////////////////////////////////////////////////////////////////////
[10603]111void t_eph::setType(QString typeStr) {
112
113 if (typeStr == "LNAV") {
114 _type = t_eph::LNAV;
115 } else if (typeStr == "FDMA") {
116 _type = t_eph::FDMA;
117 } else if (typeStr == "FNAV") {
118 _type = t_eph::FNAV;
119 } else if (typeStr == "INAV") {
120 _type = t_eph::INAV;
121 } else if (typeStr == "D1") {
122 _type = t_eph::D1;
123 } else if (typeStr == "D2") {
124 _type = t_eph::D2;
125 } else if (typeStr == "SBAS") {
126 _type = t_eph::SBASL1;
127 } else if (typeStr == "CNAV") {
128 _type = t_eph::CNAV;
129 } else if (typeStr == "CNV1") {
130 _type = t_eph::CNV1;
131 } else if (typeStr == "CNV2") {
132 _type = t_eph::CNV2;
133 } else if (typeStr == "CNV3") {
134 _type = t_eph::CNV3;
135 } else if (typeStr == "L1NV") {
136 _type = t_eph::L1NV;
137 } else if (typeStr == "L1OC") {
138 _type = t_eph::L1OC;
139 } else if (typeStr == "L3OC") {
140 _type = t_eph::L3OC;
141 } else {
142 _type = t_eph::undefined;
143 }
144
145}
146
147
148//
149//////////////////////////////////////////////////////////////////////////////
[10587]150QString t_eph::typeStr(e_type type, const t_prn &prn, double version) {
151 QString typeStr = "";
[10577]152 QString epochStart;
153 QString eolStr;
[9765]154
[10577]155 if (version < 4.0) {
[10587]156 return typeStr;
[10577]157 }
[9765]158
[10587]159 if (version == 99.0) { // log output for OUTDATED, WRONG or UNHEALTHY satellites
[10577]160 epochStart = "";
161 eolStr = "";
162 } else {
163 epochStart = "> ";
164 eolStr = "\n";
165 }
[9765]166
[10577]167 QString ephStr = QString("EPH %1 ").arg(prn.toString().c_str());
[10587]168 switch (type) {
[10577]169 case undefined:
[10587]170 typeStr = epochStart + ephStr + "unknown" + eolStr;
[10577]171 break;
172 case LNAV:
[10587]173 typeStr = epochStart + ephStr + "LNAV" + eolStr;
[10577]174 break;
175 case FDMA:
[10599]176 case FDMA_M:
[10587]177 typeStr = epochStart + ephStr + "FDMA" + eolStr;
[10577]178 break;
179 case FNAV:
[10587]180 typeStr = epochStart + ephStr + "FNAV" + eolStr;
[10577]181 break;
[10587]182 case INAV:
183 typeStr = epochStart + ephStr + "INAV" + eolStr;
[10577]184 break;
185 case D1:
[10587]186 typeStr = epochStart + ephStr + "D1 " + eolStr;
[10577]187 break;
188 case D2:
[10587]189 typeStr = epochStart + ephStr + "D2 " + eolStr;
[10577]190 break;
191 case SBASL1:
[10587]192 typeStr = epochStart + ephStr + "SBAS" + eolStr;
[10577]193 break;
194 case CNAV:
[10587]195 typeStr = epochStart + ephStr + "CNAV" + eolStr;
[10577]196 break;
197 case CNV1:
[10587]198 typeStr = epochStart + ephStr + "CNV1" + eolStr;
[10577]199 break;
200 case CNV2:
[10587]201 typeStr = epochStart + ephStr + "CNV2" + eolStr;
[10577]202 break;
203 case CNV3:
[10587]204 typeStr = epochStart + ephStr + "CNV3" + eolStr;
[10577]205 break;
206 case L1NV:
[10587]207 typeStr = epochStart + ephStr + "L1NV" + eolStr;
[10577]208 break;
209 case L1OC:
[10587]210 typeStr = epochStart + ephStr + "L1OC" + eolStr;
[10577]211 break;
212 case L3OC:
[10587]213 typeStr = epochStart + ephStr + "L3OC" + eolStr;
[10577]214 break;
[9765]215 }
[10587]216 return typeStr;
[10577]217}
[9765]218
219//
220//////////////////////////////////////////////////////////////////////////////
[10577]221QString t_eph::rinexDateStr(const bncTime &tt, const t_prn &prn,
222 double version) {
[6801]223 QString prnStr(prn.toString().c_str());
224 return rinexDateStr(tt, prnStr, version);
225}
226
227//
228//////////////////////////////////////////////////////////////////////////////
[10577]229QString t_eph::rinexDateStr(const bncTime &tt, const QString &prnStr,
230 double version) {
[6801]231
232 QString datStr;
233
234 unsigned year, month, day, hour, min;
[10577]235 double sec;
[6801]236 tt.civil_date(year, month, day);
237 tt.civil_time(hour, min, sec);
238
239 QTextStream out(&datStr);
240
241 if (version < 3.0) {
[10577]242 QString prnHlp = prnStr.mid(1, 2);
243 if (prnHlp[0] == '0')
244 prnHlp[0] = ' ';
245 out << prnHlp
246 << QString(" %1 %2 %3 %4 %5%6").arg(year % 100, 2, 10, QChar('0')).arg(
247 month, 2).arg(day, 2).arg(hour, 2).arg(min, 2).arg(sec, 5, 'f', 1);
[10587]248 }
249 else if (version == 99) {
[10577]250 out
251 << QString(" %1 %2 %3 %4 %5 %6").arg(year, 4).arg(month, 2, 10,
252 QChar('0')).arg(day, 2, 10, QChar('0')).arg(hour, 2, 10, QChar('0')).arg(
253 min, 2, 10, QChar('0')).arg(int(sec), 2, 10, QChar('0'));
[10587]254 }
255 else {
[10577]256 out << prnStr
257 << QString(" %1 %2 %3 %4 %5 %6").arg(year, 4).arg(month, 2, 10,
258 QChar('0')).arg(day, 2, 10, QChar('0')).arg(hour, 2, 10, QChar('0')).arg(
259 min, 2, 10, QChar('0')).arg(int(sec), 2, 10, QChar('0'));
[6801]260 }
261
262 return datStr;
263}
264
265// Constructor
266//////////////////////////////////////////////////////////////////////////////
[10603]267t_ephGPS::t_ephGPS(double rnxVersion, const QStringList &lines, QString typeStr) {
268
269 setType(typeStr);
270
[10587]271 int nLines = 8; // LNAV
272 // Source RINEX version < 4
273 if (type() == t_eph::undefined) {
274 _type = t_eph::LNAV;
275 }
276
277 if (type() == t_eph::CNAV ||
278 type() == t_eph::L1NV) {
[9786]279 nLines += 1;
280 }
[10587]281 if (type() == t_eph::CNV2) {
[9786]282 nLines += 2;
283 }
284
[6801]285 if (lines.size() != nLines) {
286 _checkState = bad;
287 return;
288 }
289
290 // RINEX Format
291 // ------------
292 int fieldLen = 19;
[10587]293 double statusflags = 0.0;
[6801]294
295 int pos[4];
[10577]296 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
[6801]297 pos[1] = pos[0] + fieldLen;
298 pos[2] = pos[1] + fieldLen;
299 pos[3] = pos[2] + fieldLen;
300
[10587]301 // Read nLines lines
302 // ------------------
[6801]303 for (int iLine = 0; iLine < nLines; iLine++) {
304 QString line = lines[iLine];
305
[10577]306 if (iLine == 0) {
[8204]307 QTextStream in(line.left(pos[1]).toLatin1());
[10577]308 int year, month, day, hour, min;
[6801]309 double sec;
310
[7139]311 QString prnStr, n;
[6880]312 in >> prnStr;
[7639]313
[10587]314 if (prnStr.size() == 1 &&
315 (prnStr[0] == 'G' ||
316 prnStr[0] == 'J' ||
317 prnStr[0] == 'I')) {
[7139]318 in >> n;
319 prnStr.append(n);
[6880]320 }
[7639]321
[10587]322 if ( prnStr.at(0) == 'G') {
[6801]323 _prn.set('G', prnStr.mid(1).toInt());
[10577]324 } else if (prnStr.at(0) == 'J') {
[6801]325 _prn.set('J', prnStr.mid(1).toInt());
[10577]326 } else if (prnStr.at(0) == 'I') {
[8168]327 _prn.set('I', prnStr.mid(1).toInt());
[10577]328 } else {
[6801]329 _prn.set('G', prnStr.toInt());
330 }
[10599]331 _prn.setFlag(type());
[6801]332
[10599]333 in >> year >> month >> day >> hour >> min >> sec;
334
[10577]335 if (year < 80) {
[6801]336 year += 2000;
[10577]337 } else if (year < 100) {
[6801]338 year += 1900;
339 }
340
341 _TOC.set(year, month, day, hour, min, sec);
342
[10577]343 if ( readDbl(line, pos[1], fieldLen, _clock_bias)
344 || readDbl(line, pos[2], fieldLen, _clock_drift)
345 || readDbl(line, pos[3], fieldLen, _clock_driftrate)) {
[6801]346 _checkState = bad;
347 return;
348 }
349 }
[9786]350 // =====================
351 // BROADCAST ORBIT - 1
352 // =====================
[10577]353 else if (iLine == 1) {
[10587]354 if (type() == t_eph::CNAV ||
355 type() == t_eph::CNV2 ||
356 type() == t_eph::L1NV) {
[10577]357 if ( readDbl(line, pos[0], fieldLen, _ADOT)
358 || readDbl(line, pos[1], fieldLen, _Crs)
359 || readDbl(line, pos[2], fieldLen, _Delta_n)
360 || readDbl(line, pos[3], fieldLen, _M0)) {
[9786]361 _checkState = bad;
362 return;
363 }
[10587]364 } else { // LNAV
[10577]365 if ( readDbl(line, pos[0], fieldLen, _IODE)
366 || readDbl(line, pos[1], fieldLen, _Crs)
367 || readDbl(line, pos[2], fieldLen, _Delta_n)
368 || readDbl(line, pos[3], fieldLen, _M0)) {
369 _checkState = bad;
370 return;
371 }
[9786]372 }
[6801]373 }
[9786]374 // =====================
375 // BROADCAST ORBIT - 2
376 // =====================
[10577]377 else if (iLine == 2) {
378 if ( readDbl(line, pos[0], fieldLen, _Cuc)
379 || readDbl(line, pos[1], fieldLen, _e)
380 || readDbl(line, pos[2], fieldLen, _Cus)
381 || readDbl(line, pos[3], fieldLen, _sqrt_A)) {
[6801]382 _checkState = bad;
383 return;
384 }
385 }
[9786]386 // =====================
387 // BROADCAST ORBIT - 3
388 // =====================
[10577]389 else if (iLine == 3) {
[10587]390 if (type() == t_eph::CNAV ||
391 type() == t_eph::CNV2) {
[10577]392 if ( readDbl(line, pos[0], fieldLen, _top)
393 || readDbl(line, pos[1], fieldLen, _Cic)
394 || readDbl(line, pos[2], fieldLen, _OMEGA0)
395 || readDbl(line, pos[3], fieldLen, _Cis)) {
[9786]396 _checkState = bad;
397 return;
398 }
[10587]399 } else if (type() == t_eph::L1NV) {
[10577]400 if ( readDbl(line, pos[0], fieldLen, _IODE)
401 || readDbl(line, pos[1], fieldLen, _Cic)
402 || readDbl(line, pos[2], fieldLen, _OMEGA0)
403 || readDbl(line, pos[3], fieldLen, _Cis)) {
[9786]404 _checkState = bad;
405 return;
406 }
[10587]407 } else { // LNAV
[10577]408 if ( readDbl(line, pos[0], fieldLen, _TOEsec)
409 || readDbl(line, pos[1], fieldLen, _Cic)
410 || readDbl(line, pos[2], fieldLen, _OMEGA0)
411 || readDbl(line, pos[3], fieldLen, _Cis)) {
412 _checkState = bad;
413 return;
414 }
[9786]415 }
[6801]416 }
[9786]417 // =====================
418 // BROADCAST ORBIT - 4
419 // =====================
[10577]420 else if (iLine == 4) {
421 if ( readDbl(line, pos[0], fieldLen, _i0)
422 || readDbl(line, pos[1], fieldLen, _Crc)
423 || readDbl(line, pos[2], fieldLen, _omega)
424 || readDbl(line, pos[3], fieldLen, _OMEGADOT)) {
[6801]425 _checkState = bad;
426 return;
427 }
428 }
[9786]429 // =====================
430 // BROADCAST ORBIT - 5
431 // =====================
[10587]432 else if (iLine == 5 && system() != t_eph::IRNSS) {
433 if (type() == t_eph::CNAV ||
434 type() == t_eph::CNV2) {
[10577]435 if ( readDbl(line, pos[0], fieldLen, _IDOT)
436 || readDbl(line, pos[1], fieldLen, _Delta_n_dot)
437 || readDbl(line, pos[2], fieldLen, _URAI_NED0)
438 || readDbl(line, pos[3], fieldLen, _URAI_NED1)) {
[9786]439 _checkState = bad;
440 return;
441 }
[6801]442 }
[10587]443 else { // LNAV
[10577]444 if ( readDbl(line, pos[0], fieldLen, _IDOT)
445 || readDbl(line, pos[1], fieldLen, _L2Codes)
446 || readDbl(line, pos[2], fieldLen, _TOEweek)
447 || readDbl(line, pos[3], fieldLen, _L2PFlag)) {
[9786]448 _checkState = bad;
449 return;
450 }
451 }
[10587]452 } else if (iLine == 5 && system() == t_eph::IRNSS) {
453 if (type() == t_eph::LNAV) {
[10577]454 if ( readDbl(line, pos[0], fieldLen, _IDOT)
455 || readDbl(line, pos[2], fieldLen, _TOEweek)) {
456 _checkState = bad;
457 return;
458 }
[8168]459 }
[10587]460 else if (type() == t_eph::L1NV) {
[10577]461 if ( readDbl(line, pos[0], fieldLen, _IDOT)
462 || readDbl(line, pos[1], fieldLen, _Delta_n_dot)
463 || readDbl(line, pos[3], fieldLen, _RSF)) {
464 _checkState = bad;
465 return;
466 }
467 }
[8168]468 }
[9786]469 // =====================
470 // BROADCAST ORBIT - 6
471 // =====================
[10587]472 else if (iLine == 6 && system() != t_eph::IRNSS) {
473 if (type() == t_eph::CNAV ||
474 type() == t_eph::CNV2) {
[10577]475 if ( readDbl(line, pos[0], fieldLen, _URAI_ED)
476 || readDbl(line, pos[1], fieldLen, _health)
477 || readDbl(line, pos[2], fieldLen, _TGD)
478 || readDbl(line, pos[3], fieldLen, _URAI_NED2)) {
[9786]479 _checkState = bad;
480 return;
481 }
[10587]482 } else { // LNAV
[10577]483 if ( readDbl(line, pos[0], fieldLen, _ura)
484 || readDbl(line, pos[1], fieldLen, _health)
485 || readDbl(line, pos[2], fieldLen, _TGD)
486 || readDbl(line, pos[3], fieldLen, _IODC)) {
[9786]487 _checkState = bad;
488 return;
489 }
490 }
[6801]491 }
[10587]492 else if (iLine == 6 && system() == t_eph::IRNSS) {
493 if (type() == t_eph::LNAV) {
[10577]494 if ( readDbl(line, pos[0], fieldLen, _ura)
495 || readDbl(line, pos[1], fieldLen, _health)
496 || readDbl(line, pos[2], fieldLen, _TGD)) {
497 _checkState = bad;
498 return;
499 }
[8168]500 }
[10587]501 else if (type() == t_eph::L1NV) {
[10577]502 int i = 0;
503 (!_RSF) ? i = 2 : i = 3;
504 if ( readDbl(line, pos[0], fieldLen, _URAI)
505 || readDbl(line, pos[1], fieldLen, _health)
506 || readDbl(line, pos[i], fieldLen, _TGD)) {
507 _checkState = bad;
508 return;
509 }
[10587]510 _ura = accuracyFromIndex(int(_URAI), system());
[10577]511 }
[8168]512 }
[9786]513 // =====================
514 // BROADCAST ORBIT - 7
515 // =====================
[10577]516 else if (iLine == 7) {
[10587]517 if (type() == t_eph::LNAV) {
[10577]518 if (readDbl(line, pos[0], fieldLen, _TOT)) {
[9786]519 _checkState = bad;
520 return;
[10587]521 }
522 if (system() != t_eph::IRNSS) {
523 double fitIntervalRnx;
524 if (readDbl(line, pos[1], fieldLen, fitIntervalRnx)) {
525 //fit interval BLK, do nothing
526 _flags_unknown = true;
527 } else {
528 _flags_unknown = false;
529 if (system() == t_eph::GPS) { // in RINEX specified always as time period for GPS
[9786]530 _fitInterval = fitIntervalRnx;
531 }
[10587]532 else if (system() == t_eph::QZSS) { // specified as flag for QZSS
[10577]533 if (rnxVersion == 3.02) {
534 _fitInterval = fitIntervalRnx; // specified as time period
535 } else {
536 _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::QZSS);
537 }
[9786]538 }
[8934]539 }
[8927]540 }
[8925]541 }
[10587]542 else if (type() == t_eph::CNAV ||
543 type() == t_eph::CNV2) {
[10577]544 if ( readDbl(line, pos[0], fieldLen, _ISC_L1CA)
545 || readDbl(line, pos[1], fieldLen, _ISC_L2C)
546 || readDbl(line, pos[2], fieldLen, _ISC_L5I5)
547 || readDbl(line, pos[3], fieldLen, _ISC_L5Q5)) {
[9786]548 _checkState = bad;
549 return;
550 }
551 }
[10587]552 else if (type() == t_eph::L1NV) {
[10577]553 if (!_RSF) {
554 if ( readDbl(line, pos[0], fieldLen, _ISC_S)
555 || readDbl(line, pos[1], fieldLen, _ISC_L1D)) {
556 _checkState = bad;
557 return;
558 }
559 } else {
560 if ( readDbl(line, pos[2], fieldLen, _ISC_L1P)
561 || readDbl(line, pos[3], fieldLen, _ISC_L1D)) {
562 _checkState = bad;
563 return;
564 }
565 }
566 }
[6801]567 }
[9786]568 // =====================
569 // BROADCAST ORBIT - 8
570 // =====================
[10577]571 else if (iLine == 8) {
[10587]572 if (type() == t_eph::CNAV) {
[10577]573 if ( readDbl(line, pos[0], fieldLen, _TOT)
[10587]574 || readDbl(line, pos[1], fieldLen, _wnop)) {
[9786]575 _checkState = bad;
576 return;
577 }
[10587]578 if (readDbl(line, pos[2], fieldLen, statusflags)) {
579 _flags_unknown = true;
580 }
581 else {
582 _flags_unknown = false;
[10577]583 // Bit 0:
[10599]584 _intSF = double(bitExtracted(unsigned(statusflags), 1, 0));
[10577]585 // Bit 1:
[10599]586 _L2Cphasing = double(bitExtracted(unsigned(statusflags), 1, 1));
[10577]587 // Bit 2:
[10599]588 _alert = double(bitExtracted(unsigned(statusflags), 1, 2));
[10577]589 }
[9786]590 }
[10587]591 else if (type() == t_eph::CNV2) {
[10577]592 if ( readDbl(line, pos[0], fieldLen, _ISC_L1Cd)
593 || readDbl(line, pos[1], fieldLen, _ISC_L1Cp)) {
[9786]594 _checkState = bad;
595 return;
596 }
597 }
[10587]598 else if (type() == t_eph::L1NV) {
[10577]599 if ( readDbl(line, pos[0], fieldLen, _TOT)) {
600 _checkState = bad;
601 return;
602 }
603 }
[9786]604 }
605 // =====================
606 // BROADCAST ORBIT - 9
607 // =====================
[10577]608 else if (iLine == 9) {
[10587]609 if (type() == t_eph::CNV2) {
[10577]610 if ( readDbl(line, pos[0], fieldLen, _TOT)
[10587]611 || readDbl(line, pos[1], fieldLen, _wnop)) {
[9786]612 _checkState = bad;
613 return;
614 }
[10587]615 if (readDbl(line, pos[2], fieldLen, statusflags)) {
616 _flags_unknown = true;
617 }
618 else {
619 _flags_unknown = false;
[10577]620 // Bit 0:
[10587]621 _intSF = double(bitExtracted(int(statusflags), 1, 0));
622 if (system() == t_eph::QZSS) {
[10577]623 // Bit 1:
[10587]624 _ephSF = double(bitExtracted(int(statusflags), 1, 1));
[10577]625 }
626 }
[9786]627 }
628 }
[6801]629 }
630}
631
[2222]632// Compute GPS Satellite Position (virtual)
[1025]633////////////////////////////////////////////////////////////////////////////
[10577]634t_irc t_ephGPS::position(int GPSweek, double GPSweeks, double *xc,
635 double *vv) const {
[1025]636
[1098]637 static const double omegaEarth = 7292115.1467e-11;
[10577]638 static const double gmGRS = 398.6005e12;
[1025]639
[10577]640 memset(xc, 0, 6 * sizeof(double));
641 memset(vv, 0, 3 * sizeof(double));
[1025]642
643 double a0 = _sqrt_A * _sqrt_A;
644 if (a0 == 0) {
[6213]645 return failure;
[1025]646 }
647
[10577]648 double n0 = sqrt(gmGRS / (a0 * a0 * a0));
[4018]649
650 bncTime tt(GPSweek, GPSweeks);
[4543]651 double tk = tt - bncTime(int(_TOEweek), _TOEsec);
[4018]652
[10577]653 double n = n0 + _Delta_n;
654 double M = _M0 + n * tk;
655 double E = M;
[1025]656 double E_last;
[10577]657 int nLoop = 0;
[1025]658 do {
659 E_last = E;
[10577]660 E = M + _e * sin(E);
[8368]661
662 if (++nLoop == 100) {
663 return failure;
664 }
[10577]665 } while (fabs(E - E_last) * a0 > 0.001);
666 double v = 2.0 * atan(sqrt((1.0 + _e) / (1.0 - _e)) * tan(E / 2));
667 double u0 = v + _omega;
668 double sin2u0 = sin(2 * u0);
669 double cos2u0 = cos(2 * u0);
670 double r = a0 * (1 - _e * cos(E)) + _Crc * cos2u0 + _Crs * sin2u0;
671 double i = _i0 + _IDOT * tk + _Cic * cos2u0 + _Cis * sin2u0;
672 double u = u0 + _Cuc * cos2u0 + _Cus * sin2u0;
673 double xp = r * cos(u);
674 double yp = r * sin(u);
675 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth) * tk - omegaEarth * _TOEsec;
[7278]676
[1025]677 double sinom = sin(OM);
678 double cosom = cos(OM);
[10577]679 double sini = sin(i);
680 double cosi = cos(i);
681 xc[0] = xp * cosom - yp * cosi * sinom;
682 xc[1] = xp * sinom + yp * cosi * cosom;
683 xc[2] = yp * sini;
[7481]684
[4018]685 double tc = tt - _TOC;
[10577]686 xc[3] = _clock_bias + _clock_drift * tc + _clock_driftrate * tc * tc;
[1025]687
688 // Velocity
689 // --------
[10577]690 double tanv2 = tan(v / 2);
691 double dEdM = 1 / (1 - _e * cos(E));
692 double dotv = sqrt((1.0 + _e) / (1.0 - _e)) / cos(E / 2) / cos(E / 2)
693 / (1 + tanv2 * tanv2) * dEdM * n;
694 double dotu = dotv + (-_Cuc * sin2u0 + _Cus * cos2u0) * 2 * dotv;
[1025]695 double dotom = _OMEGADOT - omegaEarth;
[10577]696 double doti = _IDOT + (-_Cic * sin2u0 + _Cis * cos2u0) * 2 * dotv;
697 double dotr = a0 * _e * sin(E) * dEdM * n
698 + (-_Crc * sin2u0 + _Crs * cos2u0) * 2 * dotv;
699 double dotx = dotr * cos(u) - r * sin(u) * dotu;
700 double doty = dotr * sin(u) + r * cos(u) * dotu;
[1025]701
[10577]702 vv[0] = cosom * dotx - cosi * sinom * doty // dX / dr
703 - xp * sinom * dotom - yp * cosi * cosom * dotom // dX / dOMEGA
704 + yp * sini * sinom * doti; // dX / di
[1025]705
[10577]706 vv[1] = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom
707 - yp * cosi * sinom * dotom - yp * sini * cosom * doti;
[1025]708
[10577]709 vv[2] = sini * doty + yp * cosi * doti;
[2429]710
711 // Relativistic Correction
712 // -----------------------
[10577]713 xc[3] -= 4.442807633e-10 * _e * sqrt(a0) * sin(E);
[9132]714
[10577]715 xc[4] = _clock_drift + _clock_driftrate * tc;
[8542]716 xc[5] = _clock_driftrate;
[8581]717
[6213]718 return success;
[1025]719}
720
[6801]721// RINEX Format String
722//////////////////////////////////////////////////////////////////////////////
723QString t_ephGPS::toString(double version) const {
[2221]724
[10587]725 if (version < 4.0 &&
726 (type() == t_eph::CNAV ||
727 type() == t_eph::CNV2 ||
728 type() == t_eph::L1NV )) {
729 return "";
730 }
731
732 QString ephStr = typeStr(_type, _prn, version);
[10577]733 QString rnxStr = ephStr + rinexDateStr(_TOC, _prn, version);
[2221]734
[6801]735 QTextStream out(&rnxStr);
[2221]736
[10577]737 out
738 << QString("%1%2%3\n")
739 .arg(_clock_bias, 19, 'e', 12)
740 .arg(_clock_drift, 19, 'e', 12)
741 .arg(_clock_driftrate, 19, 'e', 12);
[2221]742
[6801]743 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
[2221]744
[9786]745 // =====================
746 // BROADCAST ORBIT - 1
747 // =====================
[10587]748 if (type() == t_eph::CNAV ||
749 type() == t_eph::CNV2 ||
750 type() == t_eph::L1NV) {
[10577]751 out
752 << QString(fmt)
753 .arg(_ADOT, 19, 'e', 12)
754 .arg(_Crs, 19, 'e', 12)
755 .arg(_Delta_n, 19, 'e', 12)
756 .arg(_M0, 19, 'e', 12);
757 } else { // LNAV, undefined
758 out
759 << QString(fmt)
760 .arg(_IODE, 19, 'e', 12)
761 .arg(_Crs, 19, 'e', 12)
762 .arg(_Delta_n, 19, 'e', 12)
763 .arg(_M0, 19, 'e', 12);
[9786]764 }
765 // =====================
766 // BROADCAST ORBIT - 2
767 // =====================
[10577]768 out
769 << QString(fmt)
770 .arg(_Cuc, 19, 'e', 12)
771 .arg(_e, 19, 'e', 12)
772 .arg(_Cus, 19, 'e', 12)
773 .arg(_sqrt_A, 19, 'e', 12);
[9786]774 // =====================
775 // BROADCAST ORBIT - 3
776 // =====================
[10587]777 if (type() == t_eph::CNAV ||
778 type() == t_eph::CNV2) {
[10577]779 out
780 << QString(fmt)
[9786]781 .arg(_top, 19, 'e', 12)
782 .arg(_Cic, 19, 'e', 12)
783 .arg(_OMEGA0, 19, 'e', 12)
784 .arg(_Cis, 19, 'e', 12);
785 }
[10587]786 else if (type() == t_eph::L1NV) {
[10577]787 out
788 << QString(fmt)
789 .arg(_IODE, 19, 'e', 12)
790 .arg(_Cic, 19, 'e', 12)
791 .arg(_OMEGA0, 19, 'e', 12)
792 .arg(_Cis, 19, 'e', 12);
793 }
794 else { // LNAV, undefined
795 out
796 << QString(fmt)
[9786]797 .arg(_TOEsec, 19, 'e', 12)
798 .arg(_Cic, 19, 'e', 12)
799 .arg(_OMEGA0, 19, 'e', 12)
800 .arg(_Cis, 19, 'e', 12);
801 }
802 // =====================
803 // BROADCAST ORBIT - 4
804 // =====================
[10577]805 out
806 << QString(fmt)
807 .arg(_i0, 19, 'e', 12)
808 .arg(_Crc, 19, 'e', 12)
809 .arg(_omega, 19, 'e', 12)
810 .arg(_OMEGADOT, 19, 'e', 12);
[9786]811 // =====================
812 // BROADCAST ORBIT - 5
813 // =====================
[10587]814 if (system() != t_eph::IRNSS) {
815 if (type() == t_eph::CNAV ||
816 type() == t_eph::CNV2) {
[10577]817 out
818 << QString(fmt)
819 .arg(_IDOT, 19, 'e', 12)
820 .arg(_Delta_n_dot, 19, 'e', 12)
821 .arg(_URAI_NED0, 19, 'e', 12)
822 .arg(_URAI_NED1, 19, 'e', 12);
823 }
824 else { // LNAV, undefined
825 out
826 << QString(fmt)
827 .arg(_IDOT, 19, 'e', 12)
828 .arg(_L2Codes, 19, 'e', 12)
829 .arg(_TOEweek, 19, 'e', 12)
830 .arg(_L2PFlag, 19, 'e', 12);
831 }
832 }
833 else {
[10587]834 if (type() == t_eph::LNAV ||
835 type() == t_eph::undefined) {
[10577]836 out
837 << QString(fmt)
[8168]838 .arg(_IDOT, 19, 'e', 12)
[10577]839 .arg("", 19, QChar(' '))
[8800]840 .arg(_TOEweek, 19, 'e', 12)
[10577]841 .arg("", 19, QChar(' '));
[9786]842 }
[10587]843 else if (type() == t_eph::L1NV) {
[10577]844 out
845 << QString(fmt)
846 .arg(_IDOT, 19, 'e', 12)
847 .arg(_Delta_n_dot, 19, 'e', 12)
848 .arg("", 19, QChar(' '))
849 .arg(_RSF, 19, 'e', 12);
[9786]850 }
[8800]851 }
[9786]852 // =====================
853 // BROADCAST ORBIT - 6
854 // =====================
[10587]855 if (system() != t_eph::IRNSS) {
856 if (type() == t_eph::CNAV ||
857 type() == t_eph::CNV2) {
[10577]858 out
859 << QString(fmt)
860 .arg(_URAI_ED, 19, 'e', 12)
861 .arg(_health, 19, 'e', 12)
862 .arg(_TGD, 19, 'e', 12)
863 .arg(_URAI_NED2, 19, 'e', 12);
864 }
865 else { // LNAV, undefined
866 out
867 << QString(fmt)
868 .arg(_ura, 19, 'e', 12)
869 .arg(_health, 19, 'e', 12)
870 .arg(_TGD, 19, 'e', 12)
871 .arg(_IODC, 19, 'e', 12);
872 }
[8168]873 }
874 else {
[10587]875 if (type() == t_eph::LNAV ||
876 type() == t_eph::undefined) {
[10577]877 out
878 << QString(fmt)
879 .arg(_ura, 19, 'e', 12)
880 .arg(_health, 19, 'e', 12)
881 .arg(_TGD, 19, 'e', 12);
[9786]882 }
[10587]883 else if (type() == t_eph::L1NV) {
[10577]884 int i = 0; (!_RSF) ? i = 2 : i = 3;
885 if (i == 2) {
886 out
887 << QString(fmt)
888 .arg(_URAI, 19, 'e', 12)
889 .arg(_health, 19, 'e', 12)
890 .arg(_TGD, 19, 'e', 12)
891 .arg("", 19, QChar(' '));
892 }
893 else {
894 out
895 << QString(fmt)
896 .arg(_URAI, 19, 'e', 12)
897 .arg(_health, 19, 'e', 12)
898 .arg("", 19, QChar(' '))
899 .arg(_TGD, 19, 'e', 12);
900 }
[9786]901 }
[8168]902 }
[9786]903 // =====================
904 // BROADCAST ORBIT - 7
905 // =====================
[10587]906 if (type() == t_eph::LNAV ||
907 type() == t_eph::undefined) {
[6801]908
[9786]909 double tot = _TOT;
910 if (tot == 0.9999e9 && version < 3.0) {
911 tot = 0.0;
912 }
913 // fitInterval
[10587]914 if (system() == t_eph::IRNSS) {
[10577]915 out
916 << QString(fmt)
917 .arg(tot, 19, 'e', 12)
918 .arg("", 19, QChar(' '))
919 .arg("", 19, QChar(' '))
920 .arg("", 19, QChar(' '));
[9786]921 }
922 else {
[10587]923 if (_flags_unknown) {
924 out
925 << QString(fmt)
926 .arg(tot, 19, 'e', 12)
927 .arg("", 19, QChar(' '))
928 .arg("", 19, QChar(' '))
929 .arg("", 19, QChar(' '));
[9786]930 }
[10587]931 else {
932 // for GPS and QZSS in version 3.02 specified in hours
933 double fitIntervalRnx = _fitInterval;
934 // otherwise specified as flag
935 if (system() == t_eph::QZSS && version != 3.02) {
936 (_fitInterval == 2.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0;
937 }
938 out
939 << QString(fmt)
940 .arg(tot, 19, 'e', 12)
941 .arg(fitIntervalRnx, 19, 'e', 12)
942 .arg("", 19, QChar(' '))
943 .arg("", 19, QChar(' '));
944 }
[9786]945 }
[7922]946 }
[10587]947 else if (type() == t_eph::CNAV ||
948 type() == t_eph::CNV2) {
[10577]949 out
950 << QString(fmt)
951 .arg(_ISC_L1CA, 19, 'e', 12)
952 .arg(_ISC_L2C, 19, 'e', 12)
953 .arg(_ISC_L5I5, 19, 'e', 12)
954 .arg(_ISC_L5Q5, 19, 'e', 12);
[8800]955 }
[10587]956 else if (type() == t_eph::L1NV) {
[10577]957 if (_RSF) {
958 out
959 << QString(fmt)
960 .arg(_ISC_S, 19, 'e', 12)
961 .arg(_ISC_L1D, 19, 'e', 12)
962 .arg("", 19, QChar(' '))
963 .arg("", 19, QChar(' '));
964 }
965 else {
966 out
967 << QString(fmt)
968 .arg("", 19, QChar(' '))
969 .arg("", 19, QChar(' '))
970 .arg(_ISC_L1P, 19, 'e', 12)
971 .arg(_ISC_L1D, 19, 'e', 12);
972 }
973 }
[9786]974 // =====================
975 // BROADCAST ORBIT - 8
976 // =====================
[10587]977 if (type() == t_eph::CNAV) {
978 int intFlags = 0;
979 if (!_flags_unknown) {
980 // Bit 0:
981 if (_intSF) {intFlags |= (1 << 0);}
982 // Bit 1:
983 if (_L2Cphasing) {intFlags |= (1 << 1);}
984 // Bit 2:
985 if (_alert) {intFlags |= (1 << 2);}
[10577]986 out
987 << QString(fmt)
[10587]988 .arg(_TOT, 19, 'e', 12)
989 .arg(_wnop, 19, 'e', 12)
990 .arg(double(intFlags), 19, 'e', 12)
991 .arg("", 19, QChar(' '));
[10577]992 }
993 else {
994 out
995 << QString(fmt)
996 .arg(_TOT, 19, 'e', 12)
997 .arg(_wnop, 19, 'e', 12)
998 .arg("", 19, QChar(' '))
999 .arg("", 19, QChar(' '));
1000 }
[8800]1001 }
[10587]1002 else if (type() == t_eph::CNV2) {
[10577]1003 out
1004 << QString(fmt)
1005 .arg(_ISC_L1Cd, 19, 'e', 12)
1006 .arg(_ISC_L1Cp, 19, 'e', 12)
1007 .arg("", 19, QChar(' '))
1008 .arg("", 19, QChar(' '));
[9786]1009 }
[10587]1010 else if (type() == t_eph::L1NV) {
[10577]1011 out
1012 << QString(fmt)
1013 .arg(_TOT, 19, 'e', 12)
1014 .arg("", 19, QChar(' '))
1015 .arg("", 19, QChar(' '))
1016 .arg("", 19, QChar(' '));
1017 }
[9786]1018 // =====================
1019 // BROADCAST ORBIT - 9
1020 // =====================
[10587]1021 if (type() == t_eph::CNV2) {
1022 int intFlags = 0;
1023 if (!_flags_unknown) {
1024 // Bit 0:
1025 if (_intSF) {intFlags |= (1 << 0);}
1026 if (system() == t_eph::QZSS) {
1027 // Bit 1:
1028 if (_ephSF) {intFlags |= (1 << 1);}
1029 }
[10577]1030 out
1031 << QString(fmt)
[10587]1032 .arg(_TOT, 19, 'e', 12)
1033 .arg(_wnop, 19, 'e', 12)
1034 .arg(double(intFlags), 19, 'e', 12)
1035 .arg("", 19, QChar(' '));
[10577]1036 }
1037 else {
1038 out
1039 << QString(fmt)
1040 .arg(_TOT, 19, 'e', 12)
1041 .arg(_wnop, 19, 'e', 12)
1042 .arg("", 19, QChar(' '))
1043 .arg("", 19, QChar(' '));
1044 }
[9786]1045 }
[6801]1046 return rnxStr;
[2221]1047}
1048
[6801]1049// Constructor
1050//////////////////////////////////////////////////////////////////////////////
[10603]1051t_ephGlo::t_ephGlo(double rnxVersion, const QStringList &lines, const QString typeStr) {
[2221]1052
[10603]1053 setType(typeStr);
1054
[9367]1055 int nLines = 4;
[10587]1056
1057 // Source RINEX version < 4
1058 if (type() == t_eph::undefined) {
1059 _type = t_eph::FDMA;
1060 }
1061
[9367]1062 if (rnxVersion >= 3.05) {
1063 nLines += 1;
[10577]1064 } else {
[9367]1065 _M_delta_tau = 0.9999e9; // unknown
[10587]1066 _M_FT = 1.5e1; // unknown
[9367]1067 }
[6801]1068
1069 if (lines.size() != nLines) {
1070 _checkState = bad;
1071 return;
[6518]1072 }
1073
[6801]1074 // RINEX Format
1075 // ------------
1076 int fieldLen = 19;
[9367]1077 double statusflags = 0.0;
1078 double healthflags = 0.0;
[10587]1079 double sourceflags = 0.0;
1080 _tauC = 0.0;
1081 _tau1 = 0.0;
1082 _tau2 = 0.0;
1083 _additional_data_availability = 0.0;
[2221]1084
[6801]1085 int pos[4];
[10577]1086 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
[6801]1087 pos[1] = pos[0] + fieldLen;
1088 pos[2] = pos[1] + fieldLen;
1089 pos[3] = pos[2] + fieldLen;
[2221]1090
[6801]1091 // Read four lines
1092 // ---------------
1093 for (int iLine = 0; iLine < nLines; iLine++) {
1094 QString line = lines[iLine];
[2221]1095
[10577]1096 if (iLine == 0) {
[8204]1097 QTextStream in(line.left(pos[1]).toLatin1());
[6213]1098
[10577]1099 int year, month, day, hour, min;
[6801]1100 double sec;
[2221]1101
[7139]1102 QString prnStr, n;
[6880]1103 in >> prnStr;
[7639]1104 if (prnStr.size() == 1 && prnStr[0] == 'R') {
[7139]1105 in >> n;
1106 prnStr.append(n);
[6880]1107 }
[10599]1108
[6801]1109 if (prnStr.at(0) == 'R') {
1110 _prn.set('R', prnStr.mid(1).toInt());
[10577]1111 } else {
[6801]1112 _prn.set('R', prnStr.toInt());
1113 }
[2221]1114
[10599]1115 in >> year >> month >> day >> hour >> min >> sec;
[10577]1116 if (year < 80) {
[6801]1117 year += 2000;
[10577]1118 } else if (year < 100) {
[6801]1119 year += 1900;
1120 }
[2221]1121
[6801]1122 _gps_utc = gnumleap(year, month, day);
[2221]1123
[6801]1124 _TOC.set(year, month, day, hour, min, sec);
[10577]1125 _TOC = _TOC + _gps_utc;
1126 int nd = int((_TOC.gpssec())) / (24.0 * 60.0 * 60.0);
[10587]1127 if ( readDbl(line, pos[1], fieldLen, _tau)
[10577]1128 || readDbl(line, pos[2], fieldLen, _gamma)
1129 || readDbl(line, pos[3], fieldLen, _tki)) {
[6801]1130 _checkState = bad;
1131 return;
1132 }
[8800]1133 _tki -= nd * 86400.0;
[10577]1134 _tau = -_tau;
[6801]1135 }
[9788]1136 // =====================
1137 // BROADCAST ORBIT - 1
1138 // =====================
[10577]1139 else if (iLine == 1) {
[10587]1140 if ( readDbl(line, pos[0], fieldLen, _x_pos)
1141 || readDbl(line, pos[1], fieldLen, _x_vel)
1142 || readDbl(line, pos[2], fieldLen, _x_acc)
[10577]1143 || readDbl(line, pos[3], fieldLen, _health)) {
[6801]1144 _checkState = bad;
1145 return;
1146 }
1147 }
[9788]1148 // =====================
1149 // BROADCAST ORBIT - 2
1150 // =====================
[10577]1151 else if (iLine == 2) {
[10599]1152 if (type() == t_eph::FDMA) {
[10587]1153 if ( readDbl(line, pos[0], fieldLen, _y_pos)
1154 || readDbl(line, pos[1], fieldLen, _y_vel)
1155 || readDbl(line, pos[2], fieldLen, _y_acc)
1156 || readDbl(line, pos[3], fieldLen, _frq_num)) {
1157 _checkState = bad;
1158 return;
1159 }
[6801]1160 }
[10587]1161 else { //L1OC, L3OC
1162 if ( readDbl(line, pos[0], fieldLen, _y_pos)
1163 || readDbl(line, pos[1], fieldLen, _y_vel)
1164 || readDbl(line, pos[2], fieldLen, _y_acc)
1165 || readDbl(line, pos[3], fieldLen, statusflags)) {
1166 _checkState = bad;
1167 return;
1168 }
1169 _data_validity = int(statusflags);
1170 }
[6801]1171 }
[9788]1172 // =====================
1173 // BROADCAST ORBIT - 3
1174 // =====================
[10577]1175 else if (iLine == 3) {
[10599]1176 if (type() == t_eph::FDMA) {
[10587]1177 if ( readDbl(line, pos[0], fieldLen, _z_pos)
1178 || readDbl(line, pos[1], fieldLen, _z_vel)
1179 || readDbl(line, pos[2], fieldLen, _z_acc)
1180 || readDbl(line, pos[3], fieldLen, _E)) {
1181 _checkState = bad;
1182 return;
1183 }
[6801]1184 }
[10587]1185 else if (type() == t_eph::L1OC) {
1186 if ( readDbl(line, pos[0], fieldLen, _z_pos)
1187 || readDbl(line, pos[1], fieldLen, _z_vel)
1188 || readDbl(line, pos[2], fieldLen, _z_acc)
1189 || readDbl(line, pos[3], fieldLen, _TGD_L2OCp)) {
1190 _checkState = bad;
1191 return;
1192 }
1193 }
1194 else if (type() == t_eph::L3OC) {
1195 if ( readDbl(line, pos[0], fieldLen, _z_pos)
1196 || readDbl(line, pos[1], fieldLen, _z_vel)
1197 || readDbl(line, pos[2], fieldLen, _z_acc)
1198 || readDbl(line, pos[3], fieldLen, _TGD_L3OCp)) {
1199 _checkState = bad;
1200 return;
1201 }
1202 }
[6801]1203 }
[9788]1204 // =====================
1205 // BROADCAST ORBIT - 4
1206 // =====================
[10577]1207 else if (iLine == 4) {
[10599]1208 if (type() == t_eph::FDMA) {
[10587]1209 if (readDbl(line, pos[0], fieldLen, statusflags)) {
1210 //status flags BLK, do nothing
1211 _statusflags_unknown = true;
1212 } else {
1213 _statusflags_unknown = false;
1214 // status flags
1215 // ============
1216 // bit 0-1
1217 _M_P = double(bitExtracted(int(statusflags), 2, 0));
1218 // bit 2-3
1219 _P1 = double(bitExtracted(int(statusflags), 2, 2));
1220 // bit 4
1221 _P2 = double(bitExtracted(int(statusflags), 1, 4));
1222 // bit 5
1223 _P3 = double(bitExtracted(int(statusflags), 1, 5));
1224 // bit 6
1225 _M_P4 = double(bitExtracted(int(statusflags), 1, 6));
1226 // bit 7-8
1227 _M_M = double(bitExtracted(int(statusflags), 2, 7));
1228 /// GLO M/K exclusive flags/values only valid if flag M is set to '01'
1229 if (!_M_M) {
1230 _M_P = 0.0;
1231 _M_l3 = 0.0;
1232 _M_P4 = 0.0;
1233 _M_FE = 0.0;
1234 _M_FT = 0.0;
1235 _M_NA = 0.0;
1236 _M_NT = 0.0;
1237 _M_N4 = 0.0;
1238 _M_l5 = 0.0;
1239 _M_tau_GPS = 0.0;
1240 _M_delta_tau = 0.0;
1241 }
[10599]1242 else {
1243 _type = t_eph::FDMA_M;
1244 }
[10587]1245 }
1246 if ( readDbl(line, pos[1], fieldLen, _M_delta_tau)
1247 || readDbl(line, pos[2], fieldLen, _M_FT)) {
1248 _checkState = bad;
1249 return;
1250 }
1251 if (readDbl(line, pos[3], fieldLen, healthflags)) {
1252 // health flags BLK
1253 _healthflags_unknown = true;
1254 } else {
1255 _healthflags_unknown = false;
1256 // health flags
1257 // ============
1258 // bit 0 (is to be ignored, if bit 1 is zero)
1259 _almanac_health = double(bitExtracted(int(healthflags), 1, 0));
1260 // bit 1
1261 _almanac_health_availablility_indicator =
1262 double(bitExtracted(int(healthflags), 1, 1));
1263 // bit 2; GLO-M/K only, health bit of string 3
1264 _M_l3 = double(bitExtracted(int(healthflags), 1, 2));
1265 }
1266 }
1267 else if (type() == t_eph::L1OC ||
1268 type() == t_eph::L3OC) {
1269 if ( readDbl(line, pos[0], fieldLen, _sat_type)
1270 || readDbl(line, pos[1], fieldLen, sourceflags)
1271 || readDbl(line, pos[2], fieldLen, _EE)
1272 || readDbl(line, pos[3], fieldLen, _ET)) {
1273 _checkState = bad;
1274 return;
1275 }
1276 // sourceflags:
[9367]1277 // ============
1278 // bit 0-1
[10587]1279 _RT = double(bitExtracted(int(sourceflags), 2, 0));
1280 // bit 2-3:
1281 _RE = double(bitExtracted(int(sourceflags), 2, 2));
1282 }
1283 }
1284 // =====================
1285 // BROADCAST ORBIT - 5
1286 // =====================
1287 else if (iLine == 5) {
1288 if (type() == t_eph::L1OC ||
1289 type() == t_eph::L3OC) {
1290 if ( readDbl(line, pos[0], fieldLen, _attitude_P2)
1291 || readDbl(line, pos[1], fieldLen, _Tin)
1292 || readDbl(line, pos[2], fieldLen, _tau1)
1293 || readDbl(line, pos[3], fieldLen, _tau2)) {
1294 _checkState = bad;
1295 return;
[9367]1296 }
[9892]1297 }
[10587]1298 }
1299 // =====================
1300 // BROADCAST ORBIT - 6
1301 // =====================
1302 else if (iLine == 6) {
1303 if (type() == t_eph::L1OC ||
1304 type() == t_eph::L3OC) {
1305 if ( readDbl(line, pos[0], fieldLen, _yaw)
1306 || readDbl(line, pos[1], fieldLen, _sn)
1307 || readDbl(line, pos[2], fieldLen, _angular_rate)
1308 || readDbl(line, pos[3], fieldLen, _angular_acc)) {
1309 _checkState = bad;
1310 return;
1311 }
[9892]1312 }
[10587]1313 }
1314 // =====================
1315 // BROADCAST ORBIT - 7
1316 // =====================
1317 else if (iLine == 7) {
1318 if (type() == t_eph::L1OC ||
1319 type() == t_eph::L3OC) {
1320 if ( readDbl(line, pos[0], fieldLen, _angular_rate_max)
1321 || readDbl(line, pos[1], fieldLen, _X_PC)
1322 || readDbl(line, pos[2], fieldLen, _Y_PC)
1323 || readDbl(line, pos[3], fieldLen, _Z_PC)) {
1324 _checkState = bad;
1325 return;
1326 }
[9367]1327 }
1328 }
[10587]1329 // =====================
1330 // BROADCAST ORBIT - 8
1331 // =====================
1332 else if (iLine == 8) {
1333 if (type() == t_eph::L1OC ||
1334 type() == t_eph::L3OC) {
1335 if ( readDbl(line, pos[0], fieldLen, _M_FE)
1336 || readDbl(line, pos[1], fieldLen, _M_FT)
1337 || readDbl(line, pos[3], fieldLen, _TOT)) {
1338 _checkState = bad;
1339 return;
1340 }
1341 }
1342 }
[6801]1343 }
1344
[10599]1345 _prn.setFlag(type());
1346
[6801]1347 // Initialize status vector
1348 // ------------------------
1349 _tt = _TOC;
[10577]1350 _xv.ReSize(6);
1351 _xv = 0.0;
[6801]1352 _xv(1) = _x_pos * 1.e3;
1353 _xv(2) = _y_pos * 1.e3;
1354 _xv(3) = _z_pos * 1.e3;
[10587]1355 _xv(4) = _x_vel * 1.e3;
1356 _xv(5) = _y_vel * 1.e3;
1357 _xv(6) = _z_vel * 1.e3;
[2221]1358}
1359
[6801]1360// Compute Glonass Satellite Position (virtual)
[2771]1361////////////////////////////////////////////////////////////////////////////
[10577]1362t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double *xc,
1363 double *vv) const {
[2771]1364
[6801]1365 static const double nominalStep = 10.0;
[2771]1366
[10577]1367 memset(xc, 0, 6 * sizeof(double));
1368 memset(vv, 0, 3 * sizeof(double));
[2771]1369
[6801]1370 double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
1371
[8698]1372 if (fabs(dtPos) > 24 * 3600.0) {
[6213]1373 return failure;
[2771]1374 }
1375
[10577]1376 int nSteps = int(fabs(dtPos) / nominalStep) + 1;
[6801]1377 double step = dtPos / nSteps;
[4018]1378
[6801]1379 double acc[3];
[10587]1380 acc[0] = _x_acc * 1.e3;
1381 acc[1] = _y_acc * 1.e3;
1382 acc[2] = _z_acc * 1.e3;
[9132]1383
[6801]1384 for (int ii = 1; ii <= nSteps; ii++) {
1385 _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
1386 _tt = _tt + step;
1387 }
[4018]1388
[6801]1389 // Position and Velocity
1390 // ---------------------
1391 xc[0] = _xv(1);
1392 xc[1] = _xv(2);
1393 xc[2] = _xv(3);
[2771]1394
[6801]1395 vv[0] = _xv(4);
1396 vv[1] = _xv(5);
1397 vv[2] = _xv(6);
[2771]1398
[6801]1399 // Clock Correction
1400 // ----------------
1401 double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
1402 xc[3] = -_tau + _gamma * dtClk;
[2771]1403
[8542]1404 xc[4] = _gamma;
1405 xc[5] = 0.0;
[8483]1406
[6213]1407 return success;
[2771]1408}
1409
[6801]1410// RINEX Format String
[3659]1411//////////////////////////////////////////////////////////////////////////////
[6801]1412QString t_ephGlo::toString(double version) const {
[3664]1413
[10587]1414 if (version < 4.0 &&
1415 (type() == t_eph::L1OC ||
1416 type() == t_eph::L3OC )) {
1417 return "";
1418 }
1419
1420 QString ephStr = typeStr(_type, _prn, version);
[10577]1421 QString rnxStr = ephStr + rinexDateStr(_TOC - _gps_utc, _prn, version);
1422 int nd = int((_TOC - _gps_utc).gpssec()) / (24.0 * 60.0 * 60.0);
[6801]1423 QTextStream out(&rnxStr);
[3664]1424
[10577]1425 out
[10587]1426 << QString("%1%2%3\n")
1427 .arg(-_tau, 19, 'e', 12)
1428 .arg(_gamma, 19, 'e', 12)
1429 .arg(_tki + nd * 86400.0, 19, 'e', 12);
[3668]1430
[6801]1431 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
[9788]1432 // =====================
1433 // BROADCAST ORBIT - 1
1434 // =====================
[10577]1435 out
[10587]1436 << QString(fmt)
1437 .arg(_x_pos, 19, 'e', 12)
1438 .arg(_x_vel, 19, 'e', 12)
1439 .arg(_x_acc, 19, 'e', 12)
1440 .arg(_health, 19, 'e', 12);
1441
[9788]1442 // =====================
1443 // BROADCAST ORBIT - 2
1444 // =====================
[10599]1445 if (type() == t_eph::FDMA ||
1446 type() == t_eph::FDMA_M) {
[10587]1447 out
1448 << QString(fmt)
1449 .arg(_y_pos, 19, 'e', 12)
1450 .arg(_y_vel, 19, 'e', 12)
1451 .arg(_y_acc, 19, 'e', 12)
1452 .arg(_frq_num, 19, 'e', 12);
1453 }
1454 else { //L1OC, L3OC
1455 out
1456 << QString(fmt)
1457 .arg(_y_pos, 19, 'e', 12)
1458 .arg(_y_vel, 19, 'e', 12)
1459 .arg(_y_acc, 19, 'e', 12)
1460 .arg(double(_data_validity), 19, 'e', 12);
1461 }
[9788]1462 // =====================
1463 // BROADCAST ORBIT - 3
1464 // =====================
[10599]1465 if (type() == t_eph::FDMA ||
1466 type() == t_eph::FDMA_M) {
[10587]1467 out
1468 << QString(fmt)
1469 .arg(_z_pos, 19, 'e', 12)
1470 .arg(_z_vel, 19, 'e', 12)
1471 .arg(_z_acc, 19, 'e', 12)
1472 .arg(_E, 19, 'e', 12);
1473 }
1474 else if (type() == t_eph::L1OC) {
1475 out
1476 << QString(fmt)
1477 .arg(_z_pos, 19, 'e', 12)
1478 .arg(_z_vel, 19, 'e', 12)
1479 .arg(_z_acc, 19, 'e', 12)
1480 .arg(_TGD_L2OCp, 19, 'e', 12);
1481 }
1482 else if (type() == t_eph::L3OC) {
1483 out
1484 << QString(fmt)
1485 .arg(_z_pos, 19, 'e', 12)
1486 .arg(_z_vel, 19, 'e', 12)
1487 .arg(_z_acc, 19, 'e', 12)
1488 .arg(_TGD_L3OCp, 19, 'e', 12);
1489 }
[9367]1490 if (version >= 3.05) {
[10587]1491 // =====================
1492 // BROADCAST ORBIT - 4
1493 // =====================
[10599]1494 if (type() == t_eph::FDMA ||
1495 type() == t_eph::FDMA_M){
[9367]1496 int statusflags = 0;
[10587]1497 int healthflags = 0;
1498 if (!_statusflags_unknown ) {
1499 // bit 0-1
1500 if (_M_P == 1.0) {statusflags |= (1 << 0);}
1501 else if (_M_P == 2.0) {statusflags |= (1 << 1);}
1502 else if (_M_P == 3.0) {statusflags |= (1 << 0); statusflags |= (1 << 1);}
1503 // bit 2-3
1504 if (_P1 == 1.0) {statusflags |= (1 << 2);}
1505 else if (_P1 == 2.0) {statusflags |= (1 << 3);}
1506 else if (_P1 == 3.0) {statusflags |= (1 << 2); statusflags |= (1 << 3);}
1507 // bit 4
1508 if (_P2) {statusflags |= (1 << 4);}
1509 // bit 5
1510 if (_P3) {statusflags |= (1 << 5);}
1511 // bit 6
1512 if (_M_P4) {statusflags |= (1 << 6);}
1513 // bit 7-8
1514 if (_M_M == 1.0) {statusflags |= (1 << 7);}
[9367]1515 }
[10587]1516 if (!_healthflags_unknown) {
1517 // bit 0 (is to be ignored, if bit 1 is zero)
1518 if (_almanac_health) {healthflags |= (1 << 0);}
1519 // bit 1
1520 if (_almanac_health_availablility_indicator) {healthflags |= (1 << 1);}
1521 // bit 2
1522 if (_M_l3) {healthflags |= (1 << 2);}
[9367]1523 }
[10587]1524
1525 if (_statusflags_unknown && _healthflags_unknown) {
1526 out
1527 << QString(fmt)
1528 .arg("", 19, QChar(' ')) // status-flags BNK (unknown)
1529 .arg(_M_delta_tau, 19, 'e', 12)
1530 .arg(_M_FT, 19, 'e', 12)
1531 .arg("", 19, QChar(' '));// health-flags BNK (unknown)
[9367]1532 }
[10587]1533 else if (!_statusflags_unknown && _healthflags_unknown) {
1534 out
1535 << QString(fmt)
1536 .arg(double(statusflags), 19, 'e', 12)
1537 .arg(_M_delta_tau, 19, 'e', 12)
1538 .arg(_M_FT, 19, 'e', 12)
1539 .arg("", 19, QChar(' '));// health-flags BNK (unknown)
[9367]1540 }
[10587]1541 else if (_statusflags_unknown && !_healthflags_unknown) {
1542 out
1543 << QString(fmt)
1544 .arg("", 19, QChar(' ')) // status-flags BNK (unknown)
1545 .arg(_M_delta_tau, 19, 'e', 12)
1546 .arg(_M_FT, 19, 'e', 12)
1547 .arg(double(healthflags), 19, 'e', 12);
[9367]1548 }
[10587]1549 else if (!_statusflags_unknown && !_healthflags_unknown) {
1550 out
1551 << QString(fmt)
1552 .arg(double(statusflags), 19, 'e', 12)
1553 .arg(_M_delta_tau, 19, 'e', 12)
1554 .arg(_M_FT, 19, 'e', 12)
1555 .arg(double(healthflags), 19, 'e', 12);
1556 }
1557 }
1558 else if (type() == t_eph::L1OC ||
1559 type() == t_eph::L3OC) {
1560 int sourceflags = 0;
[9367]1561 // bit 0-1
[10587]1562 if (_RT == 1.0) {sourceflags |= (1 << 0);}
1563 else if (_RT == 2.0) {sourceflags |= (1 << 1);}
1564 else if (_RT == 3.0) {sourceflags |= (1 << 0); sourceflags |= (1 << 1);}
1565 // bit 2-3
1566 if (_RE == 1.0) {sourceflags |= (1 << 2);}
1567 else if (_RE == 2.0) {sourceflags |= (1 << 3);}
1568 else if (_RE == 3.0) {sourceflags |= (1 << 2); sourceflags |= (1 << 3);}
[10577]1569 out
[10587]1570 << QString(fmt)
1571 .arg(_sat_type , 19, 'e', 12)
1572 .arg(double(sourceflags), 19, 'e', 12)
1573 .arg(_ET, 19, 'e', 12)
1574 .arg(_EE, 19, 'e', 12);
[9367]1575 }
[10587]1576 // =====================
1577 // BROADCAST ORBIT - 5
1578 // =====================
1579 if (type() == t_eph::L1OC ||
1580 type() == t_eph::L3OC) {
1581 out
1582 << QString(fmt)
1583 .arg(_attitude_P2, 19, 'e', 12)
1584 .arg(_Tin, 19, 'e', 12)
1585 .arg(_tau1, 19, 'e', 12)
1586 .arg(_tau2, 19, 'e', 12);
1587 }
1588 // =====================
1589 // BROADCAST ORBIT - 6
1590 // =====================
1591 if (type() == t_eph::L1OC ||
1592 type() == t_eph::L3OC) {
1593 out
1594 << QString(fmt)
1595 .arg(_yaw, 19, 'e', 12)
1596 .arg(_sn, 19, 'e', 12)
1597 .arg(_angular_rate, 19, 'e', 12)
1598 .arg(_angular_acc, 19, 'e', 12);
1599 }
1600 // =====================
1601 // BROADCAST ORBIT - 7
1602 // =====================
1603 if (type() == t_eph::L1OC ||
1604 type() == t_eph::L3OC) {
1605 out
1606 << QString(fmt)
1607 .arg(_angular_rate_max, 19, 'e', 12)
1608 .arg(_X_PC, 19, 'e', 12)
1609 .arg(_Y_PC, 19, 'e', 12)
1610 .arg(_Z_PC, 19, 'e', 12);
1611 }
1612 // =====================
1613 // BROADCAST ORBIT - 8
1614 // =====================
1615 if (type() == t_eph::L1OC ||
1616 type() == t_eph::L3OC) {
1617 out
1618 << QString(fmt)
1619 .arg(_M_FE, 19, 'e', 12)
1620 .arg(_M_FT, 19, 'e', 12)
1621 .arg("", 19, QChar(' '))
1622 .arg(_TOT, 19, 'e', 12);
1623 }
[9367]1624 }
[6801]1625 return rnxStr;
[3659]1626}
1627
[6801]1628// Derivative of the state vector using a simple force model (static)
1629////////////////////////////////////////////////////////////////////////////
[10577]1630ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector &xv,
1631 double *acc) {
[3659]1632
[6801]1633 // State vector components
1634 // -----------------------
[10577]1635 ColumnVector rr = xv.rows(1, 3);
1636 ColumnVector vv = xv.rows(4, 6);
[3699]1637
[6801]1638 // Acceleration
[3699]1639 // ------------
[6801]1640 static const double gmWGS = 398.60044e12;
[10577]1641 static const double AE = 6378136.0;
[6801]1642 static const double OMEGA = 7292115.e-11;
[10577]1643 static const double C20 = -1082.6257e-6;
[3699]1644
[8903]1645 double rho = rr.NormFrobenius();
[10577]1646 double t1 = -gmWGS / (rho * rho * rho);
1647 double t2 = 3.0 / 2.0 * C20 * (gmWGS * AE * AE)
1648 / (rho * rho * rho * rho * rho);
1649 double t3 = OMEGA * OMEGA;
1650 double t4 = 2.0 * OMEGA;
1651 double z2 = rr(3) * rr(3);
[3699]1652
[6801]1653 // Vector of derivatives
1654 // ---------------------
1655 ColumnVector va(6);
1656 va(1) = vv(1);
1657 va(2) = vv(2);
1658 va(3) = vv(3);
[10577]1659 va(4) = (t1 + t2 * (1.0 - 5.0 * z2 / (rho * rho)) + t3) * rr(1) + t4 * vv(2)
1660 + acc[0];
1661 va(5) = (t1 + t2 * (1.0 - 5.0 * z2 / (rho * rho)) + t3) * rr(2) - t4 * vv(1)
1662 + acc[1];
1663 va(6) = (t1 + t2 * (3.0 - 5.0 * z2 / (rho * rho))) * rr(3) + acc[2];
[3699]1664
[6801]1665 return va;
1666}
[3699]1667
[6801]1668// IOD of Glonass Ephemeris (virtual)
1669////////////////////////////////////////////////////////////////////////////
[7169]1670unsigned int t_ephGlo::IOD() const {
[6801]1671 bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
[10577]1672 return (unsigned long) tMoscow.daysec() / 900;
[3659]1673}
1674
[8187]1675// Health status of Glonass Ephemeris (virtual)
1676////////////////////////////////////////////////////////////////////////////
1677unsigned int t_ephGlo::isUnhealthy() const {
[8215]1678
[8217]1679 if (_almanac_health_availablility_indicator) {
[10577]1680 if ((_health == 0 && _almanac_health == 0)
1681 || (_health == 1 && _almanac_health == 0)
1682 || (_health == 1 && _almanac_health == 1)) {
1683 return 1;
1684 }
1685 } else if (!_almanac_health_availablility_indicator) {
[8217]1686 if (_health) {
1687 return 1;
1688 }
1689 }
[8215]1690 return 0; /* (_health == 0 && _almanac_health == 1) or (_health == 0) */
[8187]1691}
1692
[3659]1693// Constructor
1694//////////////////////////////////////////////////////////////////////////////
[10603]1695t_ephGal::t_ephGal(double rnxVersion, const QStringList &lines, const QString typeStr) {
[10599]1696
[10603]1697 setType(typeStr);
1698
[4891]1699 const int nLines = 8;
[10599]1700
[4891]1701 if (lines.size() != nLines) {
[6518]1702 _checkState = bad;
[4891]1703 return;
1704 }
1705
1706 // RINEX Format
1707 // ------------
1708 int fieldLen = 19;
[6792]1709 double SVhealth = 0.0;
1710 double datasource = 0.0;
[6798]1711
[4891]1712 int pos[4];
[10577]1713 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
[4891]1714 pos[1] = pos[0] + fieldLen;
1715 pos[2] = pos[1] + fieldLen;
1716 pos[3] = pos[2] + fieldLen;
1717
1718 // Read eight lines
1719 // ----------------
1720 for (int iLine = 0; iLine < nLines; iLine++) {
1721 QString line = lines[iLine];
1722
[10577]1723 if (iLine == 0) {
[8204]1724 QTextStream in(line.left(pos[1]).toLatin1());
[10599]1725
1726 int year, month, day, hour, min;
1727 double sec;
1728
1729 QString prnStr, n;
[6880]1730 in >> prnStr;
[7639]1731 if (prnStr.size() == 1 && prnStr[0] == 'E') {
[7139]1732 in >> n;
1733 prnStr.append(n);
[6880]1734 }
[10599]1735 if (prnStr.at(0) == 'E') {
1736 _prn.set('E', prnStr.mid(1).toInt());
1737 } else {
1738 _prn.set('E', prnStr.toInt());
1739 }
1740
[6880]1741 in >> year >> month >> day >> hour >> min >> sec;
[10577]1742 if (year < 80) {
[4891]1743 year += 2000;
[10577]1744 } else if (year < 100) {
[4891]1745 year += 1900;
1746 }
1747
1748 _TOC.set(year, month, day, hour, min, sec);
1749
[10587]1750 if ( readDbl(line, pos[1], fieldLen, _clock_bias)
[10577]1751 || readDbl(line, pos[2], fieldLen, _clock_drift)
1752 || readDbl(line, pos[3], fieldLen, _clock_driftrate)) {
[6518]1753 _checkState = bad;
[4891]1754 return;
1755 }
1756 }
[9788]1757 // =====================
1758 // BROADCAST ORBIT - 1
1759 // =====================
[10577]1760 else if (iLine == 1) {
[10587]1761 if ( readDbl(line, pos[0], fieldLen, _IODnav)
[10577]1762 || readDbl(line, pos[1], fieldLen, _Crs)
1763 || readDbl(line, pos[2], fieldLen, _Delta_n)
1764 || readDbl(line, pos[3], fieldLen, _M0)) {
[6518]1765 _checkState = bad;
[4891]1766 return;
1767 }
1768 }
[9788]1769 // =====================
1770 // BROADCAST ORBIT - 2
1771 // =====================
[10577]1772 else if (iLine == 2) {
[10587]1773 if ( readDbl(line, pos[0], fieldLen, _Cuc)
[10577]1774 || readDbl(line, pos[1], fieldLen, _e)
1775 || readDbl(line, pos[2], fieldLen, _Cus)
1776 || readDbl(line, pos[3], fieldLen, _sqrt_A)) {
[6518]1777 _checkState = bad;
[4891]1778 return;
1779 }
1780 }
[9788]1781 // =====================
1782 // BROADCAST ORBIT - 3
1783 // =====================
[10577]1784 else if (iLine == 3) {
[10587]1785 if ( readDbl(line, pos[0], fieldLen, _TOEsec)
[10577]1786 || readDbl(line, pos[1], fieldLen, _Cic)
1787 || readDbl(line, pos[2], fieldLen, _OMEGA0)
1788 || readDbl(line, pos[3], fieldLen, _Cis)) {
[6518]1789 _checkState = bad;
[4891]1790 return;
1791 }
1792 }
[9788]1793 // =====================
1794 // BROADCAST ORBIT - 4
1795 // =====================
[10577]1796 else if (iLine == 4) {
[10587]1797 if ( readDbl(line, pos[0], fieldLen, _i0)
[10577]1798 || readDbl(line, pos[1], fieldLen, _Crc)
1799 || readDbl(line, pos[2], fieldLen, _omega)
1800 || readDbl(line, pos[3], fieldLen, _OMEGADOT)) {
[6518]1801 _checkState = bad;
[4891]1802 return;
1803 }
1804 }
[9788]1805 // =====================
1806 // BROADCAST ORBIT - 5
1807 // =====================
[10577]1808 else if (iLine == 5) {
[10587]1809 if ( readDbl(line, pos[0], fieldLen, _IDOT)
[10577]1810 || readDbl(line, pos[1], fieldLen, datasource)
1811 || readDbl(line, pos[2], fieldLen, _TOEweek)) {
[6518]1812 _checkState = bad;
[4891]1813 return;
[10587]1814 }
1815 else {
[10599]1816 if (bitExtracted(unsigned(datasource), 1, 8)) {
[6812]1817 _fnav = true;
[10599]1818 _type = t_eph::FNAV;
[6812]1819 _inav = false;
[10587]1820 /* set unused I/NAV values */
1821 _E5b_HS = 0.0;
1822 _E1B_HS = 0.0;
1823 _E1B_DataInvalid = false;
1824 _E5b_DataInvalid = false;
1825 }
[10599]1826 if (bitExtracted(unsigned(datasource), 1, 9)) {
[6812]1827 _fnav = false;
1828 _inav = true;
[10599]1829 _type = t_eph::INAV;
[10587]1830 /* set unused F/NAV values */
1831 _E5a_HS = 0.0;
1832 _E5a_DataInvalid = false;
[6792]1833 }
[10587]1834 // GAL week # in RINEX is aligned/identical to continuous GPS week # used in RINEX
1835 // but GST week # started at the first GPS roll-over (continuous GPS week 1024)
[6892]1836 _TOEweek -= 1024.0;
[4891]1837 }
1838 }
[9788]1839 // =====================
1840 // BROADCAST ORBIT - 6
1841 // =====================
[10577]1842 else if (iLine == 6) {
[10587]1843 if ( readDbl(line, pos[0], fieldLen, _SISA)
[10577]1844 || readDbl(line, pos[1], fieldLen, SVhealth)
1845 || readDbl(line, pos[2], fieldLen, _BGD_1_5A)
1846 || readDbl(line, pos[3], fieldLen, _BGD_1_5B)) {
[6518]1847 _checkState = bad;
[4891]1848 return;
[6792]1849 } else {
1850 // Bit 0
[10587]1851 _E1B_DataInvalid = bitExtracted(int(SVhealth), 1, 0);
[6792]1852 // Bit 1-2
[10587]1853 _E1B_HS = double(bitExtracted(int(SVhealth), 2, 1));
[6792]1854 // Bit 3
[10587]1855 _E5a_DataInvalid = bitExtracted(int(SVhealth), 1, 3);
[6792]1856 // Bit 4-5
[10587]1857 _E5a_HS = double(bitExtracted(int(SVhealth), 2, 4));
[6792]1858 // Bit 6
[10587]1859 _E5b_DataInvalid = bitExtracted(int(SVhealth), 1, 6);
[6792]1860 // Bit 7-8
[10587]1861 _E5b_HS = double(bitExtracted(int(SVhealth), 2, 7));
1862 if (_fnav) {
1863 _BGD_1_5B = 0.0;
1864 }
[4891]1865 }
1866 }
[9788]1867 // =====================
1868 // BROADCAST ORBIT - 7
1869 // =====================
[10577]1870 else if (iLine == 7) {
1871 if (readDbl(line, pos[0], fieldLen, _TOT)) {
[6518]1872 _checkState = bad;
[4891]1873 return;
1874 }
1875 }
1876 }
[10599]1877 _prn.setFlag(type());
[3659]1878}
[4013]1879
[6801]1880// Compute Galileo Satellite Position (virtual)
1881////////////////////////////////////////////////////////////////////////////
[10577]1882t_irc t_ephGal::position(int GPSweek, double GPSweeks, double *xc,
1883 double *vv) const {
[4013]1884
[6801]1885 static const double omegaEarth = 7292115.1467e-11;
[8212]1886 static const double gmWGS = 398.6004418e12;
[4023]1887
[10577]1888 memset(xc, 0, 6 * sizeof(double));
1889 memset(vv, 0, 3 * sizeof(double));
[4023]1890
[6801]1891 double a0 = _sqrt_A * _sqrt_A;
1892 if (a0 == 0) {
1893 return failure;
1894 }
[4023]1895
[10577]1896 double n0 = sqrt(gmWGS / (a0 * a0 * a0));
[4023]1897
[6801]1898 bncTime tt(GPSweek, GPSweeks);
1899 double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
[4023]1900
[10577]1901 double n = n0 + _Delta_n;
1902 double M = _M0 + n * tk;
1903 double E = M;
[6801]1904 double E_last;
[10577]1905 int nLoop = 0;
[6801]1906 do {
1907 E_last = E;
[10577]1908 E = M + _e * sin(E);
[8368]1909
1910 if (++nLoop == 100) {
1911 return failure;
1912 }
[10577]1913 } while (fabs(E - E_last) * a0 > 0.001);
1914 double v = 2.0 * atan(sqrt((1.0 + _e) / (1.0 - _e)) * tan(E / 2));
1915 double u0 = v + _omega;
1916 double sin2u0 = sin(2 * u0);
1917 double cos2u0 = cos(2 * u0);
1918 double r = a0 * (1 - _e * cos(E)) + _Crc * cos2u0 + _Crs * sin2u0;
1919 double i = _i0 + _IDOT * tk + _Cic * cos2u0 + _Cis * sin2u0;
1920 double u = u0 + _Cuc * cos2u0 + _Cus * sin2u0;
1921 double xp = r * cos(u);
1922 double yp = r * sin(u);
1923 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth) * tk - omegaEarth * _TOEsec;
[4023]1924
[6801]1925 double sinom = sin(OM);
1926 double cosom = cos(OM);
[10577]1927 double sini = sin(i);
1928 double cosi = cos(i);
1929 xc[0] = xp * cosom - yp * cosi * sinom;
1930 xc[1] = xp * sinom + yp * cosi * cosom;
1931 xc[2] = yp * sini;
[4023]1932
[6801]1933 double tc = tt - _TOC;
[10577]1934 xc[3] = _clock_bias + _clock_drift * tc + _clock_driftrate * tc * tc;
[4023]1935
[6801]1936 // Velocity
1937 // --------
[10577]1938 double tanv2 = tan(v / 2);
1939 double dEdM = 1 / (1 - _e * cos(E));
1940 double dotv = sqrt((1.0 + _e) / (1.0 - _e)) / cos(E / 2) / cos(E / 2)
1941 / (1 + tanv2 * tanv2) * dEdM * n;
1942 double dotu = dotv + (-_Cuc * sin2u0 + _Cus * cos2u0) * 2 * dotv;
[6801]1943 double dotom = _OMEGADOT - omegaEarth;
[10577]1944 double doti = _IDOT + (-_Cic * sin2u0 + _Cis * cos2u0) * 2 * dotv;
1945 double dotr = a0 * _e * sin(E) * dEdM * n
1946 + (-_Crc * sin2u0 + _Crs * cos2u0) * 2 * dotv;
1947 double dotx = dotr * cos(u) - r * sin(u) * dotu;
1948 double doty = dotr * sin(u) + r * cos(u) * dotu;
[4023]1949
[10577]1950 vv[0] = cosom * dotx - cosi * sinom * doty // dX / dr
1951 - xp * sinom * dotom - yp * cosi * cosom * dotom // dX / dOMEGA
1952 + yp * sini * sinom * doti; // dX / di
[6801]1953
[10577]1954 vv[1] = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom
1955 - yp * cosi * sinom * dotom - yp * sini * cosom * doti;
[6801]1956
[10577]1957 vv[2] = sini * doty + yp * cosi * doti;
[6801]1958
1959 // Relativistic Correction
1960 // -----------------------
[10577]1961 xc[3] -= 4.442807309e-10 * _e * sqrt(a0) * sin(E);
[6801]1962
[10577]1963 xc[4] = _clock_drift + _clock_driftrate * tc;
[8542]1964 xc[5] = _clock_driftrate;
[8581]1965
[6801]1966 return success;
[4023]1967}
1968
[8187]1969// Health status of Galileo Ephemeris (virtual)
1970////////////////////////////////////////////////////////////////////////////
1971unsigned int t_ephGal::isUnhealthy() const {
[10587]1972 // SHS; 1 = Out of Service, 3 = In Test, 0 = Signal Ok, 2 = Extended Operations Mode
1973 if (_E5a_HS == 1 || _E5a_HS == 3 ||
1974 _E5b_HS == 1 || _E5b_HS == 3 ||
1975 _E1B_HS == 1 || _E1B_HS == 3) {
[8187]1976 return 1;
1977 }
[10587]1978 if (_E5a_DataInvalid ||
1979 _E5b_DataInvalid ||
1980 _E1B_DataInvalid) {
[10562]1981 return 1;
1982 }
[10587]1983 if (_SISA == 255.0) { // NAPA: No Accuracy Prediction Available
[10315]1984 return 1;
1985 }
[10562]1986 /*
1987 * SDD v1.3: SHS=2 leads to a newly-defined "EOM" status.
1988 * It also means that the satellite signal may be used for PNT.
[10577]1989 if (_E5aHS == 2 ||
[10587]1990 _E5bHS == 2 ||
1991 _E1_bHS == 2 ) {
1992 return 1;
[10577]1993 }
1994 */
[8187]1995 return 0;
[10587]1996
[8187]1997}
1998
[4023]1999// RINEX Format String
2000//////////////////////////////////////////////////////////////////////////////
2001QString t_ephGal::toString(double version) const {
2002
[10587]2003 QString ephStr = typeStr(_type, _prn, version);
[10577]2004 QString rnxStr = ephStr + rinexDateStr(_TOC, _prn, version);
[4023]2005
2006 QTextStream out(&rnxStr);
2007
[10577]2008 out
2009 << QString("%1%2%3\n").arg(_clock_bias, 19, 'e', 12).arg(_clock_drift, 19,
2010 'e', 12).arg(_clock_driftrate, 19, 'e', 12);
[4023]2011
2012 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
[9788]2013 // =====================
2014 // BROADCAST ORBIT - 1
2015 // =====================
[10577]2016 out
[10587]2017 << QString(fmt)
2018 .arg(_IODnav, 19, 'e', 12)
2019 .arg(_Crs, 19, 'e', 12)
2020 .arg(_Delta_n, 19, 'e', 12)
2021 .arg(_M0, 19, 'e', 12);
[9788]2022 // =====================
2023 // BROADCAST ORBIT - 2
2024 // =====================
[10577]2025 out
[10587]2026 << QString(fmt)
2027 .arg(_Cuc, 19, 'e', 12).
2028 arg(_e, 19, 'e', 12)
2029 .arg(_Cus, 19, 'e', 12)
2030 .arg(_sqrt_A, 19, 'e', 12);
[9788]2031 // =====================
2032 // BROADCAST ORBIT - 3
2033 // =====================
[10577]2034 out
[10587]2035 << QString(fmt).
2036 arg(_TOEsec, 19, 'e', 12)
2037 .arg(_Cic, 19, 'e', 12)
2038 .arg(_OMEGA0, 19, 'e', 12)
2039 .arg(_Cis, 19, 'e', 12);
[9788]2040 // =====================
2041 // BROADCAST ORBIT - 4
2042 // =====================
[10577]2043 out
[10587]2044 << QString(fmt)
2045 .arg(_i0, 19, 'e', 12)
2046 .arg(_Crc, 19, 'e', 12)
2047 .arg(_omega, 19, 'e', 12)
2048 .arg(_OMEGADOT, 19, 'e', 12);
[9788]2049 // =====================
[10587]2050 // BROADCAST ORBIT - 5/6
[9788]2051 // =====================
[10577]2052 int dataSource = 0;
2053 int SVhealth = 0;
2054 double BGD_1_5A = _BGD_1_5A;
2055 double BGD_1_5B = _BGD_1_5B;
[6812]2056 if (_fnav) {
[10577]2057 dataSource |= (1 << 1);
2058 dataSource |= (1 << 8);
[6792]2059 BGD_1_5B = 0.0;
2060 // SVhealth
2061 // Bit 3 : E5a DVS
[10587]2062 if (_E5a_DataInvalid) {
[10577]2063 SVhealth |= (1 << 3);
[6792]2064 }
2065 // Bit 4-5: E5a HS
[10587]2066 if (_E5a_HS == 1.0) {
[10577]2067 SVhealth |= (1 << 4);
[10587]2068 }
2069 else if (_E5a_HS == 2.0) {
[10577]2070 SVhealth |= (1 << 5);
[10587]2071 }
2072 else if (_E5a_HS == 3.0) {
[10577]2073 SVhealth |= (1 << 4);
2074 SVhealth |= (1 << 5);
[6792]2075 }
[10577]2076 } else if (_inav) {
[6803]2077 // Bit 2 and 0 are set because from MT1046 the data source cannot be determined
2078 // and RNXv3.03 says both can be set if the navigation messages were merged
[10577]2079 dataSource |= (1 << 0);
2080 dataSource |= (1 << 2);
2081 dataSource |= (1 << 9);
[6792]2082 // SVhealth
2083 // Bit 0 : E1-B DVS
[10587]2084 if (_E1B_DataInvalid) {
[10577]2085 SVhealth |= (1 << 0);
[6792]2086 }
2087 // Bit 1-2: E1-B HS
[10587]2088 if (_E1B_HS == 1.0) {
[10577]2089 SVhealth |= (1 << 1);
[10587]2090 }
2091 else if (_E1B_HS == 2.0) {
[10577]2092 SVhealth |= (1 << 2);
[10587]2093 }
2094 else if (_E1B_HS == 3.0) {
[10577]2095 SVhealth |= (1 << 1);
2096 SVhealth |= (1 << 2);
[6792]2097 }
2098 // Bit 6 : E5b DVS
[10587]2099 if (_E5b_DataInvalid) {
[10577]2100 SVhealth |= (1 << 6);
[6792]2101 }
2102 // Bit 7-8: E5b HS
[10587]2103 if (_E5b_HS == 1.0) {
[10577]2104 SVhealth |= (1 << 7);
[10587]2105 }
2106 else if (_E5b_HS == 2.0) {
[10577]2107 SVhealth |= (1 << 8);
[10587]2108 }
2109 else if (_E5b_HS == 3.0) {
[10577]2110 SVhealth |= (1 << 7);
2111 SVhealth |= (1 << 8);
[6792]2112 }
[5539]2113 }
[10587]2114 // =====================
2115 // BROADCAST ORBIT - 5
2116 // =====================
[10577]2117 out
[10587]2118 << QString(fmt)
2119 .arg(_IDOT, 19, 'e', 12)
2120 .arg(double(dataSource), 19, 'e', 12)
2121 .arg(_TOEweek + 1024.0, 19, 'e', 12)
2122 .arg(0.0, 19, 'e', 12);
[9788]2123 // =====================
2124 // BROADCAST ORBIT - 6
2125 // =====================
[10577]2126 out
[10587]2127 << QString(fmt)
2128 .arg(_SISA, 19, 'e', 12)
2129 .arg(double(SVhealth), 19, 'e', 12)
2130 .arg(BGD_1_5A, 19, 'e', 12)
2131 .arg(BGD_1_5B, 19, 'e', 12);
[9788]2132 // =====================
2133 // BROADCAST ORBIT - 7
2134 // =====================
[7922]2135 double tot = _TOT;
2136 if (tot == 0.9999e9 && version < 3.0) {
2137 tot = 0.0;
2138 }
[10577]2139 out
[10587]2140 << QString(fmt)
2141 .arg(tot, 19, 'e', 12)
2142 .arg("", 19, QChar(' '))
2143 .arg("", 19, QChar(' '))
2144 .arg("", 19, QChar(' '));
[4023]2145
2146 return rnxStr;
2147}
2148
[6385]2149// Constructor
2150//////////////////////////////////////////////////////////////////////////////
[10603]2151t_ephSBAS::t_ephSBAS(double rnxVersion, const QStringList &lines, const QString typeStr) {
[6390]2152
[10603]2153 setType(typeStr);
2154
[6390]2155 const int nLines = 4;
2156
[10587]2157 // Source RINEX version < 4
2158 if (type() == t_eph::undefined) {
2159 _type = t_eph::SBASL1;
2160 }
2161
[6390]2162 if (lines.size() != nLines) {
[6518]2163 _checkState = bad;
[6390]2164 return;
2165 }
2166
2167 // RINEX Format
2168 // ------------
2169 int fieldLen = 19;
2170
2171 int pos[4];
[10577]2172 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
[6390]2173 pos[1] = pos[0] + fieldLen;
2174 pos[2] = pos[1] + fieldLen;
2175 pos[3] = pos[2] + fieldLen;
2176
2177 // Read four lines
2178 // ---------------
2179 for (int iLine = 0; iLine < nLines; iLine++) {
2180 QString line = lines[iLine];
2181
[10577]2182 if (iLine == 0) {
[8204]2183 QTextStream in(line.left(pos[1]).toLatin1());
[6390]2184
[10577]2185 int year, month, day, hour, min;
[6390]2186 double sec;
[6880]2187
[7139]2188 QString prnStr, n;
[6880]2189 in >> prnStr;
[7639]2190 if (prnStr.size() == 1 && prnStr[0] == 'S') {
[7139]2191 in >> n;
2192 prnStr.append(n);
[6880]2193 }
[6390]2194 if (prnStr.at(0) == 'S') {
2195 _prn.set('S', prnStr.mid(1).toInt());
[10577]2196 } else {
[6390]2197 _prn.set('S', prnStr.toInt());
2198 }
[10599]2199 _prn.setFlag(type());
[6390]2200
[10599]2201 in >> year >> month >> day >> hour >> min >> sec;
2202
[10577]2203 if (year < 80) {
[6390]2204 year += 2000;
[10577]2205 } else if (year < 100) {
[6390]2206 year += 1900;
2207 }
2208
2209 _TOC.set(year, month, day, hour, min, sec);
2210
[10587]2211 if ( readDbl(line, pos[1], fieldLen, _agf0)
[10577]2212 || readDbl(line, pos[2], fieldLen, _agf1)
2213 || readDbl(line, pos[3], fieldLen, _TOT)) {
[6518]2214 _checkState = bad;
[6390]2215 return;
2216 }
2217 }
[9788]2218 // =====================
2219 // BROADCAST ORBIT - 1
2220 // =====================
[10577]2221 else if (iLine == 1) {
[10587]2222 if ( readDbl(line, pos[0], fieldLen, _x_pos)
2223 || readDbl(line, pos[1], fieldLen, _x_vel)
2224 || readDbl(line, pos[2], fieldLen, _x_acc)
[10577]2225 || readDbl(line, pos[3], fieldLen, _health)) {
[6518]2226 _checkState = bad;
[6390]2227 return;
2228 }
2229 }
[9788]2230 // =====================
2231 // BROADCAST ORBIT - 2
2232 // =====================
[10577]2233 else if (iLine == 2) {
[10587]2234 if ( readDbl(line, pos[0], fieldLen, _y_pos)
2235 || readDbl(line, pos[1], fieldLen, _y_vel)
2236 || readDbl(line, pos[2], fieldLen, _y_acc)
[10577]2237 || readDbl(line, pos[3], fieldLen, _ura)) {
[6518]2238 _checkState = bad;
[6390]2239 return;
2240 }
2241 }
[9788]2242 // =====================
2243 // BROADCAST ORBIT - 3
2244 // =====================
[10577]2245 else if (iLine == 3) {
[6536]2246 double iodn;
[10587]2247 if ( readDbl(line, pos[0], fieldLen, _z_pos)
2248 || readDbl(line, pos[1], fieldLen, _z_vel)
2249 || readDbl(line, pos[2], fieldLen, _z_acc)
[10577]2250 || readDbl(line, pos[3], fieldLen, iodn)) {
[6518]2251 _checkState = bad;
[6390]2252 return;
[6891]2253 } else {
[6536]2254 _IODN = int(iodn);
[6390]2255 }
2256 }
2257 }
[10577]2258 _x_pos *= 1.e3;
2259 _y_pos *= 1.e3;
2260 _z_pos *= 1.e3;
[10587]2261 _x_vel *= 1.e3;
2262 _y_vel *= 1.e3;
2263 _z_vel *= 1.e3;
2264 _x_acc *= 1.e3;
2265 _y_acc *= 1.e3;
2266 _z_acc *= 1.e3;
[6385]2267}
2268
[7054]2269// IOD of SBAS Ephemeris (virtual)
2270////////////////////////////////////////////////////////////////////////////
2271
[7169]2272unsigned int t_ephSBAS::IOD() const {
[7054]2273 unsigned char buffer[80];
2274 int size = 0;
2275 int numbits = 0;
2276 long long bitbuffer = 0;
2277 unsigned char *startbuffer = buffer;
2278
2279 SBASADDBITSFLOAT(30, this->_x_pos, 0.08)
2280 SBASADDBITSFLOAT(30, this->_y_pos, 0.08)
2281 SBASADDBITSFLOAT(25, this->_z_pos, 0.4)
[10587]2282 SBASADDBITSFLOAT(17, this->_x_vel, 0.000625)
2283 SBASADDBITSFLOAT(17, this->_y_vel, 0.000625)
2284 SBASADDBITSFLOAT(18, this->_z_vel, 0.004)
2285 SBASADDBITSFLOAT(10, this->_x_acc, 0.0000125)
2286 SBASADDBITSFLOAT(10, this->_y_acc, 0.0000125)
2287 SBASADDBITSFLOAT(10, this->_z_acc, 0.0000625)
[10577]2288 SBASADDBITSFLOAT(12, this->_agf0,
2289 1.0 / static_cast<double>(1 << 30) / static_cast<double>(1 << 1))
2290 SBASADDBITSFLOAT(8, this->_agf1,
2291 1.0 / static_cast<double>(1 << 30) / static_cast<double>(1 << 10))
2292 SBASADDBITS(5, 0); // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
[7054]2293
2294 return CRC24(size, startbuffer);
2295}
2296
[6385]2297// Compute SBAS Satellite Position (virtual)
2298////////////////////////////////////////////////////////////////////////////
[10577]2299t_irc t_ephSBAS::position(int GPSweek, double GPSweeks, double *xc,
2300 double *vv) const {
[6386]2301
2302 bncTime tt(GPSweek, GPSweeks);
[10577]2303 double dt = tt - _TOC;
[6386]2304
[10587]2305 xc[0] = _x_pos + _x_vel * dt + _x_acc * dt * dt / 2.0;
2306 xc[1] = _y_pos + _y_vel * dt + _y_acc * dt * dt / 2.0;
2307 xc[2] = _z_pos + _z_vel * dt + _z_acc * dt * dt / 2.0;
[6386]2308
[10587]2309 vv[0] = _x_vel + _x_acc * dt;
2310 vv[1] = _y_vel + _y_acc * dt;
2311 vv[2] = _z_vel + _z_acc * dt;
[6386]2312
2313 xc[3] = _agf0 + _agf1 * dt;
2314
[8542]2315 xc[4] = _agf1;
2316 xc[5] = 0.0;
[8483]2317
[6386]2318 return success;
[6385]2319}
2320
[9774]2321// Health status of SBAS Ephemeris (virtual)
2322////////////////////////////////////////////////////////////////////////////
2323unsigned int t_ephSBAS::isUnhealthy() const {
2324
2325 // Bit 5
[10577]2326 bool URAindexIs15 = (int(_health) & (1 << 5));
[9774]2327 if (URAindexIs15) {
2328 // in this case it is recommended
2329 // to set the bits 0,1,2,3 to 1 (MT17health = 15)
2330 return 1;
2331 }
2332
2333 // Bit 0-3
[10577]2334 int MT17health = (int(_health)) & (0x0f);
[9774]2335 if (MT17health) {
2336 return 1;
2337 }
2338
2339 // Bit 4
2340 // bool MT17HealthIsUnavailable = (int(_health) & (1<<4));
2341 // is not used because the MT17health bits can be independently set if URA index is 15
2342
2343 return 0;
2344}
2345
[6385]2346// RINEX Format String
2347//////////////////////////////////////////////////////////////////////////////
[6388]2348QString t_ephSBAS::toString(double version) const {
2349
[10587]2350 QString ephStr = typeStr(_type, _prn, version);
[10577]2351 QString rnxStr = ephStr + rinexDateStr(_TOC, _prn, version);
[6388]2352
2353 QTextStream out(&rnxStr);
2354
[10577]2355 out
[10587]2356 << QString("%1%2%3\n")
2357 .arg(_agf0, 19, 'e', 12)
2358 .arg(_agf1, 19, 'e', 12)
2359 .arg(_TOT, 19, 'e', 12);
[6388]2360
2361 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
[9788]2362 // =====================
2363 // BROADCAST ORBIT - 1
2364 // =====================
[10577]2365 out
[10587]2366 << QString(fmt)
2367 .arg(1.e-3 * _x_pos, 19, 'e', 12)
2368 .arg(1.e-3 * _x_vel, 19, 'e', 12)
2369 .arg(1.e-3 * _x_acc, 19, 'e', 12)
2370 .arg(_health, 19, 'e', 12);
[9788]2371 // =====================
2372 // BROADCAST ORBIT - 2
2373 // =====================
[10577]2374 out
[10587]2375 << QString(fmt)
2376 .arg(1.e-3 * _y_pos, 19, 'e', 12)
2377 .arg(1.e-3 * _y_vel, 19, 'e', 12)
2378 .arg(1.e-3 * _y_acc, 19, 'e', 12)
2379 .arg(_ura, 19, 'e', 12);
[9788]2380 // =====================
2381 // BROADCAST ORBIT - 3
2382 // =====================
[10577]2383 out
[10587]2384 << QString(fmt)
2385 .arg(1.e-3 * _z_pos, 19, 'e', 12)
2386 .arg(1.e-3 * _z_vel, 19, 'e', 12)
2387 .arg(1.e-3 * _z_acc, 19, 'e', 12)
2388 .arg(double(_IODN), 19, 'e', 12);
[6388]2389
2390 return rnxStr;
[6385]2391}
[6400]2392
2393// Constructor
2394//////////////////////////////////////////////////////////////////////////////
[10603]2395t_ephBDS::t_ephBDS(double rnxVersion, const QStringList &lines, const QString typeStr) {
[6400]2396
[10603]2397 setType(typeStr);
2398
[9788]2399 int nLines = 8;
[6400]2400
[10587]2401 if (type() == t_eph::CNV1 ||
2402 type() == t_eph::CNV2) {
[9788]2403 nLines += 2;
2404 }
[10587]2405 if (type() == t_eph::CNV3) {
[9788]2406 nLines += 1;
2407 }
2408
[6400]2409 if (lines.size() != nLines) {
[6518]2410 _checkState = bad;
[6400]2411 return;
2412 }
2413
2414 // RINEX Format
2415 // ------------
2416 int fieldLen = 19;
2417
2418 int pos[4];
[10577]2419 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
[6400]2420 pos[1] = pos[0] + fieldLen;
2421 pos[2] = pos[1] + fieldLen;
2422 pos[3] = pos[2] + fieldLen;
2423
2424 // Read eight lines
2425 // ----------------
2426 for (int iLine = 0; iLine < nLines; iLine++) {
2427 QString line = lines[iLine];
2428
[10577]2429 if (iLine == 0) {
[8204]2430 QTextStream in(line.left(pos[1]).toLatin1());
[6400]2431
[10577]2432 int year, month, day, hour, min;
[6400]2433 double sec;
[6880]2434
[7139]2435 QString prnStr, n;
[6880]2436 in >> prnStr;
[7639]2437 if (prnStr.size() == 1 && prnStr[0] == 'C') {
[7139]2438 in >> n;
2439 prnStr.append(n);
[6880]2440 }
[6400]2441 if (prnStr.at(0) == 'C') {
2442 _prn.set('C', prnStr.mid(1).toInt());
[10577]2443 } else {
[6400]2444 _prn.set('C', prnStr.toInt());
2445 }
2446
[10599]2447 in >> year >> month >> day >> hour >> min >> sec;
[10577]2448 if (year < 80) {
[6400]2449 year += 2000;
[10577]2450 } else if (year < 100) {
[6400]2451 year += 1900;
2452 }
2453
[6812]2454 _TOC.setBDS(year, month, day, hour, min, sec);
[6400]2455
[10587]2456 if ( readDbl(line, pos[1], fieldLen, _clock_bias)
[10577]2457 || readDbl(line, pos[2], fieldLen, _clock_drift)
2458 || readDbl(line, pos[3], fieldLen, _clock_driftrate)) {
[6518]2459 _checkState = bad;
[6400]2460 return;
2461 }
2462 }
[9788]2463 // =====================
2464 // BROADCAST ORBIT - 1
2465 // =====================
[10577]2466 else if (iLine == 1) {
[10587]2467 if (type() == t_eph::D1 ||
2468 type() == t_eph::D2 ||
2469 type() == t_eph::undefined) {
2470 double aode;
2471 if ( readDbl(line, pos[0], fieldLen, aode)
2472 || readDbl(line, pos[1], fieldLen, _Crs)
2473 || readDbl(line, pos[2], fieldLen, _Delta_n)
2474 || readDbl(line, pos[3], fieldLen, _M0)) {
2475 _checkState = bad;
2476 return;
2477 }
2478 _AODE = int(aode);
[6400]2479 }
[10587]2480 else { //CNV1, CNV2, CNV3
2481 if ( readDbl(line, pos[0], fieldLen, _ADOT)
2482 || readDbl(line, pos[1], fieldLen, _Crs)
2483 || readDbl(line, pos[2], fieldLen, _Delta_n)
2484 || readDbl(line, pos[3], fieldLen, _M0)) {
2485 _checkState = bad;
2486 return;
2487 }
2488 }
[6400]2489 }
[9788]2490 // =====================
2491 // BROADCAST ORBIT - 2
2492 // =====================
[10577]2493 else if (iLine == 2) {
[10587]2494 if ( readDbl(line, pos[0], fieldLen, _Cuc)
[10577]2495 || readDbl(line, pos[1], fieldLen, _e)
2496 || readDbl(line, pos[2], fieldLen, _Cus)
2497 || readDbl(line, pos[3], fieldLen, _sqrt_A)) {
[6518]2498 _checkState = bad;
[6400]2499 return;
2500 }
2501 }
[9788]2502 // =====================
2503 // BROADCAST ORBIT - 3
2504 // =====================
[10577]2505 else if (iLine == 3) {
[10587]2506 if ( readDbl(line, pos[0], fieldLen, _TOEsec)
[10577]2507 || readDbl(line, pos[1], fieldLen, _Cic)
2508 || readDbl(line, pos[2], fieldLen, _OMEGA0)
2509 || readDbl(line, pos[3], fieldLen, _Cis)) {
[6518]2510 _checkState = bad;
[6400]2511 return;
2512 }
2513 }
[9788]2514 // =====================
2515 // BROADCAST ORBIT - 4
2516 // =====================
[10577]2517 else if (iLine == 4) {
[10587]2518 if ( readDbl(line, pos[0], fieldLen, _i0)
[10577]2519 || readDbl(line, pos[1], fieldLen, _Crc)
2520 || readDbl(line, pos[2], fieldLen, _omega)
2521 || readDbl(line, pos[3], fieldLen, _OMEGADOT)) {
[6518]2522 _checkState = bad;
[6400]2523 return;
2524 }
[10587]2525 else {
2526 // Source RINEX version < 4
2527 if (type() == t_eph::undefined) {
2528 const double iMaxGEO = 10.0 / 180.0 * M_PI;
2529 if (_i0 > iMaxGEO) {
2530 _type = t_eph::D1;
2531 }
2532 else {
2533 _type = t_eph::D2;
2534 }
2535 }
2536 }
[6400]2537 }
[9788]2538 // =====================
2539 // BROADCAST ORBIT - 5
2540 // =====================
[10577]2541 else if (iLine == 5) {
[10587]2542 if (type() == t_eph::CNV1 ||
2543 type() == t_eph::CNV2 ||
2544 type() == t_eph::CNV3) {
2545 if ( readDbl(line, pos[0], fieldLen, _IDOT)
[10577]2546 || readDbl(line, pos[1], fieldLen, _Delta_n_dot)
2547 || readDbl(line, pos[2], fieldLen, _satType)
2548 || readDbl(line, pos[3], fieldLen, _top)) {
[9788]2549 _checkState = bad;
2550 return;
2551 }
[10587]2552 }
2553 else { // D1, D2
2554 if ( readDbl(line, pos[0], fieldLen, _IDOT)
[10577]2555 || readDbl(line, pos[2], fieldLen, _BDTweek)) {
[9788]2556 _checkState = bad;
2557 return;
2558 }
2559 }
[6400]2560 }
[9788]2561 // =====================
2562 // BROADCAST ORBIT - 6
2563 // =====================
[10577]2564 else if (iLine == 6) {
[10587]2565 if (type() == t_eph::CNV1 ||
2566 type() == t_eph::CNV2 ||
2567 type() == t_eph::CNV3) {
2568 if ( readDbl(line, pos[0], fieldLen, _SISAI_oe)
[10577]2569 || readDbl(line, pos[1], fieldLen, _SISAI_ocb)
2570 || readDbl(line, pos[2], fieldLen, _SISAI_oc1)
2571 || readDbl(line, pos[3], fieldLen, _SISAI_oc2)) {
[9788]2572 _checkState = bad;
2573 return;
2574 }
[10587]2575 }
2576 else { // D1, D2
[9788]2577 double SatH1;
[10587]2578 if ( readDbl(line, pos[0], fieldLen, _ura)
[10577]2579 || readDbl(line, pos[1], fieldLen, SatH1)
2580 || readDbl(line, pos[2], fieldLen, _TGD1)
2581 || readDbl(line, pos[3], fieldLen, _TGD2)) {
[9788]2582 _checkState = bad;
2583 return;
2584 }
2585 _SatH1 = int(SatH1);
2586 }
[6400]2587 }
[9788]2588 // =====================
2589 // BROADCAST ORBIT - 7
2590 // =====================
[10577]2591 else if (iLine == 7) {
[10587]2592 if (type() == t_eph::CNV1) {
2593 if ( readDbl(line, pos[0], fieldLen, _ISC_B1Cd)
[10577]2594 || readDbl(line, pos[2], fieldLen, _TGD_B1Cp)
2595 || readDbl(line, pos[3], fieldLen, _TGD_B2ap)) {
[9788]2596 _checkState = bad;
2597 return;
2598 }
[10587]2599 }
2600 else if (type() == t_eph::CNV2) {
2601 if ( readDbl(line, pos[1], fieldLen, _ISC_B2ad)
[10577]2602 || readDbl(line, pos[2], fieldLen, _TGD_B1Cp)
2603 || readDbl(line, pos[3], fieldLen, _TGD_B2ap)) {
[9788]2604 _checkState = bad;
2605 return;
2606 }
[10587]2607 }
2608 else if (type() == t_eph::CNV3) {
[9789]2609 double health;
[10587]2610 if ( readDbl(line, pos[0], fieldLen, _SISMAI)
[10577]2611 || readDbl(line, pos[1], fieldLen, health)
2612 || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B2b)
2613 || readDbl(line, pos[3], fieldLen, _TGD_B2bI)) {
[9788]2614 _checkState = bad;
2615 return;
2616 }
[9789]2617 _health = int(health);
[10587]2618 }
2619 else { // D1, D2
[9788]2620 double aodc;
[10587]2621 if ( readDbl(line, pos[0], fieldLen, _TOT)
[10577]2622 || readDbl(line, pos[1], fieldLen, aodc)) {
[9788]2623 _checkState = bad;
2624 return;
2625 }
2626 if (_TOT == 0.9999e9) { // 0.9999e9 means not known (RINEX standard)
2627 _TOT = _TOEsec;
2628 }
2629 _AODC = int(aodc);
2630 }
[6400]2631 }
[9788]2632 // =====================
2633 // BROADCAST ORBIT - 8
2634 // =====================
[10577]2635 else if (iLine == 8) {
[9789]2636 double health;
[10587]2637 if (type() == t_eph::CNV1) {
2638 if ( readDbl(line, pos[0], fieldLen, _SISMAI)
[10577]2639 || readDbl(line, pos[1], fieldLen, health)
2640 || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B1C)
2641 || readDbl(line, pos[3], fieldLen, _IODC)) {
[9788]2642 _checkState = bad;
2643 return;
2644 }
[9789]2645 _health = int(health);
[10587]2646 }
2647 else if (type() == t_eph::CNV2) {
2648 if ( readDbl(line, pos[0], fieldLen, _SISMAI)
[10577]2649 || readDbl(line, pos[1], fieldLen, health)
2650 || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B2aB1C)
2651 || readDbl(line, pos[3], fieldLen, _IODC)) {
[9788]2652 _checkState = bad;
2653 return;
2654 }
[9789]2655 _health = int(health);
[10587]2656 }
2657 else if (type() == t_eph::CNV3) {
[10577]2658 if (readDbl(line, pos[0], fieldLen, _TOT)) {
[9788]2659 _checkState = bad;
2660 return;
2661 }
2662 }
2663 }
2664 // =====================
2665 // BROADCAST ORBIT - 9
2666 // =====================
[10577]2667 else if (iLine == 9) {
[10587]2668 if (type() == t_eph::CNV1 ||
2669 type() == t_eph::CNV2) {
2670 if ( readDbl(line, pos[0], fieldLen, _TOT)
[10577]2671 || readDbl(line, pos[3], fieldLen, _IODE)) {
[9788]2672 _checkState = bad;
2673 return;
2674 }
2675 }
2676 }
[6400]2677 }
[10599]2678 _prn.setFlag(type());
[6400]2679
[10577]2680 _TOE.setBDS(int(_BDTweek), _TOEsec);
[6400]2681 // remark: actually should be computed from second_tot
2682 // but it seems to be unreliable in RINEX files
[6843]2683 //_TOT = _TOC.bdssec();
[6400]2684}
2685
[7054]2686// IOD of BDS Ephemeris (virtual)
2687////////////////////////////////////////////////////////////////////////////
[7169]2688unsigned int t_ephBDS::IOD() const {
[10577]2689 return (int(_TOC.gpssec()) / 720) % 240; //return (int(_TOEsec)/720) % 240;
[7054]2690}
2691
[6601]2692// Compute BDS Satellite Position (virtual)
[6400]2693//////////////////////////////////////////////////////////////////////////////
[10577]2694t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double *xc,
2695 double *vv) const {
[6400]2696
[10577]2697 static const double gmBDS = 398.6004418e12;
[6602]2698 static const double omegaBDS = 7292115.0000e-11;
[6400]2699
2700 xc[0] = xc[1] = xc[2] = xc[3] = 0.0;
2701 vv[0] = vv[1] = vv[2] = 0.0;
2702
2703 bncTime tt(GPSweek, GPSweeks);
2704
2705 if (_sqrt_A == 0) {
2706 return failure;
2707 }
2708 double a0 = _sqrt_A * _sqrt_A;
2709
[10577]2710 double n0 = sqrt(gmBDS / (a0 * a0 * a0));
[6400]2711 double tk = tt - _TOE;
[10577]2712 double n = n0 + _Delta_n;
2713 double M = _M0 + n * tk;
2714 double E = M;
[6400]2715 double E_last;
[10577]2716 int nLoop = 0;
[6400]2717 do {
2718 E_last = E;
[10577]2719 E = M + _e * sin(E);
[6400]2720
2721 if (++nLoop == 100) {
2722 return failure;
2723 }
[10577]2724 } while (fabs(E - E_last) * a0 > 0.001);
[6400]2725
[10577]2726 double v = atan2(sqrt(1 - _e * _e) * sin(E), cos(E) - _e);
2727 double u0 = v + _omega;
2728 double sin2u0 = sin(2 * u0);
2729 double cos2u0 = cos(2 * u0);
2730 double r = a0 * (1 - _e * cos(E)) + _Crc * cos2u0 + _Crs * sin2u0;
2731 double i = _i0 + _IDOT * tk + _Cic * cos2u0 + _Cis * sin2u0;
2732 double u = u0 + _Cuc * cos2u0 + _Cus * sin2u0;
2733 double xp = r * cos(u);
2734 double yp = r * sin(u);
[6400]2735 double toesec = (_TOE.gpssec() - 14.0);
2736 double sinom = 0;
2737 double cosom = 0;
[10577]2738 double sini = 0;
2739 double cosi = 0;
[7278]2740
[7481]2741 // Velocity
2742 // --------
[10577]2743 double tanv2 = tan(v / 2);
2744 double dEdM = 1 / (1 - _e * cos(E));
2745 double dotv = sqrt((1.0 + _e) / (1.0 - _e)) / cos(E / 2) / cos(E / 2)
2746 / (1 + tanv2 * tanv2) * dEdM * n;
2747 double dotu = dotv + (-_Cuc * sin2u0 + _Cus * cos2u0) * 2 * dotv;
2748 double doti = _IDOT + (-_Cic * sin2u0 + _Cis * cos2u0) * 2 * dotv;
2749 double dotr = a0 * _e * sin(E) * dEdM * n
2750 + (-_Crc * sin2u0 + _Crs * cos2u0) * 2 * dotv;
[7481]2751
[10577]2752 double dotx = dotr * cos(u) - r * sin(u) * dotu;
2753 double doty = dotr * sin(u) + r * cos(u) * dotu;
[7481]2754
[6400]2755 const double iMaxGEO = 10.0 / 180.0 * M_PI;
2756
2757 // MEO/IGSO satellite
2758 // ------------------
2759 if (_i0 > iMaxGEO) {
[10577]2760 double OM = _OMEGA0 + (_OMEGADOT - omegaBDS) * tk - omegaBDS * toesec;
[6400]2761
2762 sinom = sin(OM);
2763 cosom = cos(OM);
[10577]2764 sini = sin(i);
2765 cosi = cos(i);
[6400]2766
[10577]2767 xc[0] = xp * cosom - yp * cosi * sinom;
2768 xc[1] = xp * sinom + yp * cosi * cosom;
2769 xc[2] = yp * sini;
[7481]2770
2771 // Velocity
2772 // --------
2773
2774 double dotom = _OMEGADOT - t_CST::omega;
2775
[10577]2776 vv[0] = cosom * dotx - cosi * sinom * doty // dX / dr
2777 - xp * sinom * dotom - yp * cosi * cosom * dotom // dX / dOMEGA
2778 + yp * sini * sinom * doti; // dX / di
[7481]2779
[10577]2780 vv[1] = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom
2781 - yp * cosi * sinom * dotom - yp * sini * cosom * doti;
[7481]2782
[10577]2783 vv[2] = sini * doty + yp * cosi * doti;
[7481]2784
[6400]2785 }
2786
2787 // GEO satellite
2788 // -------------
2789 else {
[10577]2790 double OM = _OMEGA0 + _OMEGADOT * tk - omegaBDS * toesec;
2791 double ll = omegaBDS * tk;
[6400]2792
2793 sinom = sin(OM);
2794 cosom = cos(OM);
[10577]2795 sini = sin(i);
2796 cosi = cos(i);
[6400]2797
[10577]2798 double xx = xp * cosom - yp * cosi * sinom;
2799 double yy = xp * sinom + yp * cosi * cosom;
2800 double zz = yp * sini;
[6400]2801
[7487]2802 Matrix RX = BNC_PPP::t_astro::rotX(-5.0 / 180.0 * M_PI);
2803 Matrix RZ = BNC_PPP::t_astro::rotZ(ll);
[6400]2804
[10577]2805 ColumnVector X1(3);
2806 X1 << xx << yy << zz;
2807 ColumnVector X2 = RZ * RX * X1;
[6400]2808
2809 xc[0] = X2(1);
2810 xc[1] = X2(2);
2811 xc[2] = X2(3);
[7278]2812
[7481]2813 double dotom = _OMEGADOT;
[6400]2814
[10577]2815 double vx = cosom * dotx - cosi * sinom * doty - xp * sinom * dotom
2816 - yp * cosi * cosom * dotom + yp * sini * sinom * doti;
[6400]2817
[10577]2818 double vy = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom
2819 - yp * cosi * sinom * dotom - yp * sini * cosom * doti;
[7278]2820
[10577]2821 double vz = sini * doty + yp * cosi * doti;
[6400]2822
[10577]2823 ColumnVector V(3);
2824 V << vx << vy << vz;
[7481]2825
[10577]2826 Matrix RdotZ(3, 3);
[7481]2827 double C = cos(ll);
2828 double S = sin(ll);
[10577]2829 Matrix UU(3, 3);
2830 UU[0][0] = -S;
2831 UU[0][1] = +C;
2832 UU[0][2] = 0.0;
2833 UU[1][0] = -C;
2834 UU[1][1] = -S;
2835 UU[1][2] = 0.0;
2836 UU[2][0] = 0.0;
2837 UU[2][1] = 0.0;
2838 UU[2][2] = 0.0;
[7487]2839 RdotZ = omegaBDS * UU;
[7481]2840
2841 ColumnVector VV(3);
[10577]2842 VV = RZ * RX * V + RdotZ * RX * X1;
[7481]2843
2844 vv[0] = VV(1);
2845 vv[1] = VV(2);
2846 vv[2] = VV(3);
2847 }
2848
2849 double tc = tt - _TOC;
[10577]2850 xc[3] = _clock_bias + _clock_drift * tc + _clock_driftrate * tc * tc;
[7481]2851
[9132]2852// dotC = _clock_drift + _clock_driftrate*tc
[9290]2853// - 4.442807309e-10*_e * sqrt(a0) * cos(E) * dEdM * n;
[6400]2854
[7481]2855 // Relativistic Correction
2856 // -----------------------
[10577]2857 xc[3] -= 4.442807309e-10 * _e * sqrt(a0) * sin(E);
[7481]2858
[10577]2859 xc[4] = _clock_drift + _clock_driftrate * tc;
[8542]2860 xc[5] = _clock_driftrate;
[9126]2861
[6400]2862 return success;
2863}
2864
[9789]2865// Health status of SBAS Ephemeris (virtual)
2866////////////////////////////////////////////////////////////////////////////
2867unsigned int t_ephBDS::isUnhealthy() const {
2868
[10587]2869 if (type() == t_eph::CNV1 || type() == t_eph::CNV2
2870 || type() == t_eph::CNV3) {
[9789]2871 return static_cast<unsigned int>(_health);
2872 }
2873
2874 return static_cast<unsigned int>(_SatH1);
2875
2876}
2877
[6400]2878// RINEX Format String
2879//////////////////////////////////////////////////////////////////////////////
[6600]2880QString t_ephBDS::toString(double version) const {
[8419]2881
[10587]2882 if (version < 4.0 &&
2883 (type() == t_eph::CNV1 ||
2884 type() == t_eph::CNV2 ||
2885 type() == t_eph::CNV3 )) {
2886 return "";
2887 }
2888
2889 QString ephStr = typeStr(_type, _prn, version);
[10577]2890 QString rnxStr = ephStr + rinexDateStr(_TOC - 14.0, _prn, version);
[6400]2891
2892 QTextStream out(&rnxStr);
2893
[10577]2894 out
[10587]2895 << QString("%1%2%3\n")
2896 .arg(_clock_bias, 19, 'e', 12)
2897 .arg(_clock_drift, 19, 'e', 12)
2898 .arg(_clock_driftrate, 19, 'e', 12);
[6400]2899
2900 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
[9788]2901 // =====================
2902 // BROADCAST ORBIT - 1
2903 // =====================
[10587]2904 if (type() == t_eph::D1 ||
2905 type() == t_eph::D2 ||
2906 type() == t_eph::undefined) {
2907 out
2908 << QString(fmt)
2909 .arg(double(_AODE), 19, 'e', 12)
2910 .arg(_Crs, 19, 'e', 12)
2911 .arg(_Delta_n, 19, 'e', 12)
2912 .arg(_M0, 19, 'e', 12);
2913 }
2914 else { //CNV1, CNV2, CNV3
2915 out
2916 << QString(fmt)
2917 .arg(_ADOT, 19, 'e', 12)
2918 .arg(_Crs, 19, 'e', 12)
2919 .arg(_Delta_n, 19, 'e', 12)
2920 .arg(_M0, 19, 'e', 12);
2921 }
2922
[9788]2923 // =====================
2924 // BROADCAST ORBIT - 2
2925 // =====================
[10577]2926 out
[10587]2927 << QString(fmt)
2928 .arg(_Cuc, 19, 'e', 12)
2929 .arg(_e, 19, 'e', 12)
2930 .arg(_Cus, 19, 'e', 12)
2931 .arg(_sqrt_A, 19, 'e', 12);
2932
[9788]2933 // =====================
2934 // BROADCAST ORBIT - 3
2935 // =====================
[10577]2936 out
[10587]2937 << QString(fmt)
2938 .arg(_TOEsec, 19, 'e', 12)
2939 .arg(_Cic, 19, 'e', 12)
2940 .arg(_OMEGA0, 19, 'e', 12)
2941 .arg(_Cis, 19, 'e', 12);
[9788]2942 // =====================
2943 // BROADCAST ORBIT - 4
2944 // =====================
[10577]2945 out
[10587]2946 << QString(fmt)
2947 .arg(_i0, 19, 'e', 12)
2948 .arg(_Crc, 19, 'e', 12)
2949 .arg(_omega, 19, 'e', 12)
2950 .arg(_OMEGADOT, 19, 'e', 12);
[9788]2951 // =====================
2952 // BROADCAST ORBIT - 5
2953 // =====================
[10587]2954 if (type() == t_eph::CNV1 ||
2955 type() == t_eph::CNV2 ||
2956 type() == t_eph::CNV3) {
[10577]2957 out
[10587]2958 << QString(fmt)
2959 .arg(_IDOT, 19, 'e', 12)
2960 .arg(_Delta_n_dot, 19, 'e', 12)
2961 .arg(_satType, 19, 'e', 12)
2962 .arg(_top, 19, 'e', 12);
2963 }
2964 else { // D1, D2,
[10577]2965 out
[10587]2966 << QString(fmt)
2967 .arg(_IDOT, 19, 'e', 12)
2968 .arg("", 19, QChar(' '))
2969 .arg(_BDTweek, 19, 'e', 12)
2970 .arg("", 19, QChar(' '));
[9788]2971 }
2972 // =====================
2973 // BROADCAST ORBIT - 6
2974 // =====================
[10587]2975 if (type() == t_eph::CNV1 ||
2976 type() == t_eph::CNV2 ||
2977 type() == t_eph::CNV3) {
[10577]2978 out
[10587]2979 << QString(fmt)
2980 .arg(_SISAI_oe, 19, 'e', 12)
2981 .arg(_SISAI_ocb, 19, 'e', 12)
2982 .arg(_SISAI_oc1, 19, 'e', 12)
2983 .arg(_SISAI_oc2, 19, 'e', 12);
2984 }
2985 else { // D1, D2, undefined
[10577]2986 out
[10587]2987 << QString(fmt)
2988 .arg(_ura, 19, 'e', 12)
2989 .arg(double(_SatH1), 19, 'e', 12)
2990 .arg(_TGD1, 19, 'e', 12)
2991 .arg(_TGD2, 19, 'e', 12);
[9788]2992 }
2993 // =====================
2994 // BROADCAST ORBIT - 7
2995 // =====================
[10587]2996 if (type() == t_eph::CNV1) {
[10577]2997 out
[10587]2998 << QString(fmt)
2999 .arg(_ISC_B1Cd, 19, 'e', 12)
3000 .arg("", 19, QChar(' '))
3001 .arg(_TGD_B1Cp, 19, 'e', 12)
3002 .arg(_TGD_B2ap, 19, 'e', 12);
3003 }
3004 else if (type() == t_eph::CNV2) {
[10577]3005 out
[10587]3006 << QString(fmt)
3007 .arg("", 19, QChar(' '))
3008 .arg(_ISC_B2ad, 19, 'e', 12)
3009 .arg(_TGD_B1Cp, 19, 'e', 12)
3010 .arg(_TGD_B2ap, 19, 'e', 12);
3011 }
3012 else if (type() == t_eph::CNV3) {
[10577]3013 out
[10587]3014 << QString(fmt)
3015 .arg(_SISMAI, 19, 'e', 12)
3016 .arg(double(_health), 19, 'e', 12)
3017 .arg(_INTEGRITYF_B2b, 19, 'e', 12)
3018 .arg(_TGD_B2bI, 19, 'e', 12);
3019 }
3020 else { // D1, D2, undefined
[9788]3021 double tots = 0.0;
[10577]3022 if (_receptDateTime.isValid()) { // RTCM stream input
[9788]3023 tots = _TOE.bdssec();
[10577]3024 } else { // RINEX input
[9788]3025 tots = _TOT;
3026 }
[10577]3027 out
[10587]3028 << QString(fmt)
3029 .arg(tots, 19, 'e', 12)
3030 .arg(double(_AODC), 19, 'e', 12)
3031 .arg("", 19, QChar(' '))
3032 .arg("", 19, QChar(' '));
[9788]3033 }
[6400]3034
[9788]3035 // =====================
3036 // BROADCAST ORBIT - 8
3037 // =====================
[10587]3038 if (type() == t_eph::CNV1) {
[10577]3039 out
[10587]3040 << QString(fmt)
3041 .arg(_SISMAI, 19, 'e', 12)
3042 .arg(double(_health), 19, 'e', 12)
3043 .arg(_INTEGRITYF_B1C, 19, 'e', 12)
3044 .arg(_IODC, 19, 'e', 12);
3045 }
3046 else if (type() == t_eph::CNV2) {
[10577]3047 out
[10587]3048 << QString(fmt)
3049 .arg(_SISMAI, 19, 'e', 12)
3050 .arg(double(_health), 19, 'e', 12)
3051 .arg(_INTEGRITYF_B2aB1C, 19, 'e', 12)
3052 .arg(_IODC, 19, 'e', 12);
3053 }
3054 else if (type() == t_eph::CNV3) {
[10577]3055 out
[10587]3056 << QString(fmt)
3057 .arg(_TOT, 19, 'e', 12)
3058 .arg("", 19, QChar(' '))
3059 .arg("", 19, QChar(' '))
3060 .arg("", 19, QChar(' '));
[9788]3061 }
[6400]3062
[9788]3063 // =====================
3064 // BROADCAST ORBIT - 9
3065 // =====================
[10587]3066 if (type() == t_eph::CNV1 ||
3067 type() == t_eph::CNV2) {
[10577]3068 out
[10587]3069 << QString(fmt)
3070 .arg(_TOT, 19, 'e', 12)
3071 .arg("", 19, QChar(' '))
3072 .arg("", 19, QChar(' '))
3073 .arg(_IODE, 19, 'e', 12);
[9788]3074 }
[6400]3075
3076 return rnxStr;
3077}
Note: See TracBrowser for help on using the repository browser.