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