[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 |
|
---|
| 18 | using namespace std;
|
---|
| 19 |
|
---|
[5749] | 20 | // Constructor
|
---|
| 21 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 22 | t_eph::t_eph() {
|
---|
[6518] | 23 | _checkState = unchecked;
|
---|
[10587] | 24 | _type = undefined;
|
---|
[10577] | 25 | _orbCorr = 0;
|
---|
| 26 | _clkCorr = 0;
|
---|
[5749] | 27 | }
|
---|
[7278] | 28 | // Destructor
|
---|
| 29 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 30 | t_eph::~t_eph() {
|
---|
| 31 | if (_orbCorr)
|
---|
| 32 | delete _orbCorr;
|
---|
| 33 | if (_clkCorr)
|
---|
| 34 | delete _clkCorr;
|
---|
| 35 | }
|
---|
[5749] | 36 |
|
---|
[7481] | 37 | //
|
---|
[5749] | 38 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10577] | 39 | void 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] | 49 | void 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] | 59 | t_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] | 111 | void 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] | 150 | QString 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] | 221 | QString 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] | 229 | QString 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] | 267 | t_ephGPS::t_ephGPS(double rnxVersion, const QStringList &lines, QString typeStr) {
|
---|
[10614] | 268 |
|
---|
[10603] | 269 | setType(typeStr);
|
---|
[10614] | 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 | // =====================
|
---|
[10619] | 432 | else if (iLine == 5 && system() != t_eph::NavIC) {
|
---|
[10587] | 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 | }
|
---|
[10619] | 452 | } else if (iLine == 5 && system() == t_eph::NavIC) {
|
---|
[10587] | 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 | // =====================
|
---|
[10619] | 472 | else if (iLine == 6 && system() != t_eph::NavIC) {
|
---|
[10587] | 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 | }
|
---|
[10619] | 492 | else if (iLine == 6 && system() == t_eph::NavIC) {
|
---|
[10587] | 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 | }
|
---|
[10619] | 522 | if (system() != t_eph::NavIC) {
|
---|
[10587] | 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] | 634 | t_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 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 723 | QString 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 | // =====================
|
---|
[10619] | 814 | if (system() != t_eph::NavIC) {
|
---|
[10587] | 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 | // =====================
|
---|
[10619] | 855 | if (system() != t_eph::NavIC) {
|
---|
[10587] | 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
|
---|
[10619] | 914 | if (system() == t_eph::NavIC) {
|
---|
[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] | 1051 | t_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) {
|
---|
[10614] | 1059 | // cannot be determined from input data
|
---|
| 1060 | // but is set to be able to work with old RINEX files in BNC applications
|
---|
| 1061 | _type = t_eph::FDMA_M;
|
---|
[10587] | 1062 | }
|
---|
| 1063 |
|
---|
[9367] | 1064 | if (rnxVersion >= 3.05) {
|
---|
| 1065 | nLines += 1;
|
---|
[10577] | 1066 | } else {
|
---|
[9367] | 1067 | _M_delta_tau = 0.9999e9; // unknown
|
---|
[10587] | 1068 | _M_FT = 1.5e1; // unknown
|
---|
[10614] | 1069 | _statusflags_unknown = true;
|
---|
| 1070 | _healthflags_unknown = true;
|
---|
[9367] | 1071 | }
|
---|
[6801] | 1072 |
|
---|
| 1073 | if (lines.size() != nLines) {
|
---|
| 1074 | _checkState = bad;
|
---|
| 1075 | return;
|
---|
[6518] | 1076 | }
|
---|
| 1077 |
|
---|
[6801] | 1078 | // RINEX Format
|
---|
| 1079 | // ------------
|
---|
| 1080 | int fieldLen = 19;
|
---|
[9367] | 1081 | double statusflags = 0.0;
|
---|
| 1082 | double healthflags = 0.0;
|
---|
[10587] | 1083 | double sourceflags = 0.0;
|
---|
| 1084 | _tauC = 0.0;
|
---|
| 1085 | _tau1 = 0.0;
|
---|
| 1086 | _tau2 = 0.0;
|
---|
| 1087 | _additional_data_availability = 0.0;
|
---|
[2221] | 1088 |
|
---|
[6801] | 1089 | int pos[4];
|
---|
[10577] | 1090 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
[6801] | 1091 | pos[1] = pos[0] + fieldLen;
|
---|
| 1092 | pos[2] = pos[1] + fieldLen;
|
---|
| 1093 | pos[3] = pos[2] + fieldLen;
|
---|
[2221] | 1094 |
|
---|
[6801] | 1095 | // Read four lines
|
---|
| 1096 | // ---------------
|
---|
| 1097 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 1098 | QString line = lines[iLine];
|
---|
[2221] | 1099 |
|
---|
[10577] | 1100 | if (iLine == 0) {
|
---|
[8204] | 1101 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
[6213] | 1102 |
|
---|
[10577] | 1103 | int year, month, day, hour, min;
|
---|
[6801] | 1104 | double sec;
|
---|
[2221] | 1105 |
|
---|
[7139] | 1106 | QString prnStr, n;
|
---|
[6880] | 1107 | in >> prnStr;
|
---|
[7639] | 1108 | if (prnStr.size() == 1 && prnStr[0] == 'R') {
|
---|
[7139] | 1109 | in >> n;
|
---|
| 1110 | prnStr.append(n);
|
---|
[6880] | 1111 | }
|
---|
[10599] | 1112 |
|
---|
[6801] | 1113 | if (prnStr.at(0) == 'R') {
|
---|
| 1114 | _prn.set('R', prnStr.mid(1).toInt());
|
---|
[10577] | 1115 | } else {
|
---|
[6801] | 1116 | _prn.set('R', prnStr.toInt());
|
---|
| 1117 | }
|
---|
[2221] | 1118 |
|
---|
[10599] | 1119 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[10577] | 1120 | if (year < 80) {
|
---|
[6801] | 1121 | year += 2000;
|
---|
[10577] | 1122 | } else if (year < 100) {
|
---|
[6801] | 1123 | year += 1900;
|
---|
| 1124 | }
|
---|
[2221] | 1125 |
|
---|
[6801] | 1126 | _gps_utc = gnumleap(year, month, day);
|
---|
[2221] | 1127 |
|
---|
[6801] | 1128 | _TOC.set(year, month, day, hour, min, sec);
|
---|
[10577] | 1129 | _TOC = _TOC + _gps_utc;
|
---|
| 1130 | int nd = int((_TOC.gpssec())) / (24.0 * 60.0 * 60.0);
|
---|
[10587] | 1131 | if ( readDbl(line, pos[1], fieldLen, _tau)
|
---|
[10577] | 1132 | || readDbl(line, pos[2], fieldLen, _gamma)
|
---|
| 1133 | || readDbl(line, pos[3], fieldLen, _tki)) {
|
---|
[6801] | 1134 | _checkState = bad;
|
---|
| 1135 | return;
|
---|
| 1136 | }
|
---|
[8800] | 1137 | _tki -= nd * 86400.0;
|
---|
[10577] | 1138 | _tau = -_tau;
|
---|
[6801] | 1139 | }
|
---|
[9788] | 1140 | // =====================
|
---|
| 1141 | // BROADCAST ORBIT - 1
|
---|
| 1142 | // =====================
|
---|
[10577] | 1143 | else if (iLine == 1) {
|
---|
[10587] | 1144 | if ( readDbl(line, pos[0], fieldLen, _x_pos)
|
---|
| 1145 | || readDbl(line, pos[1], fieldLen, _x_vel)
|
---|
| 1146 | || readDbl(line, pos[2], fieldLen, _x_acc)
|
---|
[10577] | 1147 | || readDbl(line, pos[3], fieldLen, _health)) {
|
---|
[6801] | 1148 | _checkState = bad;
|
---|
| 1149 | return;
|
---|
| 1150 | }
|
---|
| 1151 | }
|
---|
[9788] | 1152 | // =====================
|
---|
| 1153 | // BROADCAST ORBIT - 2
|
---|
| 1154 | // =====================
|
---|
[10577] | 1155 | else if (iLine == 2) {
|
---|
[10614] | 1156 | if (type() == t_eph::FDMA ||
|
---|
| 1157 | type() == t_eph::FDMA_M) {
|
---|
[10587] | 1158 | if ( readDbl(line, pos[0], fieldLen, _y_pos)
|
---|
| 1159 | || readDbl(line, pos[1], fieldLen, _y_vel)
|
---|
| 1160 | || readDbl(line, pos[2], fieldLen, _y_acc)
|
---|
| 1161 | || readDbl(line, pos[3], fieldLen, _frq_num)) {
|
---|
| 1162 | _checkState = bad;
|
---|
| 1163 | return;
|
---|
| 1164 | }
|
---|
[6801] | 1165 | }
|
---|
[10587] | 1166 | else { //L1OC, L3OC
|
---|
| 1167 | if ( readDbl(line, pos[0], fieldLen, _y_pos)
|
---|
| 1168 | || readDbl(line, pos[1], fieldLen, _y_vel)
|
---|
| 1169 | || readDbl(line, pos[2], fieldLen, _y_acc)
|
---|
| 1170 | || readDbl(line, pos[3], fieldLen, statusflags)) {
|
---|
| 1171 | _checkState = bad;
|
---|
| 1172 | return;
|
---|
| 1173 | }
|
---|
| 1174 | _data_validity = int(statusflags);
|
---|
| 1175 | }
|
---|
[6801] | 1176 | }
|
---|
[9788] | 1177 | // =====================
|
---|
| 1178 | // BROADCAST ORBIT - 3
|
---|
| 1179 | // =====================
|
---|
[10577] | 1180 | else if (iLine == 3) {
|
---|
[10614] | 1181 | if (type() == t_eph::FDMA ||
|
---|
| 1182 | type() == t_eph::FDMA_M) {
|
---|
[10587] | 1183 | if ( readDbl(line, pos[0], fieldLen, _z_pos)
|
---|
| 1184 | || readDbl(line, pos[1], fieldLen, _z_vel)
|
---|
| 1185 | || readDbl(line, pos[2], fieldLen, _z_acc)
|
---|
| 1186 | || readDbl(line, pos[3], fieldLen, _E)) {
|
---|
| 1187 | _checkState = bad;
|
---|
| 1188 | return;
|
---|
| 1189 | }
|
---|
[6801] | 1190 | }
|
---|
[10587] | 1191 | else if (type() == t_eph::L1OC) {
|
---|
| 1192 | if ( readDbl(line, pos[0], fieldLen, _z_pos)
|
---|
| 1193 | || readDbl(line, pos[1], fieldLen, _z_vel)
|
---|
| 1194 | || readDbl(line, pos[2], fieldLen, _z_acc)
|
---|
| 1195 | || readDbl(line, pos[3], fieldLen, _TGD_L2OCp)) {
|
---|
| 1196 | _checkState = bad;
|
---|
| 1197 | return;
|
---|
| 1198 | }
|
---|
| 1199 | }
|
---|
| 1200 | else if (type() == t_eph::L3OC) {
|
---|
| 1201 | if ( readDbl(line, pos[0], fieldLen, _z_pos)
|
---|
| 1202 | || readDbl(line, pos[1], fieldLen, _z_vel)
|
---|
| 1203 | || readDbl(line, pos[2], fieldLen, _z_acc)
|
---|
| 1204 | || readDbl(line, pos[3], fieldLen, _TGD_L3OCp)) {
|
---|
| 1205 | _checkState = bad;
|
---|
| 1206 | return;
|
---|
| 1207 | }
|
---|
| 1208 | }
|
---|
[6801] | 1209 | }
|
---|
[9788] | 1210 | // =====================
|
---|
| 1211 | // BROADCAST ORBIT - 4
|
---|
| 1212 | // =====================
|
---|
[10577] | 1213 | else if (iLine == 4) {
|
---|
[10614] | 1214 | if (type() == t_eph::FDMA ||
|
---|
| 1215 | type() == t_eph::FDMA_M) {
|
---|
[10587] | 1216 | if (readDbl(line, pos[0], fieldLen, statusflags)) {
|
---|
| 1217 | //status flags BLK, do nothing
|
---|
| 1218 | _statusflags_unknown = true;
|
---|
| 1219 | } else {
|
---|
| 1220 | _statusflags_unknown = false;
|
---|
| 1221 | // status flags
|
---|
| 1222 | // ============
|
---|
| 1223 | // bit 0-1
|
---|
| 1224 | _M_P = double(bitExtracted(int(statusflags), 2, 0));
|
---|
| 1225 | // bit 2-3
|
---|
| 1226 | _P1 = double(bitExtracted(int(statusflags), 2, 2));
|
---|
| 1227 | // bit 4
|
---|
| 1228 | _P2 = double(bitExtracted(int(statusflags), 1, 4));
|
---|
| 1229 | // bit 5
|
---|
| 1230 | _P3 = double(bitExtracted(int(statusflags), 1, 5));
|
---|
| 1231 | // bit 6
|
---|
| 1232 | _M_P4 = double(bitExtracted(int(statusflags), 1, 6));
|
---|
| 1233 | // bit 7-8
|
---|
| 1234 | _M_M = double(bitExtracted(int(statusflags), 2, 7));
|
---|
| 1235 | /// GLO M/K exclusive flags/values only valid if flag M is set to '01'
|
---|
| 1236 | if (!_M_M) {
|
---|
| 1237 | _M_P = 0.0;
|
---|
| 1238 | _M_l3 = 0.0;
|
---|
| 1239 | _M_P4 = 0.0;
|
---|
| 1240 | _M_FE = 0.0;
|
---|
| 1241 | _M_FT = 0.0;
|
---|
| 1242 | _M_NA = 0.0;
|
---|
| 1243 | _M_NT = 0.0;
|
---|
| 1244 | _M_N4 = 0.0;
|
---|
| 1245 | _M_l5 = 0.0;
|
---|
| 1246 | _M_tau_GPS = 0.0;
|
---|
| 1247 | _M_delta_tau = 0.0;
|
---|
[10614] | 1248 | _type = t_eph::FDMA;
|
---|
[10587] | 1249 | }
|
---|
[10599] | 1250 | else {
|
---|
| 1251 | _type = t_eph::FDMA_M;
|
---|
| 1252 | }
|
---|
[10587] | 1253 | }
|
---|
| 1254 | if ( readDbl(line, pos[1], fieldLen, _M_delta_tau)
|
---|
| 1255 | || readDbl(line, pos[2], fieldLen, _M_FT)) {
|
---|
| 1256 | _checkState = bad;
|
---|
| 1257 | return;
|
---|
| 1258 | }
|
---|
| 1259 | if (readDbl(line, pos[3], fieldLen, healthflags)) {
|
---|
| 1260 | // health flags BLK
|
---|
| 1261 | _healthflags_unknown = true;
|
---|
| 1262 | } else {
|
---|
| 1263 | _healthflags_unknown = false;
|
---|
| 1264 | // health flags
|
---|
| 1265 | // ============
|
---|
| 1266 | // bit 0 (is to be ignored, if bit 1 is zero)
|
---|
| 1267 | _almanac_health = double(bitExtracted(int(healthflags), 1, 0));
|
---|
| 1268 | // bit 1
|
---|
| 1269 | _almanac_health_availablility_indicator =
|
---|
| 1270 | double(bitExtracted(int(healthflags), 1, 1));
|
---|
| 1271 | // bit 2; GLO-M/K only, health bit of string 3
|
---|
| 1272 | _M_l3 = double(bitExtracted(int(healthflags), 1, 2));
|
---|
| 1273 | }
|
---|
| 1274 | }
|
---|
| 1275 | else if (type() == t_eph::L1OC ||
|
---|
| 1276 | type() == t_eph::L3OC) {
|
---|
| 1277 | if ( readDbl(line, pos[0], fieldLen, _sat_type)
|
---|
| 1278 | || readDbl(line, pos[1], fieldLen, sourceflags)
|
---|
| 1279 | || readDbl(line, pos[2], fieldLen, _EE)
|
---|
| 1280 | || readDbl(line, pos[3], fieldLen, _ET)) {
|
---|
| 1281 | _checkState = bad;
|
---|
| 1282 | return;
|
---|
| 1283 | }
|
---|
| 1284 | // sourceflags:
|
---|
[9367] | 1285 | // ============
|
---|
| 1286 | // bit 0-1
|
---|
[10587] | 1287 | _RT = double(bitExtracted(int(sourceflags), 2, 0));
|
---|
| 1288 | // bit 2-3:
|
---|
| 1289 | _RE = double(bitExtracted(int(sourceflags), 2, 2));
|
---|
| 1290 | }
|
---|
| 1291 | }
|
---|
| 1292 | // =====================
|
---|
| 1293 | // BROADCAST ORBIT - 5
|
---|
| 1294 | // =====================
|
---|
| 1295 | else if (iLine == 5) {
|
---|
| 1296 | if (type() == t_eph::L1OC ||
|
---|
| 1297 | type() == t_eph::L3OC) {
|
---|
| 1298 | if ( readDbl(line, pos[0], fieldLen, _attitude_P2)
|
---|
| 1299 | || readDbl(line, pos[1], fieldLen, _Tin)
|
---|
| 1300 | || readDbl(line, pos[2], fieldLen, _tau1)
|
---|
| 1301 | || readDbl(line, pos[3], fieldLen, _tau2)) {
|
---|
| 1302 | _checkState = bad;
|
---|
| 1303 | return;
|
---|
[9367] | 1304 | }
|
---|
[9892] | 1305 | }
|
---|
[10587] | 1306 | }
|
---|
| 1307 | // =====================
|
---|
| 1308 | // BROADCAST ORBIT - 6
|
---|
| 1309 | // =====================
|
---|
| 1310 | else if (iLine == 6) {
|
---|
| 1311 | if (type() == t_eph::L1OC ||
|
---|
| 1312 | type() == t_eph::L3OC) {
|
---|
| 1313 | if ( readDbl(line, pos[0], fieldLen, _yaw)
|
---|
| 1314 | || readDbl(line, pos[1], fieldLen, _sn)
|
---|
| 1315 | || readDbl(line, pos[2], fieldLen, _angular_rate)
|
---|
| 1316 | || readDbl(line, pos[3], fieldLen, _angular_acc)) {
|
---|
| 1317 | _checkState = bad;
|
---|
| 1318 | return;
|
---|
| 1319 | }
|
---|
[9892] | 1320 | }
|
---|
[10587] | 1321 | }
|
---|
| 1322 | // =====================
|
---|
| 1323 | // BROADCAST ORBIT - 7
|
---|
| 1324 | // =====================
|
---|
| 1325 | else if (iLine == 7) {
|
---|
| 1326 | if (type() == t_eph::L1OC ||
|
---|
| 1327 | type() == t_eph::L3OC) {
|
---|
| 1328 | if ( readDbl(line, pos[0], fieldLen, _angular_rate_max)
|
---|
| 1329 | || readDbl(line, pos[1], fieldLen, _X_PC)
|
---|
| 1330 | || readDbl(line, pos[2], fieldLen, _Y_PC)
|
---|
| 1331 | || readDbl(line, pos[3], fieldLen, _Z_PC)) {
|
---|
| 1332 | _checkState = bad;
|
---|
| 1333 | return;
|
---|
| 1334 | }
|
---|
[9367] | 1335 | }
|
---|
| 1336 | }
|
---|
[10587] | 1337 | // =====================
|
---|
| 1338 | // BROADCAST ORBIT - 8
|
---|
| 1339 | // =====================
|
---|
| 1340 | else if (iLine == 8) {
|
---|
| 1341 | if (type() == t_eph::L1OC ||
|
---|
| 1342 | type() == t_eph::L3OC) {
|
---|
| 1343 | if ( readDbl(line, pos[0], fieldLen, _M_FE)
|
---|
| 1344 | || readDbl(line, pos[1], fieldLen, _M_FT)
|
---|
| 1345 | || readDbl(line, pos[3], fieldLen, _TOT)) {
|
---|
| 1346 | _checkState = bad;
|
---|
| 1347 | return;
|
---|
| 1348 | }
|
---|
| 1349 | }
|
---|
| 1350 | }
|
---|
[6801] | 1351 | }
|
---|
| 1352 |
|
---|
[10599] | 1353 | _prn.setFlag(type());
|
---|
| 1354 |
|
---|
[6801] | 1355 | // Initialize status vector
|
---|
| 1356 | // ------------------------
|
---|
| 1357 | _tt = _TOC;
|
---|
[10577] | 1358 | _xv.ReSize(6);
|
---|
| 1359 | _xv = 0.0;
|
---|
[6801] | 1360 | _xv(1) = _x_pos * 1.e3;
|
---|
| 1361 | _xv(2) = _y_pos * 1.e3;
|
---|
| 1362 | _xv(3) = _z_pos * 1.e3;
|
---|
[10587] | 1363 | _xv(4) = _x_vel * 1.e3;
|
---|
| 1364 | _xv(5) = _y_vel * 1.e3;
|
---|
| 1365 | _xv(6) = _z_vel * 1.e3;
|
---|
[2221] | 1366 | }
|
---|
| 1367 |
|
---|
[6801] | 1368 | // Compute Glonass Satellite Position (virtual)
|
---|
[2771] | 1369 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10577] | 1370 | t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double *xc,
|
---|
| 1371 | double *vv) const {
|
---|
[2771] | 1372 |
|
---|
[6801] | 1373 | static const double nominalStep = 10.0;
|
---|
[2771] | 1374 |
|
---|
[10577] | 1375 | memset(xc, 0, 6 * sizeof(double));
|
---|
| 1376 | memset(vv, 0, 3 * sizeof(double));
|
---|
[2771] | 1377 |
|
---|
[6801] | 1378 | double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
|
---|
| 1379 |
|
---|
[8698] | 1380 | if (fabs(dtPos) > 24 * 3600.0) {
|
---|
[6213] | 1381 | return failure;
|
---|
[2771] | 1382 | }
|
---|
| 1383 |
|
---|
[10577] | 1384 | int nSteps = int(fabs(dtPos) / nominalStep) + 1;
|
---|
[6801] | 1385 | double step = dtPos / nSteps;
|
---|
[4018] | 1386 |
|
---|
[6801] | 1387 | double acc[3];
|
---|
[10587] | 1388 | acc[0] = _x_acc * 1.e3;
|
---|
| 1389 | acc[1] = _y_acc * 1.e3;
|
---|
| 1390 | acc[2] = _z_acc * 1.e3;
|
---|
[9132] | 1391 |
|
---|
[6801] | 1392 | for (int ii = 1; ii <= nSteps; ii++) {
|
---|
| 1393 | _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
|
---|
| 1394 | _tt = _tt + step;
|
---|
| 1395 | }
|
---|
[4018] | 1396 |
|
---|
[6801] | 1397 | // Position and Velocity
|
---|
| 1398 | // ---------------------
|
---|
| 1399 | xc[0] = _xv(1);
|
---|
| 1400 | xc[1] = _xv(2);
|
---|
| 1401 | xc[2] = _xv(3);
|
---|
[2771] | 1402 |
|
---|
[6801] | 1403 | vv[0] = _xv(4);
|
---|
| 1404 | vv[1] = _xv(5);
|
---|
| 1405 | vv[2] = _xv(6);
|
---|
[2771] | 1406 |
|
---|
[6801] | 1407 | // Clock Correction
|
---|
| 1408 | // ----------------
|
---|
| 1409 | double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
|
---|
| 1410 | xc[3] = -_tau + _gamma * dtClk;
|
---|
[2771] | 1411 |
|
---|
[8542] | 1412 | xc[4] = _gamma;
|
---|
| 1413 | xc[5] = 0.0;
|
---|
[8483] | 1414 |
|
---|
[6213] | 1415 | return success;
|
---|
[2771] | 1416 | }
|
---|
| 1417 |
|
---|
[6801] | 1418 | // RINEX Format String
|
---|
[3659] | 1419 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6801] | 1420 | QString t_ephGlo::toString(double version) const {
|
---|
[3664] | 1421 |
|
---|
[10587] | 1422 | if (version < 4.0 &&
|
---|
| 1423 | (type() == t_eph::L1OC ||
|
---|
| 1424 | type() == t_eph::L3OC )) {
|
---|
| 1425 | return "";
|
---|
| 1426 | }
|
---|
| 1427 |
|
---|
| 1428 | QString ephStr = typeStr(_type, _prn, version);
|
---|
[10577] | 1429 | QString rnxStr = ephStr + rinexDateStr(_TOC - _gps_utc, _prn, version);
|
---|
| 1430 | int nd = int((_TOC - _gps_utc).gpssec()) / (24.0 * 60.0 * 60.0);
|
---|
[6801] | 1431 | QTextStream out(&rnxStr);
|
---|
[3664] | 1432 |
|
---|
[10577] | 1433 | out
|
---|
[10587] | 1434 | << QString("%1%2%3\n")
|
---|
| 1435 | .arg(-_tau, 19, 'e', 12)
|
---|
| 1436 | .arg(_gamma, 19, 'e', 12)
|
---|
| 1437 | .arg(_tki + nd * 86400.0, 19, 'e', 12);
|
---|
[3668] | 1438 |
|
---|
[6801] | 1439 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
[9788] | 1440 | // =====================
|
---|
| 1441 | // BROADCAST ORBIT - 1
|
---|
| 1442 | // =====================
|
---|
[10577] | 1443 | out
|
---|
[10587] | 1444 | << QString(fmt)
|
---|
| 1445 | .arg(_x_pos, 19, 'e', 12)
|
---|
| 1446 | .arg(_x_vel, 19, 'e', 12)
|
---|
| 1447 | .arg(_x_acc, 19, 'e', 12)
|
---|
| 1448 | .arg(_health, 19, 'e', 12);
|
---|
| 1449 |
|
---|
[9788] | 1450 | // =====================
|
---|
| 1451 | // BROADCAST ORBIT - 2
|
---|
| 1452 | // =====================
|
---|
[10599] | 1453 | if (type() == t_eph::FDMA ||
|
---|
| 1454 | type() == t_eph::FDMA_M) {
|
---|
[10587] | 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(_frq_num, 19, 'e', 12);
|
---|
| 1461 | }
|
---|
| 1462 | else { //L1OC, L3OC
|
---|
| 1463 | out
|
---|
| 1464 | << QString(fmt)
|
---|
| 1465 | .arg(_y_pos, 19, 'e', 12)
|
---|
| 1466 | .arg(_y_vel, 19, 'e', 12)
|
---|
| 1467 | .arg(_y_acc, 19, 'e', 12)
|
---|
| 1468 | .arg(double(_data_validity), 19, 'e', 12);
|
---|
| 1469 | }
|
---|
[9788] | 1470 | // =====================
|
---|
| 1471 | // BROADCAST ORBIT - 3
|
---|
| 1472 | // =====================
|
---|
[10599] | 1473 | if (type() == t_eph::FDMA ||
|
---|
| 1474 | type() == t_eph::FDMA_M) {
|
---|
[10587] | 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(_E, 19, 'e', 12);
|
---|
| 1481 | }
|
---|
| 1482 | else if (type() == t_eph::L1OC) {
|
---|
| 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_L2OCp, 19, 'e', 12);
|
---|
| 1489 | }
|
---|
| 1490 | else if (type() == t_eph::L3OC) {
|
---|
| 1491 | out
|
---|
| 1492 | << QString(fmt)
|
---|
| 1493 | .arg(_z_pos, 19, 'e', 12)
|
---|
| 1494 | .arg(_z_vel, 19, 'e', 12)
|
---|
| 1495 | .arg(_z_acc, 19, 'e', 12)
|
---|
| 1496 | .arg(_TGD_L3OCp, 19, 'e', 12);
|
---|
| 1497 | }
|
---|
[9367] | 1498 | if (version >= 3.05) {
|
---|
[10587] | 1499 | // =====================
|
---|
| 1500 | // BROADCAST ORBIT - 4
|
---|
| 1501 | // =====================
|
---|
[10599] | 1502 | if (type() == t_eph::FDMA ||
|
---|
| 1503 | type() == t_eph::FDMA_M){
|
---|
[9367] | 1504 | int statusflags = 0;
|
---|
[10587] | 1505 | int healthflags = 0;
|
---|
| 1506 | if (!_statusflags_unknown ) {
|
---|
| 1507 | // bit 0-1
|
---|
| 1508 | if (_M_P == 1.0) {statusflags |= (1 << 0);}
|
---|
| 1509 | else if (_M_P == 2.0) {statusflags |= (1 << 1);}
|
---|
| 1510 | else if (_M_P == 3.0) {statusflags |= (1 << 0); statusflags |= (1 << 1);}
|
---|
| 1511 | // bit 2-3
|
---|
| 1512 | if (_P1 == 1.0) {statusflags |= (1 << 2);}
|
---|
| 1513 | else if (_P1 == 2.0) {statusflags |= (1 << 3);}
|
---|
| 1514 | else if (_P1 == 3.0) {statusflags |= (1 << 2); statusflags |= (1 << 3);}
|
---|
| 1515 | // bit 4
|
---|
| 1516 | if (_P2) {statusflags |= (1 << 4);}
|
---|
| 1517 | // bit 5
|
---|
| 1518 | if (_P3) {statusflags |= (1 << 5);}
|
---|
| 1519 | // bit 6
|
---|
| 1520 | if (_M_P4) {statusflags |= (1 << 6);}
|
---|
| 1521 | // bit 7-8
|
---|
| 1522 | if (_M_M == 1.0) {statusflags |= (1 << 7);}
|
---|
[9367] | 1523 | }
|
---|
[10587] | 1524 | if (!_healthflags_unknown) {
|
---|
| 1525 | // bit 0 (is to be ignored, if bit 1 is zero)
|
---|
| 1526 | if (_almanac_health) {healthflags |= (1 << 0);}
|
---|
| 1527 | // bit 1
|
---|
| 1528 | if (_almanac_health_availablility_indicator) {healthflags |= (1 << 1);}
|
---|
| 1529 | // bit 2
|
---|
| 1530 | if (_M_l3) {healthflags |= (1 << 2);}
|
---|
[9367] | 1531 | }
|
---|
[10587] | 1532 |
|
---|
| 1533 | if (_statusflags_unknown && _healthflags_unknown) {
|
---|
| 1534 | out
|
---|
| 1535 | << QString(fmt)
|
---|
| 1536 | .arg("", 19, QChar(' ')) // status-flags BNK (unknown)
|
---|
| 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(double(statusflags), 19, 'e', 12)
|
---|
| 1545 | .arg(_M_delta_tau, 19, 'e', 12)
|
---|
| 1546 | .arg(_M_FT, 19, 'e', 12)
|
---|
| 1547 | .arg("", 19, QChar(' '));// health-flags BNK (unknown)
|
---|
[9367] | 1548 | }
|
---|
[10587] | 1549 | else if (_statusflags_unknown && !_healthflags_unknown) {
|
---|
| 1550 | out
|
---|
| 1551 | << QString(fmt)
|
---|
| 1552 | .arg("", 19, QChar(' ')) // status-flags BNK (unknown)
|
---|
| 1553 | .arg(_M_delta_tau, 19, 'e', 12)
|
---|
| 1554 | .arg(_M_FT, 19, 'e', 12)
|
---|
| 1555 | .arg(double(healthflags), 19, 'e', 12);
|
---|
[9367] | 1556 | }
|
---|
[10587] | 1557 | else if (!_statusflags_unknown && !_healthflags_unknown) {
|
---|
| 1558 | out
|
---|
| 1559 | << QString(fmt)
|
---|
| 1560 | .arg(double(statusflags), 19, 'e', 12)
|
---|
| 1561 | .arg(_M_delta_tau, 19, 'e', 12)
|
---|
| 1562 | .arg(_M_FT, 19, 'e', 12)
|
---|
| 1563 | .arg(double(healthflags), 19, 'e', 12);
|
---|
| 1564 | }
|
---|
| 1565 | }
|
---|
| 1566 | else if (type() == t_eph::L1OC ||
|
---|
| 1567 | type() == t_eph::L3OC) {
|
---|
| 1568 | int sourceflags = 0;
|
---|
[9367] | 1569 | // bit 0-1
|
---|
[10587] | 1570 | if (_RT == 1.0) {sourceflags |= (1 << 0);}
|
---|
| 1571 | else if (_RT == 2.0) {sourceflags |= (1 << 1);}
|
---|
| 1572 | else if (_RT == 3.0) {sourceflags |= (1 << 0); sourceflags |= (1 << 1);}
|
---|
| 1573 | // bit 2-3
|
---|
| 1574 | if (_RE == 1.0) {sourceflags |= (1 << 2);}
|
---|
| 1575 | else if (_RE == 2.0) {sourceflags |= (1 << 3);}
|
---|
| 1576 | else if (_RE == 3.0) {sourceflags |= (1 << 2); sourceflags |= (1 << 3);}
|
---|
[10577] | 1577 | out
|
---|
[10587] | 1578 | << QString(fmt)
|
---|
| 1579 | .arg(_sat_type , 19, 'e', 12)
|
---|
| 1580 | .arg(double(sourceflags), 19, 'e', 12)
|
---|
| 1581 | .arg(_ET, 19, 'e', 12)
|
---|
| 1582 | .arg(_EE, 19, 'e', 12);
|
---|
[9367] | 1583 | }
|
---|
[10587] | 1584 | // =====================
|
---|
| 1585 | // BROADCAST ORBIT - 5
|
---|
| 1586 | // =====================
|
---|
| 1587 | if (type() == t_eph::L1OC ||
|
---|
| 1588 | type() == t_eph::L3OC) {
|
---|
| 1589 | out
|
---|
| 1590 | << QString(fmt)
|
---|
| 1591 | .arg(_attitude_P2, 19, 'e', 12)
|
---|
| 1592 | .arg(_Tin, 19, 'e', 12)
|
---|
| 1593 | .arg(_tau1, 19, 'e', 12)
|
---|
| 1594 | .arg(_tau2, 19, 'e', 12);
|
---|
| 1595 | }
|
---|
| 1596 | // =====================
|
---|
| 1597 | // BROADCAST ORBIT - 6
|
---|
| 1598 | // =====================
|
---|
| 1599 | if (type() == t_eph::L1OC ||
|
---|
| 1600 | type() == t_eph::L3OC) {
|
---|
| 1601 | out
|
---|
| 1602 | << QString(fmt)
|
---|
| 1603 | .arg(_yaw, 19, 'e', 12)
|
---|
| 1604 | .arg(_sn, 19, 'e', 12)
|
---|
| 1605 | .arg(_angular_rate, 19, 'e', 12)
|
---|
| 1606 | .arg(_angular_acc, 19, 'e', 12);
|
---|
| 1607 | }
|
---|
| 1608 | // =====================
|
---|
| 1609 | // BROADCAST ORBIT - 7
|
---|
| 1610 | // =====================
|
---|
| 1611 | if (type() == t_eph::L1OC ||
|
---|
| 1612 | type() == t_eph::L3OC) {
|
---|
| 1613 | out
|
---|
| 1614 | << QString(fmt)
|
---|
| 1615 | .arg(_angular_rate_max, 19, 'e', 12)
|
---|
| 1616 | .arg(_X_PC, 19, 'e', 12)
|
---|
| 1617 | .arg(_Y_PC, 19, 'e', 12)
|
---|
| 1618 | .arg(_Z_PC, 19, 'e', 12);
|
---|
| 1619 | }
|
---|
| 1620 | // =====================
|
---|
| 1621 | // BROADCAST ORBIT - 8
|
---|
| 1622 | // =====================
|
---|
| 1623 | if (type() == t_eph::L1OC ||
|
---|
| 1624 | type() == t_eph::L3OC) {
|
---|
| 1625 | out
|
---|
| 1626 | << QString(fmt)
|
---|
| 1627 | .arg(_M_FE, 19, 'e', 12)
|
---|
| 1628 | .arg(_M_FT, 19, 'e', 12)
|
---|
| 1629 | .arg("", 19, QChar(' '))
|
---|
| 1630 | .arg(_TOT, 19, 'e', 12);
|
---|
| 1631 | }
|
---|
[9367] | 1632 | }
|
---|
[6801] | 1633 | return rnxStr;
|
---|
[3659] | 1634 | }
|
---|
| 1635 |
|
---|
[6801] | 1636 | // Derivative of the state vector using a simple force model (static)
|
---|
| 1637 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10577] | 1638 | ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector &xv,
|
---|
| 1639 | double *acc) {
|
---|
[3659] | 1640 |
|
---|
[6801] | 1641 | // State vector components
|
---|
| 1642 | // -----------------------
|
---|
[10577] | 1643 | ColumnVector rr = xv.rows(1, 3);
|
---|
| 1644 | ColumnVector vv = xv.rows(4, 6);
|
---|
[3699] | 1645 |
|
---|
[6801] | 1646 | // Acceleration
|
---|
[3699] | 1647 | // ------------
|
---|
[6801] | 1648 | static const double gmWGS = 398.60044e12;
|
---|
[10577] | 1649 | static const double AE = 6378136.0;
|
---|
[6801] | 1650 | static const double OMEGA = 7292115.e-11;
|
---|
[10577] | 1651 | static const double C20 = -1082.6257e-6;
|
---|
[3699] | 1652 |
|
---|
[8903] | 1653 | double rho = rr.NormFrobenius();
|
---|
[10577] | 1654 | double t1 = -gmWGS / (rho * rho * rho);
|
---|
| 1655 | double t2 = 3.0 / 2.0 * C20 * (gmWGS * AE * AE)
|
---|
| 1656 | / (rho * rho * rho * rho * rho);
|
---|
| 1657 | double t3 = OMEGA * OMEGA;
|
---|
| 1658 | double t4 = 2.0 * OMEGA;
|
---|
| 1659 | double z2 = rr(3) * rr(3);
|
---|
[3699] | 1660 |
|
---|
[6801] | 1661 | // Vector of derivatives
|
---|
| 1662 | // ---------------------
|
---|
| 1663 | ColumnVector va(6);
|
---|
| 1664 | va(1) = vv(1);
|
---|
| 1665 | va(2) = vv(2);
|
---|
| 1666 | va(3) = vv(3);
|
---|
[10577] | 1667 | va(4) = (t1 + t2 * (1.0 - 5.0 * z2 / (rho * rho)) + t3) * rr(1) + t4 * vv(2)
|
---|
| 1668 | + acc[0];
|
---|
| 1669 | va(5) = (t1 + t2 * (1.0 - 5.0 * z2 / (rho * rho)) + t3) * rr(2) - t4 * vv(1)
|
---|
| 1670 | + acc[1];
|
---|
| 1671 | va(6) = (t1 + t2 * (3.0 - 5.0 * z2 / (rho * rho))) * rr(3) + acc[2];
|
---|
[3699] | 1672 |
|
---|
[6801] | 1673 | return va;
|
---|
| 1674 | }
|
---|
[3699] | 1675 |
|
---|
[6801] | 1676 | // IOD of Glonass Ephemeris (virtual)
|
---|
| 1677 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7169] | 1678 | unsigned int t_ephGlo::IOD() const {
|
---|
[6801] | 1679 | bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
|
---|
[10577] | 1680 | return (unsigned long) tMoscow.daysec() / 900;
|
---|
[3659] | 1681 | }
|
---|
| 1682 |
|
---|
[8187] | 1683 | // Health status of Glonass Ephemeris (virtual)
|
---|
| 1684 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1685 | unsigned int t_ephGlo::isUnhealthy() const {
|
---|
[8215] | 1686 |
|
---|
[8217] | 1687 | if (_almanac_health_availablility_indicator) {
|
---|
[10577] | 1688 | if ((_health == 0 && _almanac_health == 0)
|
---|
| 1689 | || (_health == 1 && _almanac_health == 0)
|
---|
| 1690 | || (_health == 1 && _almanac_health == 1)) {
|
---|
| 1691 | return 1;
|
---|
| 1692 | }
|
---|
| 1693 | } else if (!_almanac_health_availablility_indicator) {
|
---|
[8217] | 1694 | if (_health) {
|
---|
| 1695 | return 1;
|
---|
| 1696 | }
|
---|
| 1697 | }
|
---|
[8215] | 1698 | return 0; /* (_health == 0 && _almanac_health == 1) or (_health == 0) */
|
---|
[8187] | 1699 | }
|
---|
| 1700 |
|
---|
[3659] | 1701 | // Constructor
|
---|
| 1702 | //////////////////////////////////////////////////////////////////////////////
|
---|
[10603] | 1703 | t_ephGal::t_ephGal(double rnxVersion, const QStringList &lines, const QString typeStr) {
|
---|
[10599] | 1704 |
|
---|
[10603] | 1705 | setType(typeStr);
|
---|
| 1706 |
|
---|
[4891] | 1707 | const int nLines = 8;
|
---|
[10599] | 1708 |
|
---|
[4891] | 1709 | if (lines.size() != nLines) {
|
---|
[6518] | 1710 | _checkState = bad;
|
---|
[4891] | 1711 | return;
|
---|
| 1712 | }
|
---|
| 1713 |
|
---|
| 1714 | // RINEX Format
|
---|
| 1715 | // ------------
|
---|
| 1716 | int fieldLen = 19;
|
---|
[6792] | 1717 | double SVhealth = 0.0;
|
---|
| 1718 | double datasource = 0.0;
|
---|
[6798] | 1719 |
|
---|
[4891] | 1720 | int pos[4];
|
---|
[10577] | 1721 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
[4891] | 1722 | pos[1] = pos[0] + fieldLen;
|
---|
| 1723 | pos[2] = pos[1] + fieldLen;
|
---|
| 1724 | pos[3] = pos[2] + fieldLen;
|
---|
| 1725 |
|
---|
| 1726 | // Read eight lines
|
---|
| 1727 | // ----------------
|
---|
| 1728 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 1729 | QString line = lines[iLine];
|
---|
| 1730 |
|
---|
[10577] | 1731 | if (iLine == 0) {
|
---|
[8204] | 1732 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
[10599] | 1733 |
|
---|
| 1734 | int year, month, day, hour, min;
|
---|
| 1735 | double sec;
|
---|
| 1736 |
|
---|
| 1737 | QString prnStr, n;
|
---|
[6880] | 1738 | in >> prnStr;
|
---|
[7639] | 1739 | if (prnStr.size() == 1 && prnStr[0] == 'E') {
|
---|
[7139] | 1740 | in >> n;
|
---|
| 1741 | prnStr.append(n);
|
---|
[6880] | 1742 | }
|
---|
[10599] | 1743 | if (prnStr.at(0) == 'E') {
|
---|
| 1744 | _prn.set('E', prnStr.mid(1).toInt());
|
---|
| 1745 | } else {
|
---|
| 1746 | _prn.set('E', prnStr.toInt());
|
---|
| 1747 | }
|
---|
| 1748 |
|
---|
[6880] | 1749 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[10577] | 1750 | if (year < 80) {
|
---|
[4891] | 1751 | year += 2000;
|
---|
[10577] | 1752 | } else if (year < 100) {
|
---|
[4891] | 1753 | year += 1900;
|
---|
| 1754 | }
|
---|
| 1755 |
|
---|
| 1756 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 1757 |
|
---|
[10587] | 1758 | if ( readDbl(line, pos[1], fieldLen, _clock_bias)
|
---|
[10577] | 1759 | || readDbl(line, pos[2], fieldLen, _clock_drift)
|
---|
| 1760 | || readDbl(line, pos[3], fieldLen, _clock_driftrate)) {
|
---|
[6518] | 1761 | _checkState = bad;
|
---|
[4891] | 1762 | return;
|
---|
| 1763 | }
|
---|
| 1764 | }
|
---|
[9788] | 1765 | // =====================
|
---|
| 1766 | // BROADCAST ORBIT - 1
|
---|
| 1767 | // =====================
|
---|
[10577] | 1768 | else if (iLine == 1) {
|
---|
[10587] | 1769 | if ( readDbl(line, pos[0], fieldLen, _IODnav)
|
---|
[10577] | 1770 | || readDbl(line, pos[1], fieldLen, _Crs)
|
---|
| 1771 | || readDbl(line, pos[2], fieldLen, _Delta_n)
|
---|
| 1772 | || readDbl(line, pos[3], fieldLen, _M0)) {
|
---|
[6518] | 1773 | _checkState = bad;
|
---|
[4891] | 1774 | return;
|
---|
| 1775 | }
|
---|
| 1776 | }
|
---|
[9788] | 1777 | // =====================
|
---|
| 1778 | // BROADCAST ORBIT - 2
|
---|
| 1779 | // =====================
|
---|
[10577] | 1780 | else if (iLine == 2) {
|
---|
[10587] | 1781 | if ( readDbl(line, pos[0], fieldLen, _Cuc)
|
---|
[10577] | 1782 | || readDbl(line, pos[1], fieldLen, _e)
|
---|
| 1783 | || readDbl(line, pos[2], fieldLen, _Cus)
|
---|
| 1784 | || readDbl(line, pos[3], fieldLen, _sqrt_A)) {
|
---|
[6518] | 1785 | _checkState = bad;
|
---|
[4891] | 1786 | return;
|
---|
| 1787 | }
|
---|
| 1788 | }
|
---|
[9788] | 1789 | // =====================
|
---|
| 1790 | // BROADCAST ORBIT - 3
|
---|
| 1791 | // =====================
|
---|
[10577] | 1792 | else if (iLine == 3) {
|
---|
[10587] | 1793 | if ( readDbl(line, pos[0], fieldLen, _TOEsec)
|
---|
[10577] | 1794 | || readDbl(line, pos[1], fieldLen, _Cic)
|
---|
| 1795 | || readDbl(line, pos[2], fieldLen, _OMEGA0)
|
---|
| 1796 | || readDbl(line, pos[3], fieldLen, _Cis)) {
|
---|
[6518] | 1797 | _checkState = bad;
|
---|
[4891] | 1798 | return;
|
---|
| 1799 | }
|
---|
| 1800 | }
|
---|
[9788] | 1801 | // =====================
|
---|
| 1802 | // BROADCAST ORBIT - 4
|
---|
| 1803 | // =====================
|
---|
[10577] | 1804 | else if (iLine == 4) {
|
---|
[10587] | 1805 | if ( readDbl(line, pos[0], fieldLen, _i0)
|
---|
[10577] | 1806 | || readDbl(line, pos[1], fieldLen, _Crc)
|
---|
| 1807 | || readDbl(line, pos[2], fieldLen, _omega)
|
---|
| 1808 | || readDbl(line, pos[3], fieldLen, _OMEGADOT)) {
|
---|
[6518] | 1809 | _checkState = bad;
|
---|
[4891] | 1810 | return;
|
---|
| 1811 | }
|
---|
| 1812 | }
|
---|
[9788] | 1813 | // =====================
|
---|
| 1814 | // BROADCAST ORBIT - 5
|
---|
| 1815 | // =====================
|
---|
[10577] | 1816 | else if (iLine == 5) {
|
---|
[10587] | 1817 | if ( readDbl(line, pos[0], fieldLen, _IDOT)
|
---|
[10577] | 1818 | || readDbl(line, pos[1], fieldLen, datasource)
|
---|
| 1819 | || readDbl(line, pos[2], fieldLen, _TOEweek)) {
|
---|
[6518] | 1820 | _checkState = bad;
|
---|
[4891] | 1821 | return;
|
---|
[10587] | 1822 | }
|
---|
| 1823 | else {
|
---|
[10599] | 1824 | if (bitExtracted(unsigned(datasource), 1, 8)) {
|
---|
[6812] | 1825 | _fnav = true;
|
---|
[10599] | 1826 | _type = t_eph::FNAV;
|
---|
[6812] | 1827 | _inav = false;
|
---|
[10587] | 1828 | /* set unused I/NAV values */
|
---|
| 1829 | _E5b_HS = 0.0;
|
---|
| 1830 | _E1B_HS = 0.0;
|
---|
| 1831 | _E1B_DataInvalid = false;
|
---|
| 1832 | _E5b_DataInvalid = false;
|
---|
| 1833 | }
|
---|
[10599] | 1834 | if (bitExtracted(unsigned(datasource), 1, 9)) {
|
---|
[6812] | 1835 | _fnav = false;
|
---|
| 1836 | _inav = true;
|
---|
[10599] | 1837 | _type = t_eph::INAV;
|
---|
[10587] | 1838 | /* set unused F/NAV values */
|
---|
| 1839 | _E5a_HS = 0.0;
|
---|
| 1840 | _E5a_DataInvalid = false;
|
---|
[6792] | 1841 | }
|
---|
[10587] | 1842 | // GAL week # in RINEX is aligned/identical to continuous GPS week # used in RINEX
|
---|
| 1843 | // but GST week # started at the first GPS roll-over (continuous GPS week 1024)
|
---|
[6892] | 1844 | _TOEweek -= 1024.0;
|
---|
[4891] | 1845 | }
|
---|
| 1846 | }
|
---|
[9788] | 1847 | // =====================
|
---|
| 1848 | // BROADCAST ORBIT - 6
|
---|
| 1849 | // =====================
|
---|
[10577] | 1850 | else if (iLine == 6) {
|
---|
[10587] | 1851 | if ( readDbl(line, pos[0], fieldLen, _SISA)
|
---|
[10577] | 1852 | || readDbl(line, pos[1], fieldLen, SVhealth)
|
---|
| 1853 | || readDbl(line, pos[2], fieldLen, _BGD_1_5A)
|
---|
| 1854 | || readDbl(line, pos[3], fieldLen, _BGD_1_5B)) {
|
---|
[6518] | 1855 | _checkState = bad;
|
---|
[4891] | 1856 | return;
|
---|
[6792] | 1857 | } else {
|
---|
| 1858 | // Bit 0
|
---|
[10587] | 1859 | _E1B_DataInvalid = bitExtracted(int(SVhealth), 1, 0);
|
---|
[6792] | 1860 | // Bit 1-2
|
---|
[10587] | 1861 | _E1B_HS = double(bitExtracted(int(SVhealth), 2, 1));
|
---|
[6792] | 1862 | // Bit 3
|
---|
[10587] | 1863 | _E5a_DataInvalid = bitExtracted(int(SVhealth), 1, 3);
|
---|
[6792] | 1864 | // Bit 4-5
|
---|
[10587] | 1865 | _E5a_HS = double(bitExtracted(int(SVhealth), 2, 4));
|
---|
[6792] | 1866 | // Bit 6
|
---|
[10587] | 1867 | _E5b_DataInvalid = bitExtracted(int(SVhealth), 1, 6);
|
---|
[6792] | 1868 | // Bit 7-8
|
---|
[10587] | 1869 | _E5b_HS = double(bitExtracted(int(SVhealth), 2, 7));
|
---|
| 1870 | if (_fnav) {
|
---|
| 1871 | _BGD_1_5B = 0.0;
|
---|
| 1872 | }
|
---|
[4891] | 1873 | }
|
---|
| 1874 | }
|
---|
[9788] | 1875 | // =====================
|
---|
| 1876 | // BROADCAST ORBIT - 7
|
---|
| 1877 | // =====================
|
---|
[10577] | 1878 | else if (iLine == 7) {
|
---|
| 1879 | if (readDbl(line, pos[0], fieldLen, _TOT)) {
|
---|
[6518] | 1880 | _checkState = bad;
|
---|
[4891] | 1881 | return;
|
---|
| 1882 | }
|
---|
| 1883 | }
|
---|
| 1884 | }
|
---|
[10599] | 1885 | _prn.setFlag(type());
|
---|
[3659] | 1886 | }
|
---|
[4013] | 1887 |
|
---|
[6801] | 1888 | // Compute Galileo Satellite Position (virtual)
|
---|
| 1889 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10577] | 1890 | t_irc t_ephGal::position(int GPSweek, double GPSweeks, double *xc,
|
---|
| 1891 | double *vv) const {
|
---|
[4013] | 1892 |
|
---|
[6801] | 1893 | static const double omegaEarth = 7292115.1467e-11;
|
---|
[8212] | 1894 | static const double gmWGS = 398.6004418e12;
|
---|
[4023] | 1895 |
|
---|
[10577] | 1896 | memset(xc, 0, 6 * sizeof(double));
|
---|
| 1897 | memset(vv, 0, 3 * sizeof(double));
|
---|
[4023] | 1898 |
|
---|
[6801] | 1899 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 1900 | if (a0 == 0) {
|
---|
| 1901 | return failure;
|
---|
| 1902 | }
|
---|
[4023] | 1903 |
|
---|
[10577] | 1904 | double n0 = sqrt(gmWGS / (a0 * a0 * a0));
|
---|
[4023] | 1905 |
|
---|
[6801] | 1906 | bncTime tt(GPSweek, GPSweeks);
|
---|
| 1907 | double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
|
---|
[4023] | 1908 |
|
---|
[10577] | 1909 | double n = n0 + _Delta_n;
|
---|
| 1910 | double M = _M0 + n * tk;
|
---|
| 1911 | double E = M;
|
---|
[6801] | 1912 | double E_last;
|
---|
[10577] | 1913 | int nLoop = 0;
|
---|
[6801] | 1914 | do {
|
---|
| 1915 | E_last = E;
|
---|
[10577] | 1916 | E = M + _e * sin(E);
|
---|
[8368] | 1917 |
|
---|
| 1918 | if (++nLoop == 100) {
|
---|
| 1919 | return failure;
|
---|
| 1920 | }
|
---|
[10577] | 1921 | } while (fabs(E - E_last) * a0 > 0.001);
|
---|
| 1922 | double v = 2.0 * atan(sqrt((1.0 + _e) / (1.0 - _e)) * tan(E / 2));
|
---|
| 1923 | double u0 = v + _omega;
|
---|
| 1924 | double sin2u0 = sin(2 * u0);
|
---|
| 1925 | double cos2u0 = cos(2 * u0);
|
---|
| 1926 | double r = a0 * (1 - _e * cos(E)) + _Crc * cos2u0 + _Crs * sin2u0;
|
---|
| 1927 | double i = _i0 + _IDOT * tk + _Cic * cos2u0 + _Cis * sin2u0;
|
---|
| 1928 | double u = u0 + _Cuc * cos2u0 + _Cus * sin2u0;
|
---|
| 1929 | double xp = r * cos(u);
|
---|
| 1930 | double yp = r * sin(u);
|
---|
| 1931 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth) * tk - omegaEarth * _TOEsec;
|
---|
[4023] | 1932 |
|
---|
[6801] | 1933 | double sinom = sin(OM);
|
---|
| 1934 | double cosom = cos(OM);
|
---|
[10577] | 1935 | double sini = sin(i);
|
---|
| 1936 | double cosi = cos(i);
|
---|
| 1937 | xc[0] = xp * cosom - yp * cosi * sinom;
|
---|
| 1938 | xc[1] = xp * sinom + yp * cosi * cosom;
|
---|
| 1939 | xc[2] = yp * sini;
|
---|
[4023] | 1940 |
|
---|
[6801] | 1941 | double tc = tt - _TOC;
|
---|
[10577] | 1942 | xc[3] = _clock_bias + _clock_drift * tc + _clock_driftrate * tc * tc;
|
---|
[4023] | 1943 |
|
---|
[6801] | 1944 | // Velocity
|
---|
| 1945 | // --------
|
---|
[10577] | 1946 | double tanv2 = tan(v / 2);
|
---|
| 1947 | double dEdM = 1 / (1 - _e * cos(E));
|
---|
| 1948 | double dotv = sqrt((1.0 + _e) / (1.0 - _e)) / cos(E / 2) / cos(E / 2)
|
---|
| 1949 | / (1 + tanv2 * tanv2) * dEdM * n;
|
---|
| 1950 | double dotu = dotv + (-_Cuc * sin2u0 + _Cus * cos2u0) * 2 * dotv;
|
---|
[6801] | 1951 | double dotom = _OMEGADOT - omegaEarth;
|
---|
[10577] | 1952 | double doti = _IDOT + (-_Cic * sin2u0 + _Cis * cos2u0) * 2 * dotv;
|
---|
| 1953 | double dotr = a0 * _e * sin(E) * dEdM * n
|
---|
| 1954 | + (-_Crc * sin2u0 + _Crs * cos2u0) * 2 * dotv;
|
---|
| 1955 | double dotx = dotr * cos(u) - r * sin(u) * dotu;
|
---|
| 1956 | double doty = dotr * sin(u) + r * cos(u) * dotu;
|
---|
[4023] | 1957 |
|
---|
[10577] | 1958 | vv[0] = cosom * dotx - cosi * sinom * doty // dX / dr
|
---|
| 1959 | - xp * sinom * dotom - yp * cosi * cosom * dotom // dX / dOMEGA
|
---|
| 1960 | + yp * sini * sinom * doti; // dX / di
|
---|
[6801] | 1961 |
|
---|
[10577] | 1962 | vv[1] = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom
|
---|
| 1963 | - yp * cosi * sinom * dotom - yp * sini * cosom * doti;
|
---|
[6801] | 1964 |
|
---|
[10577] | 1965 | vv[2] = sini * doty + yp * cosi * doti;
|
---|
[6801] | 1966 |
|
---|
| 1967 | // Relativistic Correction
|
---|
| 1968 | // -----------------------
|
---|
[10577] | 1969 | xc[3] -= 4.442807309e-10 * _e * sqrt(a0) * sin(E);
|
---|
[6801] | 1970 |
|
---|
[10577] | 1971 | xc[4] = _clock_drift + _clock_driftrate * tc;
|
---|
[8542] | 1972 | xc[5] = _clock_driftrate;
|
---|
[8581] | 1973 |
|
---|
[6801] | 1974 | return success;
|
---|
[4023] | 1975 | }
|
---|
| 1976 |
|
---|
[8187] | 1977 | // Health status of Galileo Ephemeris (virtual)
|
---|
| 1978 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1979 | unsigned int t_ephGal::isUnhealthy() const {
|
---|
[10587] | 1980 | // SHS; 1 = Out of Service, 3 = In Test, 0 = Signal Ok, 2 = Extended Operations Mode
|
---|
| 1981 | if (_E5a_HS == 1 || _E5a_HS == 3 ||
|
---|
| 1982 | _E5b_HS == 1 || _E5b_HS == 3 ||
|
---|
| 1983 | _E1B_HS == 1 || _E1B_HS == 3) {
|
---|
[8187] | 1984 | return 1;
|
---|
| 1985 | }
|
---|
[10587] | 1986 | if (_E5a_DataInvalid ||
|
---|
| 1987 | _E5b_DataInvalid ||
|
---|
| 1988 | _E1B_DataInvalid) {
|
---|
[10562] | 1989 | return 1;
|
---|
| 1990 | }
|
---|
[10587] | 1991 | if (_SISA == 255.0) { // NAPA: No Accuracy Prediction Available
|
---|
[10315] | 1992 | return 1;
|
---|
| 1993 | }
|
---|
[10562] | 1994 | /*
|
---|
| 1995 | * SDD v1.3: SHS=2 leads to a newly-defined "EOM" status.
|
---|
| 1996 | * It also means that the satellite signal may be used for PNT.
|
---|
[10577] | 1997 | if (_E5aHS == 2 ||
|
---|
[10587] | 1998 | _E5bHS == 2 ||
|
---|
| 1999 | _E1_bHS == 2 ) {
|
---|
| 2000 | return 1;
|
---|
[10577] | 2001 | }
|
---|
| 2002 | */
|
---|
[8187] | 2003 | return 0;
|
---|
[10587] | 2004 |
|
---|
[8187] | 2005 | }
|
---|
| 2006 |
|
---|
[4023] | 2007 | // RINEX Format String
|
---|
| 2008 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 2009 | QString t_ephGal::toString(double version) const {
|
---|
| 2010 |
|
---|
[10587] | 2011 | QString ephStr = typeStr(_type, _prn, version);
|
---|
[10577] | 2012 | QString rnxStr = ephStr + rinexDateStr(_TOC, _prn, version);
|
---|
[4023] | 2013 |
|
---|
| 2014 | QTextStream out(&rnxStr);
|
---|
| 2015 |
|
---|
[10577] | 2016 | out
|
---|
| 2017 | << QString("%1%2%3\n").arg(_clock_bias, 19, 'e', 12).arg(_clock_drift, 19,
|
---|
| 2018 | 'e', 12).arg(_clock_driftrate, 19, 'e', 12);
|
---|
[4023] | 2019 |
|
---|
| 2020 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
[9788] | 2021 | // =====================
|
---|
| 2022 | // BROADCAST ORBIT - 1
|
---|
| 2023 | // =====================
|
---|
[10577] | 2024 | out
|
---|
[10587] | 2025 | << QString(fmt)
|
---|
| 2026 | .arg(_IODnav, 19, 'e', 12)
|
---|
| 2027 | .arg(_Crs, 19, 'e', 12)
|
---|
| 2028 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 2029 | .arg(_M0, 19, 'e', 12);
|
---|
[9788] | 2030 | // =====================
|
---|
| 2031 | // BROADCAST ORBIT - 2
|
---|
| 2032 | // =====================
|
---|
[10577] | 2033 | out
|
---|
[10587] | 2034 | << QString(fmt)
|
---|
| 2035 | .arg(_Cuc, 19, 'e', 12).
|
---|
| 2036 | arg(_e, 19, 'e', 12)
|
---|
| 2037 | .arg(_Cus, 19, 'e', 12)
|
---|
| 2038 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
[9788] | 2039 | // =====================
|
---|
| 2040 | // BROADCAST ORBIT - 3
|
---|
| 2041 | // =====================
|
---|
[10577] | 2042 | out
|
---|
[10587] | 2043 | << QString(fmt).
|
---|
| 2044 | arg(_TOEsec, 19, 'e', 12)
|
---|
| 2045 | .arg(_Cic, 19, 'e', 12)
|
---|
| 2046 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 2047 | .arg(_Cis, 19, 'e', 12);
|
---|
[9788] | 2048 | // =====================
|
---|
| 2049 | // BROADCAST ORBIT - 4
|
---|
| 2050 | // =====================
|
---|
[10577] | 2051 | out
|
---|
[10587] | 2052 | << QString(fmt)
|
---|
| 2053 | .arg(_i0, 19, 'e', 12)
|
---|
| 2054 | .arg(_Crc, 19, 'e', 12)
|
---|
| 2055 | .arg(_omega, 19, 'e', 12)
|
---|
| 2056 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
[9788] | 2057 | // =====================
|
---|
[10587] | 2058 | // BROADCAST ORBIT - 5/6
|
---|
[9788] | 2059 | // =====================
|
---|
[10577] | 2060 | int dataSource = 0;
|
---|
| 2061 | int SVhealth = 0;
|
---|
| 2062 | double BGD_1_5A = _BGD_1_5A;
|
---|
| 2063 | double BGD_1_5B = _BGD_1_5B;
|
---|
[6812] | 2064 | if (_fnav) {
|
---|
[10577] | 2065 | dataSource |= (1 << 1);
|
---|
| 2066 | dataSource |= (1 << 8);
|
---|
[6792] | 2067 | BGD_1_5B = 0.0;
|
---|
| 2068 | // SVhealth
|
---|
| 2069 | // Bit 3 : E5a DVS
|
---|
[10587] | 2070 | if (_E5a_DataInvalid) {
|
---|
[10577] | 2071 | SVhealth |= (1 << 3);
|
---|
[6792] | 2072 | }
|
---|
| 2073 | // Bit 4-5: E5a HS
|
---|
[10587] | 2074 | if (_E5a_HS == 1.0) {
|
---|
[10577] | 2075 | SVhealth |= (1 << 4);
|
---|
[10587] | 2076 | }
|
---|
| 2077 | else if (_E5a_HS == 2.0) {
|
---|
[10577] | 2078 | SVhealth |= (1 << 5);
|
---|
[10587] | 2079 | }
|
---|
| 2080 | else if (_E5a_HS == 3.0) {
|
---|
[10577] | 2081 | SVhealth |= (1 << 4);
|
---|
| 2082 | SVhealth |= (1 << 5);
|
---|
[6792] | 2083 | }
|
---|
[10577] | 2084 | } else if (_inav) {
|
---|
[6803] | 2085 | // Bit 2 and 0 are set because from MT1046 the data source cannot be determined
|
---|
| 2086 | // and RNXv3.03 says both can be set if the navigation messages were merged
|
---|
[10577] | 2087 | dataSource |= (1 << 0);
|
---|
| 2088 | dataSource |= (1 << 2);
|
---|
| 2089 | dataSource |= (1 << 9);
|
---|
[6792] | 2090 | // SVhealth
|
---|
| 2091 | // Bit 0 : E1-B DVS
|
---|
[10587] | 2092 | if (_E1B_DataInvalid) {
|
---|
[10577] | 2093 | SVhealth |= (1 << 0);
|
---|
[6792] | 2094 | }
|
---|
| 2095 | // Bit 1-2: E1-B HS
|
---|
[10587] | 2096 | if (_E1B_HS == 1.0) {
|
---|
[10577] | 2097 | SVhealth |= (1 << 1);
|
---|
[10587] | 2098 | }
|
---|
| 2099 | else if (_E1B_HS == 2.0) {
|
---|
[10577] | 2100 | SVhealth |= (1 << 2);
|
---|
[10587] | 2101 | }
|
---|
| 2102 | else if (_E1B_HS == 3.0) {
|
---|
[10577] | 2103 | SVhealth |= (1 << 1);
|
---|
| 2104 | SVhealth |= (1 << 2);
|
---|
[6792] | 2105 | }
|
---|
| 2106 | // Bit 6 : E5b DVS
|
---|
[10587] | 2107 | if (_E5b_DataInvalid) {
|
---|
[10577] | 2108 | SVhealth |= (1 << 6);
|
---|
[6792] | 2109 | }
|
---|
| 2110 | // Bit 7-8: E5b HS
|
---|
[10587] | 2111 | if (_E5b_HS == 1.0) {
|
---|
[10577] | 2112 | SVhealth |= (1 << 7);
|
---|
[10587] | 2113 | }
|
---|
| 2114 | else if (_E5b_HS == 2.0) {
|
---|
[10577] | 2115 | SVhealth |= (1 << 8);
|
---|
[10587] | 2116 | }
|
---|
| 2117 | else if (_E5b_HS == 3.0) {
|
---|
[10577] | 2118 | SVhealth |= (1 << 7);
|
---|
| 2119 | SVhealth |= (1 << 8);
|
---|
[6792] | 2120 | }
|
---|
[5539] | 2121 | }
|
---|
[10587] | 2122 | // =====================
|
---|
| 2123 | // BROADCAST ORBIT - 5
|
---|
| 2124 | // =====================
|
---|
[10577] | 2125 | out
|
---|
[10587] | 2126 | << QString(fmt)
|
---|
| 2127 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 2128 | .arg(double(dataSource), 19, 'e', 12)
|
---|
| 2129 | .arg(_TOEweek + 1024.0, 19, 'e', 12)
|
---|
| 2130 | .arg(0.0, 19, 'e', 12);
|
---|
[9788] | 2131 | // =====================
|
---|
| 2132 | // BROADCAST ORBIT - 6
|
---|
| 2133 | // =====================
|
---|
[10577] | 2134 | out
|
---|
[10587] | 2135 | << QString(fmt)
|
---|
| 2136 | .arg(_SISA, 19, 'e', 12)
|
---|
| 2137 | .arg(double(SVhealth), 19, 'e', 12)
|
---|
| 2138 | .arg(BGD_1_5A, 19, 'e', 12)
|
---|
| 2139 | .arg(BGD_1_5B, 19, 'e', 12);
|
---|
[9788] | 2140 | // =====================
|
---|
| 2141 | // BROADCAST ORBIT - 7
|
---|
| 2142 | // =====================
|
---|
[7922] | 2143 | double tot = _TOT;
|
---|
| 2144 | if (tot == 0.9999e9 && version < 3.0) {
|
---|
| 2145 | tot = 0.0;
|
---|
| 2146 | }
|
---|
[10577] | 2147 | out
|
---|
[10587] | 2148 | << QString(fmt)
|
---|
| 2149 | .arg(tot, 19, 'e', 12)
|
---|
| 2150 | .arg("", 19, QChar(' '))
|
---|
| 2151 | .arg("", 19, QChar(' '))
|
---|
| 2152 | .arg("", 19, QChar(' '));
|
---|
[4023] | 2153 |
|
---|
| 2154 | return rnxStr;
|
---|
| 2155 | }
|
---|
| 2156 |
|
---|
[6385] | 2157 | // Constructor
|
---|
| 2158 | //////////////////////////////////////////////////////////////////////////////
|
---|
[10603] | 2159 | t_ephSBAS::t_ephSBAS(double rnxVersion, const QStringList &lines, const QString typeStr) {
|
---|
[6390] | 2160 |
|
---|
[10603] | 2161 | setType(typeStr);
|
---|
| 2162 |
|
---|
[6390] | 2163 | const int nLines = 4;
|
---|
| 2164 |
|
---|
[10587] | 2165 | // Source RINEX version < 4
|
---|
| 2166 | if (type() == t_eph::undefined) {
|
---|
| 2167 | _type = t_eph::SBASL1;
|
---|
| 2168 | }
|
---|
| 2169 |
|
---|
[6390] | 2170 | if (lines.size() != nLines) {
|
---|
[6518] | 2171 | _checkState = bad;
|
---|
[6390] | 2172 | return;
|
---|
| 2173 | }
|
---|
| 2174 |
|
---|
| 2175 | // RINEX Format
|
---|
| 2176 | // ------------
|
---|
| 2177 | int fieldLen = 19;
|
---|
| 2178 |
|
---|
| 2179 | int pos[4];
|
---|
[10577] | 2180 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
[6390] | 2181 | pos[1] = pos[0] + fieldLen;
|
---|
| 2182 | pos[2] = pos[1] + fieldLen;
|
---|
| 2183 | pos[3] = pos[2] + fieldLen;
|
---|
| 2184 |
|
---|
| 2185 | // Read four lines
|
---|
| 2186 | // ---------------
|
---|
| 2187 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 2188 | QString line = lines[iLine];
|
---|
| 2189 |
|
---|
[10577] | 2190 | if (iLine == 0) {
|
---|
[8204] | 2191 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
[6390] | 2192 |
|
---|
[10577] | 2193 | int year, month, day, hour, min;
|
---|
[6390] | 2194 | double sec;
|
---|
[6880] | 2195 |
|
---|
[7139] | 2196 | QString prnStr, n;
|
---|
[6880] | 2197 | in >> prnStr;
|
---|
[7639] | 2198 | if (prnStr.size() == 1 && prnStr[0] == 'S') {
|
---|
[7139] | 2199 | in >> n;
|
---|
| 2200 | prnStr.append(n);
|
---|
[6880] | 2201 | }
|
---|
[6390] | 2202 | if (prnStr.at(0) == 'S') {
|
---|
| 2203 | _prn.set('S', prnStr.mid(1).toInt());
|
---|
[10577] | 2204 | } else {
|
---|
[6390] | 2205 | _prn.set('S', prnStr.toInt());
|
---|
| 2206 | }
|
---|
[10599] | 2207 | _prn.setFlag(type());
|
---|
[6390] | 2208 |
|
---|
[10599] | 2209 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
| 2210 |
|
---|
[10577] | 2211 | if (year < 80) {
|
---|
[6390] | 2212 | year += 2000;
|
---|
[10577] | 2213 | } else if (year < 100) {
|
---|
[6390] | 2214 | year += 1900;
|
---|
| 2215 | }
|
---|
| 2216 |
|
---|
| 2217 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 2218 |
|
---|
[10587] | 2219 | if ( readDbl(line, pos[1], fieldLen, _agf0)
|
---|
[10577] | 2220 | || readDbl(line, pos[2], fieldLen, _agf1)
|
---|
| 2221 | || readDbl(line, pos[3], fieldLen, _TOT)) {
|
---|
[6518] | 2222 | _checkState = bad;
|
---|
[6390] | 2223 | return;
|
---|
| 2224 | }
|
---|
| 2225 | }
|
---|
[9788] | 2226 | // =====================
|
---|
| 2227 | // BROADCAST ORBIT - 1
|
---|
| 2228 | // =====================
|
---|
[10577] | 2229 | else if (iLine == 1) {
|
---|
[10587] | 2230 | if ( readDbl(line, pos[0], fieldLen, _x_pos)
|
---|
| 2231 | || readDbl(line, pos[1], fieldLen, _x_vel)
|
---|
| 2232 | || readDbl(line, pos[2], fieldLen, _x_acc)
|
---|
[10577] | 2233 | || readDbl(line, pos[3], fieldLen, _health)) {
|
---|
[6518] | 2234 | _checkState = bad;
|
---|
[6390] | 2235 | return;
|
---|
| 2236 | }
|
---|
| 2237 | }
|
---|
[9788] | 2238 | // =====================
|
---|
| 2239 | // BROADCAST ORBIT - 2
|
---|
| 2240 | // =====================
|
---|
[10577] | 2241 | else if (iLine == 2) {
|
---|
[10587] | 2242 | if ( readDbl(line, pos[0], fieldLen, _y_pos)
|
---|
| 2243 | || readDbl(line, pos[1], fieldLen, _y_vel)
|
---|
| 2244 | || readDbl(line, pos[2], fieldLen, _y_acc)
|
---|
[10577] | 2245 | || readDbl(line, pos[3], fieldLen, _ura)) {
|
---|
[6518] | 2246 | _checkState = bad;
|
---|
[6390] | 2247 | return;
|
---|
| 2248 | }
|
---|
| 2249 | }
|
---|
[9788] | 2250 | // =====================
|
---|
| 2251 | // BROADCAST ORBIT - 3
|
---|
| 2252 | // =====================
|
---|
[10577] | 2253 | else if (iLine == 3) {
|
---|
[6536] | 2254 | double iodn;
|
---|
[10587] | 2255 | if ( readDbl(line, pos[0], fieldLen, _z_pos)
|
---|
| 2256 | || readDbl(line, pos[1], fieldLen, _z_vel)
|
---|
| 2257 | || readDbl(line, pos[2], fieldLen, _z_acc)
|
---|
[10577] | 2258 | || readDbl(line, pos[3], fieldLen, iodn)) {
|
---|
[6518] | 2259 | _checkState = bad;
|
---|
[6390] | 2260 | return;
|
---|
[6891] | 2261 | } else {
|
---|
[6536] | 2262 | _IODN = int(iodn);
|
---|
[6390] | 2263 | }
|
---|
| 2264 | }
|
---|
| 2265 | }
|
---|
[10577] | 2266 | _x_pos *= 1.e3;
|
---|
| 2267 | _y_pos *= 1.e3;
|
---|
| 2268 | _z_pos *= 1.e3;
|
---|
[10587] | 2269 | _x_vel *= 1.e3;
|
---|
| 2270 | _y_vel *= 1.e3;
|
---|
| 2271 | _z_vel *= 1.e3;
|
---|
| 2272 | _x_acc *= 1.e3;
|
---|
| 2273 | _y_acc *= 1.e3;
|
---|
| 2274 | _z_acc *= 1.e3;
|
---|
[6385] | 2275 | }
|
---|
| 2276 |
|
---|
[7054] | 2277 | // IOD of SBAS Ephemeris (virtual)
|
---|
| 2278 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 2279 |
|
---|
[7169] | 2280 | unsigned int t_ephSBAS::IOD() const {
|
---|
[7054] | 2281 | unsigned char buffer[80];
|
---|
| 2282 | int size = 0;
|
---|
| 2283 | int numbits = 0;
|
---|
| 2284 | long long bitbuffer = 0;
|
---|
| 2285 | unsigned char *startbuffer = buffer;
|
---|
| 2286 |
|
---|
| 2287 | SBASADDBITSFLOAT(30, this->_x_pos, 0.08)
|
---|
| 2288 | SBASADDBITSFLOAT(30, this->_y_pos, 0.08)
|
---|
| 2289 | SBASADDBITSFLOAT(25, this->_z_pos, 0.4)
|
---|
[10587] | 2290 | SBASADDBITSFLOAT(17, this->_x_vel, 0.000625)
|
---|
| 2291 | SBASADDBITSFLOAT(17, this->_y_vel, 0.000625)
|
---|
| 2292 | SBASADDBITSFLOAT(18, this->_z_vel, 0.004)
|
---|
| 2293 | SBASADDBITSFLOAT(10, this->_x_acc, 0.0000125)
|
---|
| 2294 | SBASADDBITSFLOAT(10, this->_y_acc, 0.0000125)
|
---|
| 2295 | SBASADDBITSFLOAT(10, this->_z_acc, 0.0000625)
|
---|
[10577] | 2296 | SBASADDBITSFLOAT(12, this->_agf0,
|
---|
| 2297 | 1.0 / static_cast<double>(1 << 30) / static_cast<double>(1 << 1))
|
---|
| 2298 | SBASADDBITSFLOAT(8, this->_agf1,
|
---|
| 2299 | 1.0 / static_cast<double>(1 << 30) / static_cast<double>(1 << 10))
|
---|
| 2300 | SBASADDBITS(5, 0); // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
|
---|
[7054] | 2301 |
|
---|
| 2302 | return CRC24(size, startbuffer);
|
---|
| 2303 | }
|
---|
| 2304 |
|
---|
[6385] | 2305 | // Compute SBAS Satellite Position (virtual)
|
---|
| 2306 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10577] | 2307 | t_irc t_ephSBAS::position(int GPSweek, double GPSweeks, double *xc,
|
---|
| 2308 | double *vv) const {
|
---|
[6386] | 2309 |
|
---|
| 2310 | bncTime tt(GPSweek, GPSweeks);
|
---|
[10577] | 2311 | double dt = tt - _TOC;
|
---|
[6386] | 2312 |
|
---|
[10587] | 2313 | xc[0] = _x_pos + _x_vel * dt + _x_acc * dt * dt / 2.0;
|
---|
| 2314 | xc[1] = _y_pos + _y_vel * dt + _y_acc * dt * dt / 2.0;
|
---|
| 2315 | xc[2] = _z_pos + _z_vel * dt + _z_acc * dt * dt / 2.0;
|
---|
[6386] | 2316 |
|
---|
[10587] | 2317 | vv[0] = _x_vel + _x_acc * dt;
|
---|
| 2318 | vv[1] = _y_vel + _y_acc * dt;
|
---|
| 2319 | vv[2] = _z_vel + _z_acc * dt;
|
---|
[6386] | 2320 |
|
---|
| 2321 | xc[3] = _agf0 + _agf1 * dt;
|
---|
| 2322 |
|
---|
[8542] | 2323 | xc[4] = _agf1;
|
---|
| 2324 | xc[5] = 0.0;
|
---|
[8483] | 2325 |
|
---|
[6386] | 2326 | return success;
|
---|
[6385] | 2327 | }
|
---|
| 2328 |
|
---|
[9774] | 2329 | // Health status of SBAS Ephemeris (virtual)
|
---|
| 2330 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 2331 | unsigned int t_ephSBAS::isUnhealthy() const {
|
---|
| 2332 |
|
---|
| 2333 | // Bit 5
|
---|
[10577] | 2334 | bool URAindexIs15 = (int(_health) & (1 << 5));
|
---|
[9774] | 2335 | if (URAindexIs15) {
|
---|
| 2336 | // in this case it is recommended
|
---|
| 2337 | // to set the bits 0,1,2,3 to 1 (MT17health = 15)
|
---|
| 2338 | return 1;
|
---|
| 2339 | }
|
---|
| 2340 |
|
---|
| 2341 | // Bit 0-3
|
---|
[10577] | 2342 | int MT17health = (int(_health)) & (0x0f);
|
---|
[9774] | 2343 | if (MT17health) {
|
---|
| 2344 | return 1;
|
---|
| 2345 | }
|
---|
| 2346 |
|
---|
| 2347 | // Bit 4
|
---|
| 2348 | // bool MT17HealthIsUnavailable = (int(_health) & (1<<4));
|
---|
| 2349 | // is not used because the MT17health bits can be independently set if URA index is 15
|
---|
| 2350 |
|
---|
| 2351 | return 0;
|
---|
| 2352 | }
|
---|
| 2353 |
|
---|
[6385] | 2354 | // RINEX Format String
|
---|
| 2355 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6388] | 2356 | QString t_ephSBAS::toString(double version) const {
|
---|
| 2357 |
|
---|
[10587] | 2358 | QString ephStr = typeStr(_type, _prn, version);
|
---|
[10577] | 2359 | QString rnxStr = ephStr + rinexDateStr(_TOC, _prn, version);
|
---|
[6388] | 2360 |
|
---|
| 2361 | QTextStream out(&rnxStr);
|
---|
| 2362 |
|
---|
[10577] | 2363 | out
|
---|
[10587] | 2364 | << QString("%1%2%3\n")
|
---|
| 2365 | .arg(_agf0, 19, 'e', 12)
|
---|
| 2366 | .arg(_agf1, 19, 'e', 12)
|
---|
| 2367 | .arg(_TOT, 19, 'e', 12);
|
---|
[6388] | 2368 |
|
---|
| 2369 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
[9788] | 2370 | // =====================
|
---|
| 2371 | // BROADCAST ORBIT - 1
|
---|
| 2372 | // =====================
|
---|
[10577] | 2373 | out
|
---|
[10587] | 2374 | << QString(fmt)
|
---|
| 2375 | .arg(1.e-3 * _x_pos, 19, 'e', 12)
|
---|
| 2376 | .arg(1.e-3 * _x_vel, 19, 'e', 12)
|
---|
| 2377 | .arg(1.e-3 * _x_acc, 19, 'e', 12)
|
---|
| 2378 | .arg(_health, 19, 'e', 12);
|
---|
[9788] | 2379 | // =====================
|
---|
| 2380 | // BROADCAST ORBIT - 2
|
---|
| 2381 | // =====================
|
---|
[10577] | 2382 | out
|
---|
[10587] | 2383 | << QString(fmt)
|
---|
| 2384 | .arg(1.e-3 * _y_pos, 19, 'e', 12)
|
---|
| 2385 | .arg(1.e-3 * _y_vel, 19, 'e', 12)
|
---|
| 2386 | .arg(1.e-3 * _y_acc, 19, 'e', 12)
|
---|
| 2387 | .arg(_ura, 19, 'e', 12);
|
---|
[9788] | 2388 | // =====================
|
---|
| 2389 | // BROADCAST ORBIT - 3
|
---|
| 2390 | // =====================
|
---|
[10577] | 2391 | out
|
---|
[10587] | 2392 | << QString(fmt)
|
---|
| 2393 | .arg(1.e-3 * _z_pos, 19, 'e', 12)
|
---|
| 2394 | .arg(1.e-3 * _z_vel, 19, 'e', 12)
|
---|
| 2395 | .arg(1.e-3 * _z_acc, 19, 'e', 12)
|
---|
| 2396 | .arg(double(_IODN), 19, 'e', 12);
|
---|
[6388] | 2397 |
|
---|
| 2398 | return rnxStr;
|
---|
[6385] | 2399 | }
|
---|
[6400] | 2400 |
|
---|
| 2401 | // Constructor
|
---|
| 2402 | //////////////////////////////////////////////////////////////////////////////
|
---|
[10603] | 2403 | t_ephBDS::t_ephBDS(double rnxVersion, const QStringList &lines, const QString typeStr) {
|
---|
[6400] | 2404 |
|
---|
[10603] | 2405 | setType(typeStr);
|
---|
| 2406 |
|
---|
[9788] | 2407 | int nLines = 8;
|
---|
[6400] | 2408 |
|
---|
[10587] | 2409 | if (type() == t_eph::CNV1 ||
|
---|
| 2410 | type() == t_eph::CNV2) {
|
---|
[9788] | 2411 | nLines += 2;
|
---|
| 2412 | }
|
---|
[10587] | 2413 | if (type() == t_eph::CNV3) {
|
---|
[9788] | 2414 | nLines += 1;
|
---|
| 2415 | }
|
---|
| 2416 |
|
---|
[6400] | 2417 | if (lines.size() != nLines) {
|
---|
[6518] | 2418 | _checkState = bad;
|
---|
[6400] | 2419 | return;
|
---|
| 2420 | }
|
---|
| 2421 |
|
---|
| 2422 | // RINEX Format
|
---|
| 2423 | // ------------
|
---|
| 2424 | int fieldLen = 19;
|
---|
| 2425 |
|
---|
| 2426 | int pos[4];
|
---|
[10577] | 2427 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
[6400] | 2428 | pos[1] = pos[0] + fieldLen;
|
---|
| 2429 | pos[2] = pos[1] + fieldLen;
|
---|
| 2430 | pos[3] = pos[2] + fieldLen;
|
---|
| 2431 |
|
---|
| 2432 | // Read eight lines
|
---|
| 2433 | // ----------------
|
---|
| 2434 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 2435 | QString line = lines[iLine];
|
---|
| 2436 |
|
---|
[10577] | 2437 | if (iLine == 0) {
|
---|
[8204] | 2438 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
[6400] | 2439 |
|
---|
[10577] | 2440 | int year, month, day, hour, min;
|
---|
[6400] | 2441 | double sec;
|
---|
[6880] | 2442 |
|
---|
[7139] | 2443 | QString prnStr, n;
|
---|
[6880] | 2444 | in >> prnStr;
|
---|
[7639] | 2445 | if (prnStr.size() == 1 && prnStr[0] == 'C') {
|
---|
[7139] | 2446 | in >> n;
|
---|
| 2447 | prnStr.append(n);
|
---|
[6880] | 2448 | }
|
---|
[6400] | 2449 | if (prnStr.at(0) == 'C') {
|
---|
| 2450 | _prn.set('C', prnStr.mid(1).toInt());
|
---|
[10577] | 2451 | } else {
|
---|
[6400] | 2452 | _prn.set('C', prnStr.toInt());
|
---|
| 2453 | }
|
---|
| 2454 |
|
---|
[10599] | 2455 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[10577] | 2456 | if (year < 80) {
|
---|
[6400] | 2457 | year += 2000;
|
---|
[10577] | 2458 | } else if (year < 100) {
|
---|
[6400] | 2459 | year += 1900;
|
---|
| 2460 | }
|
---|
| 2461 |
|
---|
[6812] | 2462 | _TOC.setBDS(year, month, day, hour, min, sec);
|
---|
[6400] | 2463 |
|
---|
[10587] | 2464 | if ( readDbl(line, pos[1], fieldLen, _clock_bias)
|
---|
[10577] | 2465 | || readDbl(line, pos[2], fieldLen, _clock_drift)
|
---|
| 2466 | || readDbl(line, pos[3], fieldLen, _clock_driftrate)) {
|
---|
[6518] | 2467 | _checkState = bad;
|
---|
[6400] | 2468 | return;
|
---|
| 2469 | }
|
---|
| 2470 | }
|
---|
[9788] | 2471 | // =====================
|
---|
| 2472 | // BROADCAST ORBIT - 1
|
---|
| 2473 | // =====================
|
---|
[10577] | 2474 | else if (iLine == 1) {
|
---|
[10587] | 2475 | if (type() == t_eph::D1 ||
|
---|
| 2476 | type() == t_eph::D2 ||
|
---|
| 2477 | type() == t_eph::undefined) {
|
---|
| 2478 | double aode;
|
---|
| 2479 | if ( readDbl(line, pos[0], fieldLen, aode)
|
---|
| 2480 | || readDbl(line, pos[1], fieldLen, _Crs)
|
---|
| 2481 | || readDbl(line, pos[2], fieldLen, _Delta_n)
|
---|
| 2482 | || readDbl(line, pos[3], fieldLen, _M0)) {
|
---|
| 2483 | _checkState = bad;
|
---|
| 2484 | return;
|
---|
| 2485 | }
|
---|
| 2486 | _AODE = int(aode);
|
---|
[6400] | 2487 | }
|
---|
[10587] | 2488 | else { //CNV1, CNV2, CNV3
|
---|
| 2489 | if ( readDbl(line, pos[0], fieldLen, _ADOT)
|
---|
| 2490 | || readDbl(line, pos[1], fieldLen, _Crs)
|
---|
| 2491 | || readDbl(line, pos[2], fieldLen, _Delta_n)
|
---|
| 2492 | || readDbl(line, pos[3], fieldLen, _M0)) {
|
---|
| 2493 | _checkState = bad;
|
---|
| 2494 | return;
|
---|
| 2495 | }
|
---|
| 2496 | }
|
---|
[6400] | 2497 | }
|
---|
[9788] | 2498 | // =====================
|
---|
| 2499 | // BROADCAST ORBIT - 2
|
---|
| 2500 | // =====================
|
---|
[10577] | 2501 | else if (iLine == 2) {
|
---|
[10587] | 2502 | if ( readDbl(line, pos[0], fieldLen, _Cuc)
|
---|
[10577] | 2503 | || readDbl(line, pos[1], fieldLen, _e)
|
---|
| 2504 | || readDbl(line, pos[2], fieldLen, _Cus)
|
---|
| 2505 | || readDbl(line, pos[3], fieldLen, _sqrt_A)) {
|
---|
[6518] | 2506 | _checkState = bad;
|
---|
[6400] | 2507 | return;
|
---|
| 2508 | }
|
---|
| 2509 | }
|
---|
[9788] | 2510 | // =====================
|
---|
| 2511 | // BROADCAST ORBIT - 3
|
---|
| 2512 | // =====================
|
---|
[10577] | 2513 | else if (iLine == 3) {
|
---|
[10587] | 2514 | if ( readDbl(line, pos[0], fieldLen, _TOEsec)
|
---|
[10577] | 2515 | || readDbl(line, pos[1], fieldLen, _Cic)
|
---|
| 2516 | || readDbl(line, pos[2], fieldLen, _OMEGA0)
|
---|
| 2517 | || readDbl(line, pos[3], fieldLen, _Cis)) {
|
---|
[6518] | 2518 | _checkState = bad;
|
---|
[6400] | 2519 | return;
|
---|
| 2520 | }
|
---|
| 2521 | }
|
---|
[9788] | 2522 | // =====================
|
---|
| 2523 | // BROADCAST ORBIT - 4
|
---|
| 2524 | // =====================
|
---|
[10577] | 2525 | else if (iLine == 4) {
|
---|
[10587] | 2526 | if ( readDbl(line, pos[0], fieldLen, _i0)
|
---|
[10577] | 2527 | || readDbl(line, pos[1], fieldLen, _Crc)
|
---|
| 2528 | || readDbl(line, pos[2], fieldLen, _omega)
|
---|
| 2529 | || readDbl(line, pos[3], fieldLen, _OMEGADOT)) {
|
---|
[6518] | 2530 | _checkState = bad;
|
---|
[6400] | 2531 | return;
|
---|
| 2532 | }
|
---|
[10587] | 2533 | else {
|
---|
| 2534 | // Source RINEX version < 4
|
---|
| 2535 | if (type() == t_eph::undefined) {
|
---|
| 2536 | const double iMaxGEO = 10.0 / 180.0 * M_PI;
|
---|
| 2537 | if (_i0 > iMaxGEO) {
|
---|
| 2538 | _type = t_eph::D1;
|
---|
| 2539 | }
|
---|
| 2540 | else {
|
---|
| 2541 | _type = t_eph::D2;
|
---|
| 2542 | }
|
---|
| 2543 | }
|
---|
| 2544 | }
|
---|
[6400] | 2545 | }
|
---|
[9788] | 2546 | // =====================
|
---|
| 2547 | // BROADCAST ORBIT - 5
|
---|
| 2548 | // =====================
|
---|
[10577] | 2549 | else if (iLine == 5) {
|
---|
[10587] | 2550 | if (type() == t_eph::CNV1 ||
|
---|
| 2551 | type() == t_eph::CNV2 ||
|
---|
| 2552 | type() == t_eph::CNV3) {
|
---|
| 2553 | if ( readDbl(line, pos[0], fieldLen, _IDOT)
|
---|
[10577] | 2554 | || readDbl(line, pos[1], fieldLen, _Delta_n_dot)
|
---|
| 2555 | || readDbl(line, pos[2], fieldLen, _satType)
|
---|
| 2556 | || readDbl(line, pos[3], fieldLen, _top)) {
|
---|
[9788] | 2557 | _checkState = bad;
|
---|
| 2558 | return;
|
---|
| 2559 | }
|
---|
[10587] | 2560 | }
|
---|
| 2561 | else { // D1, D2
|
---|
| 2562 | if ( readDbl(line, pos[0], fieldLen, _IDOT)
|
---|
[10577] | 2563 | || readDbl(line, pos[2], fieldLen, _BDTweek)) {
|
---|
[9788] | 2564 | _checkState = bad;
|
---|
| 2565 | return;
|
---|
| 2566 | }
|
---|
| 2567 | }
|
---|
[6400] | 2568 | }
|
---|
[9788] | 2569 | // =====================
|
---|
| 2570 | // BROADCAST ORBIT - 6
|
---|
| 2571 | // =====================
|
---|
[10577] | 2572 | else if (iLine == 6) {
|
---|
[10587] | 2573 | if (type() == t_eph::CNV1 ||
|
---|
| 2574 | type() == t_eph::CNV2 ||
|
---|
| 2575 | type() == t_eph::CNV3) {
|
---|
| 2576 | if ( readDbl(line, pos[0], fieldLen, _SISAI_oe)
|
---|
[10577] | 2577 | || readDbl(line, pos[1], fieldLen, _SISAI_ocb)
|
---|
| 2578 | || readDbl(line, pos[2], fieldLen, _SISAI_oc1)
|
---|
| 2579 | || readDbl(line, pos[3], fieldLen, _SISAI_oc2)) {
|
---|
[9788] | 2580 | _checkState = bad;
|
---|
| 2581 | return;
|
---|
| 2582 | }
|
---|
[10587] | 2583 | }
|
---|
| 2584 | else { // D1, D2
|
---|
[9788] | 2585 | double SatH1;
|
---|
[10587] | 2586 | if ( readDbl(line, pos[0], fieldLen, _ura)
|
---|
[10577] | 2587 | || readDbl(line, pos[1], fieldLen, SatH1)
|
---|
| 2588 | || readDbl(line, pos[2], fieldLen, _TGD1)
|
---|
| 2589 | || readDbl(line, pos[3], fieldLen, _TGD2)) {
|
---|
[9788] | 2590 | _checkState = bad;
|
---|
| 2591 | return;
|
---|
| 2592 | }
|
---|
| 2593 | _SatH1 = int(SatH1);
|
---|
| 2594 | }
|
---|
[6400] | 2595 | }
|
---|
[9788] | 2596 | // =====================
|
---|
| 2597 | // BROADCAST ORBIT - 7
|
---|
| 2598 | // =====================
|
---|
[10577] | 2599 | else if (iLine == 7) {
|
---|
[10587] | 2600 | if (type() == t_eph::CNV1) {
|
---|
| 2601 | if ( readDbl(line, pos[0], fieldLen, _ISC_B1Cd)
|
---|
[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::CNV2) {
|
---|
| 2609 | if ( readDbl(line, pos[1], fieldLen, _ISC_B2ad)
|
---|
[10577] | 2610 | || readDbl(line, pos[2], fieldLen, _TGD_B1Cp)
|
---|
| 2611 | || readDbl(line, pos[3], fieldLen, _TGD_B2ap)) {
|
---|
[9788] | 2612 | _checkState = bad;
|
---|
| 2613 | return;
|
---|
| 2614 | }
|
---|
[10587] | 2615 | }
|
---|
| 2616 | else if (type() == t_eph::CNV3) {
|
---|
[9789] | 2617 | double health;
|
---|
[10587] | 2618 | if ( readDbl(line, pos[0], fieldLen, _SISMAI)
|
---|
[10577] | 2619 | || readDbl(line, pos[1], fieldLen, health)
|
---|
| 2620 | || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B2b)
|
---|
| 2621 | || readDbl(line, pos[3], fieldLen, _TGD_B2bI)) {
|
---|
[9788] | 2622 | _checkState = bad;
|
---|
| 2623 | return;
|
---|
| 2624 | }
|
---|
[9789] | 2625 | _health = int(health);
|
---|
[10587] | 2626 | }
|
---|
| 2627 | else { // D1, D2
|
---|
[9788] | 2628 | double aodc;
|
---|
[10587] | 2629 | if ( readDbl(line, pos[0], fieldLen, _TOT)
|
---|
[10577] | 2630 | || readDbl(line, pos[1], fieldLen, aodc)) {
|
---|
[9788] | 2631 | _checkState = bad;
|
---|
| 2632 | return;
|
---|
| 2633 | }
|
---|
| 2634 | if (_TOT == 0.9999e9) { // 0.9999e9 means not known (RINEX standard)
|
---|
| 2635 | _TOT = _TOEsec;
|
---|
| 2636 | }
|
---|
| 2637 | _AODC = int(aodc);
|
---|
| 2638 | }
|
---|
[6400] | 2639 | }
|
---|
[9788] | 2640 | // =====================
|
---|
| 2641 | // BROADCAST ORBIT - 8
|
---|
| 2642 | // =====================
|
---|
[10577] | 2643 | else if (iLine == 8) {
|
---|
[9789] | 2644 | double health;
|
---|
[10587] | 2645 | if (type() == t_eph::CNV1) {
|
---|
| 2646 | if ( readDbl(line, pos[0], fieldLen, _SISMAI)
|
---|
[10577] | 2647 | || readDbl(line, pos[1], fieldLen, health)
|
---|
| 2648 | || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B1C)
|
---|
| 2649 | || readDbl(line, pos[3], fieldLen, _IODC)) {
|
---|
[9788] | 2650 | _checkState = bad;
|
---|
| 2651 | return;
|
---|
| 2652 | }
|
---|
[9789] | 2653 | _health = int(health);
|
---|
[10587] | 2654 | }
|
---|
| 2655 | else if (type() == t_eph::CNV2) {
|
---|
| 2656 | if ( readDbl(line, pos[0], fieldLen, _SISMAI)
|
---|
[10577] | 2657 | || readDbl(line, pos[1], fieldLen, health)
|
---|
| 2658 | || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B2aB1C)
|
---|
| 2659 | || readDbl(line, pos[3], fieldLen, _IODC)) {
|
---|
[9788] | 2660 | _checkState = bad;
|
---|
| 2661 | return;
|
---|
| 2662 | }
|
---|
[9789] | 2663 | _health = int(health);
|
---|
[10587] | 2664 | }
|
---|
| 2665 | else if (type() == t_eph::CNV3) {
|
---|
[10577] | 2666 | if (readDbl(line, pos[0], fieldLen, _TOT)) {
|
---|
[9788] | 2667 | _checkState = bad;
|
---|
| 2668 | return;
|
---|
| 2669 | }
|
---|
| 2670 | }
|
---|
| 2671 | }
|
---|
| 2672 | // =====================
|
---|
| 2673 | // BROADCAST ORBIT - 9
|
---|
| 2674 | // =====================
|
---|
[10577] | 2675 | else if (iLine == 9) {
|
---|
[10587] | 2676 | if (type() == t_eph::CNV1 ||
|
---|
| 2677 | type() == t_eph::CNV2) {
|
---|
| 2678 | if ( readDbl(line, pos[0], fieldLen, _TOT)
|
---|
[10577] | 2679 | || readDbl(line, pos[3], fieldLen, _IODE)) {
|
---|
[9788] | 2680 | _checkState = bad;
|
---|
| 2681 | return;
|
---|
| 2682 | }
|
---|
| 2683 | }
|
---|
| 2684 | }
|
---|
[6400] | 2685 | }
|
---|
[10599] | 2686 | _prn.setFlag(type());
|
---|
[6400] | 2687 |
|
---|
[10577] | 2688 | _TOE.setBDS(int(_BDTweek), _TOEsec);
|
---|
[6400] | 2689 | // remark: actually should be computed from second_tot
|
---|
| 2690 | // but it seems to be unreliable in RINEX files
|
---|
[6843] | 2691 | //_TOT = _TOC.bdssec();
|
---|
[6400] | 2692 | }
|
---|
| 2693 |
|
---|
[7054] | 2694 | // IOD of BDS Ephemeris (virtual)
|
---|
| 2695 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7169] | 2696 | unsigned int t_ephBDS::IOD() const {
|
---|
[10577] | 2697 | return (int(_TOC.gpssec()) / 720) % 240; //return (int(_TOEsec)/720) % 240;
|
---|
[7054] | 2698 | }
|
---|
| 2699 |
|
---|
[6601] | 2700 | // Compute BDS Satellite Position (virtual)
|
---|
[6400] | 2701 | //////////////////////////////////////////////////////////////////////////////
|
---|
[10577] | 2702 | t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double *xc,
|
---|
| 2703 | double *vv) const {
|
---|
[6400] | 2704 |
|
---|
[10577] | 2705 | static const double gmBDS = 398.6004418e12;
|
---|
[6602] | 2706 | static const double omegaBDS = 7292115.0000e-11;
|
---|
[6400] | 2707 |
|
---|
| 2708 | xc[0] = xc[1] = xc[2] = xc[3] = 0.0;
|
---|
| 2709 | vv[0] = vv[1] = vv[2] = 0.0;
|
---|
| 2710 |
|
---|
| 2711 | bncTime tt(GPSweek, GPSweeks);
|
---|
| 2712 |
|
---|
| 2713 | if (_sqrt_A == 0) {
|
---|
| 2714 | return failure;
|
---|
| 2715 | }
|
---|
| 2716 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 2717 |
|
---|
[10577] | 2718 | double n0 = sqrt(gmBDS / (a0 * a0 * a0));
|
---|
[6400] | 2719 | double tk = tt - _TOE;
|
---|
[10577] | 2720 | double n = n0 + _Delta_n;
|
---|
| 2721 | double M = _M0 + n * tk;
|
---|
| 2722 | double E = M;
|
---|
[6400] | 2723 | double E_last;
|
---|
[10577] | 2724 | int nLoop = 0;
|
---|
[6400] | 2725 | do {
|
---|
| 2726 | E_last = E;
|
---|
[10577] | 2727 | E = M + _e * sin(E);
|
---|
[6400] | 2728 |
|
---|
| 2729 | if (++nLoop == 100) {
|
---|
| 2730 | return failure;
|
---|
| 2731 | }
|
---|
[10577] | 2732 | } while (fabs(E - E_last) * a0 > 0.001);
|
---|
[6400] | 2733 |
|
---|
[10577] | 2734 | double v = atan2(sqrt(1 - _e * _e) * sin(E), cos(E) - _e);
|
---|
| 2735 | double u0 = v + _omega;
|
---|
| 2736 | double sin2u0 = sin(2 * u0);
|
---|
| 2737 | double cos2u0 = cos(2 * u0);
|
---|
| 2738 | double r = a0 * (1 - _e * cos(E)) + _Crc * cos2u0 + _Crs * sin2u0;
|
---|
| 2739 | double i = _i0 + _IDOT * tk + _Cic * cos2u0 + _Cis * sin2u0;
|
---|
| 2740 | double u = u0 + _Cuc * cos2u0 + _Cus * sin2u0;
|
---|
| 2741 | double xp = r * cos(u);
|
---|
| 2742 | double yp = r * sin(u);
|
---|
[6400] | 2743 | double toesec = (_TOE.gpssec() - 14.0);
|
---|
| 2744 | double sinom = 0;
|
---|
| 2745 | double cosom = 0;
|
---|
[10577] | 2746 | double sini = 0;
|
---|
| 2747 | double cosi = 0;
|
---|
[7278] | 2748 |
|
---|
[7481] | 2749 | // Velocity
|
---|
| 2750 | // --------
|
---|
[10577] | 2751 | double tanv2 = tan(v / 2);
|
---|
| 2752 | double dEdM = 1 / (1 - _e * cos(E));
|
---|
| 2753 | double dotv = sqrt((1.0 + _e) / (1.0 - _e)) / cos(E / 2) / cos(E / 2)
|
---|
| 2754 | / (1 + tanv2 * tanv2) * dEdM * n;
|
---|
| 2755 | double dotu = dotv + (-_Cuc * sin2u0 + _Cus * cos2u0) * 2 * dotv;
|
---|
| 2756 | double doti = _IDOT + (-_Cic * sin2u0 + _Cis * cos2u0) * 2 * dotv;
|
---|
| 2757 | double dotr = a0 * _e * sin(E) * dEdM * n
|
---|
| 2758 | + (-_Crc * sin2u0 + _Crs * cos2u0) * 2 * dotv;
|
---|
[7481] | 2759 |
|
---|
[10577] | 2760 | double dotx = dotr * cos(u) - r * sin(u) * dotu;
|
---|
| 2761 | double doty = dotr * sin(u) + r * cos(u) * dotu;
|
---|
[7481] | 2762 |
|
---|
[6400] | 2763 | const double iMaxGEO = 10.0 / 180.0 * M_PI;
|
---|
| 2764 |
|
---|
| 2765 | // MEO/IGSO satellite
|
---|
| 2766 | // ------------------
|
---|
| 2767 | if (_i0 > iMaxGEO) {
|
---|
[10577] | 2768 | double OM = _OMEGA0 + (_OMEGADOT - omegaBDS) * tk - omegaBDS * toesec;
|
---|
[6400] | 2769 |
|
---|
| 2770 | sinom = sin(OM);
|
---|
| 2771 | cosom = cos(OM);
|
---|
[10577] | 2772 | sini = sin(i);
|
---|
| 2773 | cosi = cos(i);
|
---|
[6400] | 2774 |
|
---|
[10577] | 2775 | xc[0] = xp * cosom - yp * cosi * sinom;
|
---|
| 2776 | xc[1] = xp * sinom + yp * cosi * cosom;
|
---|
| 2777 | xc[2] = yp * sini;
|
---|
[7481] | 2778 |
|
---|
| 2779 | // Velocity
|
---|
| 2780 | // --------
|
---|
| 2781 |
|
---|
| 2782 | double dotom = _OMEGADOT - t_CST::omega;
|
---|
| 2783 |
|
---|
[10577] | 2784 | vv[0] = cosom * dotx - cosi * sinom * doty // dX / dr
|
---|
| 2785 | - xp * sinom * dotom - yp * cosi * cosom * dotom // dX / dOMEGA
|
---|
| 2786 | + yp * sini * sinom * doti; // dX / di
|
---|
[7481] | 2787 |
|
---|
[10577] | 2788 | vv[1] = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom
|
---|
| 2789 | - yp * cosi * sinom * dotom - yp * sini * cosom * doti;
|
---|
[7481] | 2790 |
|
---|
[10577] | 2791 | vv[2] = sini * doty + yp * cosi * doti;
|
---|
[7481] | 2792 |
|
---|
[6400] | 2793 | }
|
---|
| 2794 |
|
---|
| 2795 | // GEO satellite
|
---|
| 2796 | // -------------
|
---|
| 2797 | else {
|
---|
[10577] | 2798 | double OM = _OMEGA0 + _OMEGADOT * tk - omegaBDS * toesec;
|
---|
| 2799 | double ll = omegaBDS * tk;
|
---|
[6400] | 2800 |
|
---|
| 2801 | sinom = sin(OM);
|
---|
| 2802 | cosom = cos(OM);
|
---|
[10577] | 2803 | sini = sin(i);
|
---|
| 2804 | cosi = cos(i);
|
---|
[6400] | 2805 |
|
---|
[10577] | 2806 | double xx = xp * cosom - yp * cosi * sinom;
|
---|
| 2807 | double yy = xp * sinom + yp * cosi * cosom;
|
---|
| 2808 | double zz = yp * sini;
|
---|
[6400] | 2809 |
|
---|
[7487] | 2810 | Matrix RX = BNC_PPP::t_astro::rotX(-5.0 / 180.0 * M_PI);
|
---|
| 2811 | Matrix RZ = BNC_PPP::t_astro::rotZ(ll);
|
---|
[6400] | 2812 |
|
---|
[10577] | 2813 | ColumnVector X1(3);
|
---|
| 2814 | X1 << xx << yy << zz;
|
---|
| 2815 | ColumnVector X2 = RZ * RX * X1;
|
---|
[6400] | 2816 |
|
---|
| 2817 | xc[0] = X2(1);
|
---|
| 2818 | xc[1] = X2(2);
|
---|
| 2819 | xc[2] = X2(3);
|
---|
[7278] | 2820 |
|
---|
[7481] | 2821 | double dotom = _OMEGADOT;
|
---|
[6400] | 2822 |
|
---|
[10577] | 2823 | double vx = cosom * dotx - cosi * sinom * doty - xp * sinom * dotom
|
---|
| 2824 | - yp * cosi * cosom * dotom + yp * sini * sinom * doti;
|
---|
[6400] | 2825 |
|
---|
[10577] | 2826 | double vy = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom
|
---|
| 2827 | - yp * cosi * sinom * dotom - yp * sini * cosom * doti;
|
---|
[7278] | 2828 |
|
---|
[10577] | 2829 | double vz = sini * doty + yp * cosi * doti;
|
---|
[6400] | 2830 |
|
---|
[10577] | 2831 | ColumnVector V(3);
|
---|
| 2832 | V << vx << vy << vz;
|
---|
[7481] | 2833 |
|
---|
[10577] | 2834 | Matrix RdotZ(3, 3);
|
---|
[7481] | 2835 | double C = cos(ll);
|
---|
| 2836 | double S = sin(ll);
|
---|
[10577] | 2837 | Matrix UU(3, 3);
|
---|
| 2838 | UU[0][0] = -S;
|
---|
| 2839 | UU[0][1] = +C;
|
---|
| 2840 | UU[0][2] = 0.0;
|
---|
| 2841 | UU[1][0] = -C;
|
---|
| 2842 | UU[1][1] = -S;
|
---|
| 2843 | UU[1][2] = 0.0;
|
---|
| 2844 | UU[2][0] = 0.0;
|
---|
| 2845 | UU[2][1] = 0.0;
|
---|
| 2846 | UU[2][2] = 0.0;
|
---|
[7487] | 2847 | RdotZ = omegaBDS * UU;
|
---|
[7481] | 2848 |
|
---|
| 2849 | ColumnVector VV(3);
|
---|
[10577] | 2850 | VV = RZ * RX * V + RdotZ * RX * X1;
|
---|
[7481] | 2851 |
|
---|
| 2852 | vv[0] = VV(1);
|
---|
| 2853 | vv[1] = VV(2);
|
---|
| 2854 | vv[2] = VV(3);
|
---|
| 2855 | }
|
---|
| 2856 |
|
---|
| 2857 | double tc = tt - _TOC;
|
---|
[10577] | 2858 | xc[3] = _clock_bias + _clock_drift * tc + _clock_driftrate * tc * tc;
|
---|
[7481] | 2859 |
|
---|
[9132] | 2860 | // dotC = _clock_drift + _clock_driftrate*tc
|
---|
[9290] | 2861 | // - 4.442807309e-10*_e * sqrt(a0) * cos(E) * dEdM * n;
|
---|
[6400] | 2862 |
|
---|
[7481] | 2863 | // Relativistic Correction
|
---|
| 2864 | // -----------------------
|
---|
[10577] | 2865 | xc[3] -= 4.442807309e-10 * _e * sqrt(a0) * sin(E);
|
---|
[7481] | 2866 |
|
---|
[10577] | 2867 | xc[4] = _clock_drift + _clock_driftrate * tc;
|
---|
[8542] | 2868 | xc[5] = _clock_driftrate;
|
---|
[9126] | 2869 |
|
---|
[6400] | 2870 | return success;
|
---|
| 2871 | }
|
---|
| 2872 |
|
---|
[9789] | 2873 | // Health status of SBAS Ephemeris (virtual)
|
---|
| 2874 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 2875 | unsigned int t_ephBDS::isUnhealthy() const {
|
---|
| 2876 |
|
---|
[10587] | 2877 | if (type() == t_eph::CNV1 || type() == t_eph::CNV2
|
---|
| 2878 | || type() == t_eph::CNV3) {
|
---|
[9789] | 2879 | return static_cast<unsigned int>(_health);
|
---|
| 2880 | }
|
---|
| 2881 |
|
---|
| 2882 | return static_cast<unsigned int>(_SatH1);
|
---|
| 2883 |
|
---|
| 2884 | }
|
---|
| 2885 |
|
---|
[6400] | 2886 | // RINEX Format String
|
---|
| 2887 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6600] | 2888 | QString t_ephBDS::toString(double version) const {
|
---|
[8419] | 2889 |
|
---|
[10587] | 2890 | if (version < 4.0 &&
|
---|
| 2891 | (type() == t_eph::CNV1 ||
|
---|
| 2892 | type() == t_eph::CNV2 ||
|
---|
| 2893 | type() == t_eph::CNV3 )) {
|
---|
| 2894 | return "";
|
---|
| 2895 | }
|
---|
| 2896 |
|
---|
| 2897 | QString ephStr = typeStr(_type, _prn, version);
|
---|
[10577] | 2898 | QString rnxStr = ephStr + rinexDateStr(_TOC - 14.0, _prn, version);
|
---|
[6400] | 2899 |
|
---|
| 2900 | QTextStream out(&rnxStr);
|
---|
| 2901 |
|
---|
[10577] | 2902 | out
|
---|
[10587] | 2903 | << QString("%1%2%3\n")
|
---|
| 2904 | .arg(_clock_bias, 19, 'e', 12)
|
---|
| 2905 | .arg(_clock_drift, 19, 'e', 12)
|
---|
| 2906 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
[6400] | 2907 |
|
---|
| 2908 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
[9788] | 2909 | // =====================
|
---|
| 2910 | // BROADCAST ORBIT - 1
|
---|
| 2911 | // =====================
|
---|
[10587] | 2912 | if (type() == t_eph::D1 ||
|
---|
| 2913 | type() == t_eph::D2 ||
|
---|
| 2914 | type() == t_eph::undefined) {
|
---|
| 2915 | out
|
---|
| 2916 | << QString(fmt)
|
---|
| 2917 | .arg(double(_AODE), 19, 'e', 12)
|
---|
| 2918 | .arg(_Crs, 19, 'e', 12)
|
---|
| 2919 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 2920 | .arg(_M0, 19, 'e', 12);
|
---|
| 2921 | }
|
---|
| 2922 | else { //CNV1, CNV2, CNV3
|
---|
| 2923 | out
|
---|
| 2924 | << QString(fmt)
|
---|
| 2925 | .arg(_ADOT, 19, 'e', 12)
|
---|
| 2926 | .arg(_Crs, 19, 'e', 12)
|
---|
| 2927 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 2928 | .arg(_M0, 19, 'e', 12);
|
---|
| 2929 | }
|
---|
| 2930 |
|
---|
[9788] | 2931 | // =====================
|
---|
| 2932 | // BROADCAST ORBIT - 2
|
---|
| 2933 | // =====================
|
---|
[10577] | 2934 | out
|
---|
[10587] | 2935 | << QString(fmt)
|
---|
| 2936 | .arg(_Cuc, 19, 'e', 12)
|
---|
| 2937 | .arg(_e, 19, 'e', 12)
|
---|
| 2938 | .arg(_Cus, 19, 'e', 12)
|
---|
| 2939 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
| 2940 |
|
---|
[9788] | 2941 | // =====================
|
---|
| 2942 | // BROADCAST ORBIT - 3
|
---|
| 2943 | // =====================
|
---|
[10577] | 2944 | out
|
---|
[10587] | 2945 | << QString(fmt)
|
---|
| 2946 | .arg(_TOEsec, 19, 'e', 12)
|
---|
| 2947 | .arg(_Cic, 19, 'e', 12)
|
---|
| 2948 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 2949 | .arg(_Cis, 19, 'e', 12);
|
---|
[9788] | 2950 | // =====================
|
---|
| 2951 | // BROADCAST ORBIT - 4
|
---|
| 2952 | // =====================
|
---|
[10577] | 2953 | out
|
---|
[10587] | 2954 | << QString(fmt)
|
---|
| 2955 | .arg(_i0, 19, 'e', 12)
|
---|
| 2956 | .arg(_Crc, 19, 'e', 12)
|
---|
| 2957 | .arg(_omega, 19, 'e', 12)
|
---|
| 2958 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
[9788] | 2959 | // =====================
|
---|
| 2960 | // BROADCAST ORBIT - 5
|
---|
| 2961 | // =====================
|
---|
[10587] | 2962 | if (type() == t_eph::CNV1 ||
|
---|
| 2963 | type() == t_eph::CNV2 ||
|
---|
| 2964 | type() == t_eph::CNV3) {
|
---|
[10577] | 2965 | out
|
---|
[10587] | 2966 | << QString(fmt)
|
---|
| 2967 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 2968 | .arg(_Delta_n_dot, 19, 'e', 12)
|
---|
| 2969 | .arg(_satType, 19, 'e', 12)
|
---|
| 2970 | .arg(_top, 19, 'e', 12);
|
---|
| 2971 | }
|
---|
| 2972 | else { // D1, D2,
|
---|
[10577] | 2973 | out
|
---|
[10587] | 2974 | << QString(fmt)
|
---|
| 2975 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 2976 | .arg("", 19, QChar(' '))
|
---|
| 2977 | .arg(_BDTweek, 19, 'e', 12)
|
---|
| 2978 | .arg("", 19, QChar(' '));
|
---|
[9788] | 2979 | }
|
---|
| 2980 | // =====================
|
---|
| 2981 | // BROADCAST ORBIT - 6
|
---|
| 2982 | // =====================
|
---|
[10587] | 2983 | if (type() == t_eph::CNV1 ||
|
---|
| 2984 | type() == t_eph::CNV2 ||
|
---|
| 2985 | type() == t_eph::CNV3) {
|
---|
[10577] | 2986 | out
|
---|
[10587] | 2987 | << QString(fmt)
|
---|
| 2988 | .arg(_SISAI_oe, 19, 'e', 12)
|
---|
| 2989 | .arg(_SISAI_ocb, 19, 'e', 12)
|
---|
| 2990 | .arg(_SISAI_oc1, 19, 'e', 12)
|
---|
| 2991 | .arg(_SISAI_oc2, 19, 'e', 12);
|
---|
| 2992 | }
|
---|
| 2993 | else { // D1, D2, undefined
|
---|
[10577] | 2994 | out
|
---|
[10587] | 2995 | << QString(fmt)
|
---|
| 2996 | .arg(_ura, 19, 'e', 12)
|
---|
| 2997 | .arg(double(_SatH1), 19, 'e', 12)
|
---|
| 2998 | .arg(_TGD1, 19, 'e', 12)
|
---|
| 2999 | .arg(_TGD2, 19, 'e', 12);
|
---|
[9788] | 3000 | }
|
---|
| 3001 | // =====================
|
---|
| 3002 | // BROADCAST ORBIT - 7
|
---|
| 3003 | // =====================
|
---|
[10587] | 3004 | if (type() == t_eph::CNV1) {
|
---|
[10577] | 3005 | out
|
---|
[10587] | 3006 | << QString(fmt)
|
---|
| 3007 | .arg(_ISC_B1Cd, 19, 'e', 12)
|
---|
| 3008 | .arg("", 19, QChar(' '))
|
---|
| 3009 | .arg(_TGD_B1Cp, 19, 'e', 12)
|
---|
| 3010 | .arg(_TGD_B2ap, 19, 'e', 12);
|
---|
| 3011 | }
|
---|
| 3012 | else if (type() == t_eph::CNV2) {
|
---|
[10577] | 3013 | out
|
---|
[10587] | 3014 | << QString(fmt)
|
---|
| 3015 | .arg("", 19, QChar(' '))
|
---|
| 3016 | .arg(_ISC_B2ad, 19, 'e', 12)
|
---|
| 3017 | .arg(_TGD_B1Cp, 19, 'e', 12)
|
---|
| 3018 | .arg(_TGD_B2ap, 19, 'e', 12);
|
---|
| 3019 | }
|
---|
| 3020 | else if (type() == t_eph::CNV3) {
|
---|
[10577] | 3021 | out
|
---|
[10587] | 3022 | << QString(fmt)
|
---|
| 3023 | .arg(_SISMAI, 19, 'e', 12)
|
---|
| 3024 | .arg(double(_health), 19, 'e', 12)
|
---|
| 3025 | .arg(_INTEGRITYF_B2b, 19, 'e', 12)
|
---|
| 3026 | .arg(_TGD_B2bI, 19, 'e', 12);
|
---|
| 3027 | }
|
---|
| 3028 | else { // D1, D2, undefined
|
---|
[9788] | 3029 | double tots = 0.0;
|
---|
[10577] | 3030 | if (_receptDateTime.isValid()) { // RTCM stream input
|
---|
[9788] | 3031 | tots = _TOE.bdssec();
|
---|
[10577] | 3032 | } else { // RINEX input
|
---|
[9788] | 3033 | tots = _TOT;
|
---|
| 3034 | }
|
---|
[10577] | 3035 | out
|
---|
[10587] | 3036 | << QString(fmt)
|
---|
| 3037 | .arg(tots, 19, 'e', 12)
|
---|
| 3038 | .arg(double(_AODC), 19, 'e', 12)
|
---|
| 3039 | .arg("", 19, QChar(' '))
|
---|
| 3040 | .arg("", 19, QChar(' '));
|
---|
[9788] | 3041 | }
|
---|
[6400] | 3042 |
|
---|
[9788] | 3043 | // =====================
|
---|
| 3044 | // BROADCAST ORBIT - 8
|
---|
| 3045 | // =====================
|
---|
[10587] | 3046 | if (type() == t_eph::CNV1) {
|
---|
[10577] | 3047 | out
|
---|
[10587] | 3048 | << QString(fmt)
|
---|
| 3049 | .arg(_SISMAI, 19, 'e', 12)
|
---|
| 3050 | .arg(double(_health), 19, 'e', 12)
|
---|
| 3051 | .arg(_INTEGRITYF_B1C, 19, 'e', 12)
|
---|
| 3052 | .arg(_IODC, 19, 'e', 12);
|
---|
| 3053 | }
|
---|
| 3054 | else if (type() == t_eph::CNV2) {
|
---|
[10577] | 3055 | out
|
---|
[10587] | 3056 | << QString(fmt)
|
---|
| 3057 | .arg(_SISMAI, 19, 'e', 12)
|
---|
| 3058 | .arg(double(_health), 19, 'e', 12)
|
---|
| 3059 | .arg(_INTEGRITYF_B2aB1C, 19, 'e', 12)
|
---|
| 3060 | .arg(_IODC, 19, 'e', 12);
|
---|
| 3061 | }
|
---|
| 3062 | else if (type() == t_eph::CNV3) {
|
---|
[10577] | 3063 | out
|
---|
[10587] | 3064 | << QString(fmt)
|
---|
| 3065 | .arg(_TOT, 19, 'e', 12)
|
---|
| 3066 | .arg("", 19, QChar(' '))
|
---|
| 3067 | .arg("", 19, QChar(' '))
|
---|
| 3068 | .arg("", 19, QChar(' '));
|
---|
[9788] | 3069 | }
|
---|
[6400] | 3070 |
|
---|
[9788] | 3071 | // =====================
|
---|
| 3072 | // BROADCAST ORBIT - 9
|
---|
| 3073 | // =====================
|
---|
[10587] | 3074 | if (type() == t_eph::CNV1 ||
|
---|
| 3075 | type() == t_eph::CNV2) {
|
---|
[10577] | 3076 | out
|
---|
[10587] | 3077 | << QString(fmt)
|
---|
| 3078 | .arg(_TOT, 19, 'e', 12)
|
---|
| 3079 | .arg("", 19, QChar(' '))
|
---|
| 3080 | .arg("", 19, QChar(' '))
|
---|
| 3081 | .arg(_IODE, 19, 'e', 12);
|
---|
[9788] | 3082 | }
|
---|
[6400] | 3083 |
|
---|
| 3084 | return rnxStr;
|
---|
| 3085 | }
|
---|