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