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