[1025] | 1 | #include <sstream>
|
---|
[2234] | 2 | #include <iostream>
|
---|
[1025] | 3 | #include <iomanip>
|
---|
[1239] | 4 | #include <cstring>
|
---|
[1025] | 5 |
|
---|
[2234] | 6 | #include <newmatio.h>
|
---|
| 7 |
|
---|
[1025] | 8 | #include "ephemeris.h"
|
---|
[2221] | 9 | #include "bncutils.h"
|
---|
[2285] | 10 | #include "bnctime.h"
|
---|
[5070] | 11 | #include "bnccore.h"
|
---|
[5839] | 12 | #include "bncutils.h"
|
---|
[6141] | 13 | #include "satObs.h"
|
---|
[6044] | 14 | #include "pppInclude.h"
|
---|
[6400] | 15 | #include "pppModel.h"
|
---|
[1025] | 16 |
|
---|
| 17 | using namespace std;
|
---|
| 18 |
|
---|
[5749] | 19 | // Constructor
|
---|
| 20 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 21 | t_eph::t_eph() {
|
---|
[6518] | 22 | _checkState = unchecked;
|
---|
| 23 | _orbCorr = 0;
|
---|
| 24 | _clkCorr = 0;
|
---|
[5749] | 25 | }
|
---|
[7278] | 26 | // Destructor
|
---|
| 27 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 28 | t_eph::~t_eph() {
|
---|
| 29 | if (_orbCorr)
|
---|
| 30 | delete _orbCorr;
|
---|
| 31 | if (_clkCorr)
|
---|
| 32 | delete _clkCorr;
|
---|
| 33 | }
|
---|
[5749] | 34 |
|
---|
[7481] | 35 | //
|
---|
[5749] | 36 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 37 | void t_eph::setOrbCorr(const t_orbCorr* orbCorr) {
|
---|
[8006] | 38 | if (_orbCorr) {
|
---|
| 39 | delete _orbCorr;
|
---|
| 40 | _orbCorr = 0;
|
---|
| 41 | }
|
---|
[6141] | 42 | _orbCorr = new t_orbCorr(*orbCorr);
|
---|
[5749] | 43 | }
|
---|
| 44 |
|
---|
[7481] | 45 | //
|
---|
[5749] | 46 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 47 | void t_eph::setClkCorr(const t_clkCorr* clkCorr) {
|
---|
[8006] | 48 | if (_clkCorr) {
|
---|
| 49 | delete _clkCorr;
|
---|
| 50 | _clkCorr = 0;
|
---|
| 51 | }
|
---|
[6141] | 52 | _clkCorr = new t_clkCorr(*clkCorr);
|
---|
[5749] | 53 | }
|
---|
| 54 |
|
---|
[7481] | 55 | //
|
---|
[5749] | 56 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6109] | 57 | t_irc t_eph::getCrd(const bncTime& tt, ColumnVector& xc, ColumnVector& vv, bool useCorr) const {
|
---|
[6518] | 58 |
|
---|
[8420] | 59 | if (_checkState == bad ||
|
---|
[8615] | 60 | _checkState == unhealthy ||
|
---|
| 61 | _checkState == outdated) {
|
---|
[6518] | 62 | return failure;
|
---|
| 63 | }
|
---|
[6556] | 64 | const QVector<int> updateInt = QVector<int>() << 1 << 2 << 5 << 10 << 15 << 30
|
---|
| 65 | << 60 << 120 << 240 << 300 << 600
|
---|
| 66 | << 900 << 1800 << 3600 << 7200
|
---|
| 67 | << 10800;
|
---|
[8541] | 68 | xc.ReSize(6);
|
---|
[5749] | 69 | vv.ReSize(3);
|
---|
[6213] | 70 | if (position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data()) != success) {
|
---|
| 71 | return failure;
|
---|
| 72 | }
|
---|
[5789] | 73 | if (useCorr) {
|
---|
[5839] | 74 | if (_orbCorr && _clkCorr) {
|
---|
[5849] | 75 | double dtO = tt - _orbCorr->_time;
|
---|
[6556] | 76 | if (_orbCorr->_updateInt) {
|
---|
| 77 | dtO -= (0.5 * updateInt[_orbCorr->_updateInt]);
|
---|
| 78 | }
|
---|
[5839] | 79 | ColumnVector dx(3);
|
---|
[5849] | 80 | dx[0] = _orbCorr->_xr[0] + _orbCorr->_dotXr[0] * dtO;
|
---|
| 81 | dx[1] = _orbCorr->_xr[1] + _orbCorr->_dotXr[1] * dtO;
|
---|
| 82 | dx[2] = _orbCorr->_xr[2] + _orbCorr->_dotXr[2] * dtO;
|
---|
| 83 |
|
---|
[7133] | 84 | RSW_to_XYZ(xc.Rows(1,3), vv.Rows(1,3), dx, dx);
|
---|
[5849] | 85 |
|
---|
[5839] | 86 | xc[0] -= dx[0];
|
---|
| 87 | xc[1] -= dx[1];
|
---|
| 88 | xc[2] -= dx[2];
|
---|
[5849] | 89 |
|
---|
[7133] | 90 | ColumnVector dv(3);
|
---|
| 91 | RSW_to_XYZ(xc.Rows(1,3), vv.Rows(1,3), _orbCorr->_dotXr, dv);
|
---|
| 92 |
|
---|
| 93 | vv[0] -= dv[0];
|
---|
| 94 | vv[1] -= dv[1];
|
---|
| 95 | vv[2] -= dv[2];
|
---|
| 96 |
|
---|
[5849] | 97 | double dtC = tt - _clkCorr->_time;
|
---|
[6556] | 98 | if (_clkCorr->_updateInt) {
|
---|
| 99 | dtC -= (0.5 * updateInt[_clkCorr->_updateInt]);
|
---|
| 100 | }
|
---|
[7014] | 101 | xc[3] += _clkCorr->_dClk + _clkCorr->_dotDClk * dtC + _clkCorr->_dotDotDClk * dtC * dtC;
|
---|
[5839] | 102 | }
|
---|
| 103 | else {
|
---|
| 104 | return failure;
|
---|
| 105 | }
|
---|
[5749] | 106 | }
|
---|
| 107 | return success;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
[6801] | 110 | //
|
---|
| 111 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 112 | QString t_eph::rinexDateStr(const bncTime& tt, const t_prn& prn, double version) {
|
---|
| 113 | QString prnStr(prn.toString().c_str());
|
---|
| 114 | return rinexDateStr(tt, prnStr, version);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | //
|
---|
| 118 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 119 | QString t_eph::rinexDateStr(const bncTime& tt, const QString& prnStr, double version) {
|
---|
| 120 |
|
---|
| 121 | QString datStr;
|
---|
| 122 |
|
---|
| 123 | unsigned year, month, day, hour, min;
|
---|
| 124 | double sec;
|
---|
| 125 | tt.civil_date(year, month, day);
|
---|
| 126 | tt.civil_time(hour, min, sec);
|
---|
| 127 |
|
---|
| 128 | QTextStream out(&datStr);
|
---|
| 129 |
|
---|
| 130 | if (version < 3.0) {
|
---|
| 131 | QString prnHlp = prnStr.mid(1,2); if (prnHlp[0] == '0') prnHlp[0] = ' ';
|
---|
| 132 | out << prnHlp << QString(" %1 %2 %3 %4 %5%6")
|
---|
| 133 | .arg(year % 100, 2, 10, QChar('0'))
|
---|
| 134 | .arg(month, 2)
|
---|
| 135 | .arg(day, 2)
|
---|
| 136 | .arg(hour, 2)
|
---|
| 137 | .arg(min, 2)
|
---|
| 138 | .arg(sec, 5, 'f',1);
|
---|
| 139 | }
|
---|
| 140 | else {
|
---|
| 141 | out << prnStr << QString(" %1 %2 %3 %4 %5 %6")
|
---|
| 142 | .arg(year, 4)
|
---|
| 143 | .arg(month, 2, 10, QChar('0'))
|
---|
| 144 | .arg(day, 2, 10, QChar('0'))
|
---|
| 145 | .arg(hour, 2, 10, QChar('0'))
|
---|
| 146 | .arg(min, 2, 10, QChar('0'))
|
---|
| 147 | .arg(int(sec), 2, 10, QChar('0'));
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | return datStr;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | // Constructor
|
---|
| 154 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 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 | else if ( iLine == 7 ) {
|
---|
| 301 | if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
|
---|
| 302 | _checkState = bad;
|
---|
| 303 | return;
|
---|
| 304 | }
|
---|
[8926] | 305 | // fitInterval is not valid for IRNSS
|
---|
| 306 | if (type() != t_eph::IRNSS) {
|
---|
| 307 | double fitIntervalRnx;
|
---|
| 308 | readDbl(line, pos[1], fieldLen, fitIntervalRnx);
|
---|
[8932] | 309 | if (type() == t_eph::GPS) { // in RINEX specified allways as time period for GPS
|
---|
[8929] | 310 | _fitInterval = fitIntervalRnx;
|
---|
[8932] | 311 | } else if (type() == t_eph::QZSS) { // specified as flag for QZSS
|
---|
| 312 | if (rnxVersion == 3.02) {
|
---|
| 313 | _fitInterval = fitIntervalRnx; // specified as time period
|
---|
[8929] | 314 | }
|
---|
[8932] | 315 | else {
|
---|
| 316 | _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::QZSS);
|
---|
| 317 | }
|
---|
[8926] | 318 | }
|
---|
| 319 | }
|
---|
[6801] | 320 | }
|
---|
| 321 | }
|
---|
| 322 | }
|
---|
| 323 |
|
---|
[2222] | 324 | // Compute GPS Satellite Position (virtual)
|
---|
[1025] | 325 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6213] | 326 | t_irc t_ephGPS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[1025] | 327 |
|
---|
[1098] | 328 | static const double omegaEarth = 7292115.1467e-11;
|
---|
[5277] | 329 | static const double gmGRS = 398.6005e12;
|
---|
[1025] | 330 |
|
---|
[8541] | 331 | memset(xc, 0, 6*sizeof(double));
|
---|
[1025] | 332 | memset(vv, 0, 3*sizeof(double));
|
---|
| 333 |
|
---|
| 334 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 335 | if (a0 == 0) {
|
---|
[6213] | 336 | return failure;
|
---|
[1025] | 337 | }
|
---|
| 338 |
|
---|
[5277] | 339 | double n0 = sqrt(gmGRS/(a0*a0*a0));
|
---|
[4018] | 340 |
|
---|
| 341 | bncTime tt(GPSweek, GPSweeks);
|
---|
[4543] | 342 | double tk = tt - bncTime(int(_TOEweek), _TOEsec);
|
---|
[4018] | 343 |
|
---|
[1025] | 344 | double n = n0 + _Delta_n;
|
---|
| 345 | double M = _M0 + n*tk;
|
---|
| 346 | double E = M;
|
---|
| 347 | double E_last;
|
---|
[8370] | 348 | int nLoop = 0;
|
---|
[1025] | 349 | do {
|
---|
| 350 | E_last = E;
|
---|
| 351 | E = M + _e*sin(E);
|
---|
[8455] | 352 |
|
---|
[8370] | 353 | if (++nLoop == 100) {
|
---|
| 354 | return failure;
|
---|
| 355 | }
|
---|
[9127] | 356 | } while ( fabs(E-E_last)*a0 > 0.001);
|
---|
[1025] | 357 | double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
|
---|
| 358 | double u0 = v + _omega;
|
---|
| 359 | double sin2u0 = sin(2*u0);
|
---|
| 360 | double cos2u0 = cos(2*u0);
|
---|
| 361 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
| 362 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
| 363 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
| 364 | double xp = r*cos(u);
|
---|
| 365 | double yp = r*sin(u);
|
---|
[7481] | 366 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
|
---|
[4018] | 367 | omegaEarth*_TOEsec;
|
---|
[7278] | 368 |
|
---|
[1025] | 369 | double sinom = sin(OM);
|
---|
| 370 | double cosom = cos(OM);
|
---|
| 371 | double sini = sin(i);
|
---|
| 372 | double cosi = cos(i);
|
---|
| 373 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
| 374 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
[7481] | 375 | xc[2] = yp*sini;
|
---|
| 376 |
|
---|
[4018] | 377 | double tc = tt - _TOC;
|
---|
[2429] | 378 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
[1025] | 379 |
|
---|
| 380 | // Velocity
|
---|
| 381 | // --------
|
---|
| 382 | double tanv2 = tan(v/2);
|
---|
| 383 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
[7278] | 384 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
|
---|
[1025] | 385 | * dEdM * n;
|
---|
| 386 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
| 387 | double dotom = _OMEGADOT - omegaEarth;
|
---|
| 388 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
[7278] | 389 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
[1025] | 390 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
| 391 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
| 392 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
| 393 |
|
---|
| 394 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
| 395 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
| 396 | + yp*sini*sinom*doti; // dX / di
|
---|
| 397 |
|
---|
| 398 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
| 399 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
| 400 | - yp*sini*cosom*doti;
|
---|
| 401 |
|
---|
| 402 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
[2429] | 403 |
|
---|
| 404 | // Relativistic Correction
|
---|
| 405 | // -----------------------
|
---|
[7481] | 406 | // correspondent to IGS convention and GPS ICD (and SSR standard)
|
---|
[9127] | 407 | // xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
|
---|
| 408 | xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
|
---|
| 409 | // correspondent to IGS-SSR
|
---|
[8541] | 410 | xc[4] = _clock_drift + _clock_driftrate*tc;
|
---|
| 411 | xc[5] = _clock_driftrate;
|
---|
| 412 |
|
---|
[6213] | 413 | return success;
|
---|
[1025] | 414 | }
|
---|
| 415 |
|
---|
[6801] | 416 | // RINEX Format String
|
---|
| 417 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 418 | QString t_ephGPS::toString(double version) const {
|
---|
[2221] | 419 |
|
---|
[6801] | 420 | QString rnxStr = rinexDateStr(_TOC, _prn, version);
|
---|
[2221] | 421 |
|
---|
[6801] | 422 | QTextStream out(&rnxStr);
|
---|
[2221] | 423 |
|
---|
[6801] | 424 | out << QString("%1%2%3\n")
|
---|
| 425 | .arg(_clock_bias, 19, 'e', 12)
|
---|
| 426 | .arg(_clock_drift, 19, 'e', 12)
|
---|
| 427 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
[2221] | 428 |
|
---|
[6801] | 429 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
[2221] | 430 |
|
---|
[8167] | 431 | out << QString(fmt)
|
---|
[6801] | 432 | .arg(_IODE, 19, 'e', 12)
|
---|
| 433 | .arg(_Crs, 19, 'e', 12)
|
---|
| 434 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 435 | .arg(_M0, 19, 'e', 12);
|
---|
| 436 |
|
---|
| 437 | out << QString(fmt)
|
---|
| 438 | .arg(_Cuc, 19, 'e', 12)
|
---|
| 439 | .arg(_e, 19, 'e', 12)
|
---|
| 440 | .arg(_Cus, 19, 'e', 12)
|
---|
| 441 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
| 442 |
|
---|
| 443 | out << QString(fmt)
|
---|
| 444 | .arg(_TOEsec, 19, 'e', 12)
|
---|
| 445 | .arg(_Cic, 19, 'e', 12)
|
---|
| 446 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 447 | .arg(_Cis, 19, 'e', 12);
|
---|
| 448 |
|
---|
| 449 | out << QString(fmt)
|
---|
| 450 | .arg(_i0, 19, 'e', 12)
|
---|
| 451 | .arg(_Crc, 19, 'e', 12)
|
---|
| 452 | .arg(_omega, 19, 'e', 12)
|
---|
| 453 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
| 454 |
|
---|
[8167] | 455 | if (type() == t_eph::IRNSS) {
|
---|
| 456 | out << QString(fmt)
|
---|
| 457 | .arg(_IDOT, 19, 'e', 12)
|
---|
[8804] | 458 | .arg(0.0, 19, 'e', 12)
|
---|
[8167] | 459 | .arg(_TOEweek, 19, 'e', 12)
|
---|
[8804] | 460 | .arg(0.0, 19, 'e', 12);
|
---|
[8167] | 461 | }
|
---|
| 462 | else {
|
---|
| 463 | out << QString(fmt)
|
---|
| 464 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 465 | .arg(_L2Codes, 19, 'e', 12)
|
---|
| 466 | .arg(_TOEweek, 19, 'e', 12)
|
---|
| 467 | .arg(_L2PFlag, 19, 'e', 12);
|
---|
| 468 | }
|
---|
[6801] | 469 |
|
---|
[8167] | 470 | if (type() == t_eph::IRNSS) {
|
---|
| 471 | out << QString(fmt)
|
---|
| 472 | .arg(_ura, 19, 'e', 12)
|
---|
| 473 | .arg(_health, 19, 'e', 12)
|
---|
| 474 | .arg(_TGD, 19, 'e', 12)
|
---|
[8804] | 475 | .arg(0.0, 19, 'e', 12);
|
---|
[8167] | 476 | }
|
---|
| 477 | else {
|
---|
| 478 | out << QString(fmt)
|
---|
| 479 | .arg(_ura, 19, 'e', 12)
|
---|
| 480 | .arg(_health, 19, 'e', 12)
|
---|
| 481 | .arg(_TGD, 19, 'e', 12)
|
---|
| 482 | .arg(_IODC, 19, 'e', 12);
|
---|
| 483 | }
|
---|
[6801] | 484 |
|
---|
[7923] | 485 | double tot = _TOT;
|
---|
| 486 | if (tot == 0.9999e9 && version < 3.0) {
|
---|
| 487 | tot = 0.0;
|
---|
| 488 | }
|
---|
[8926] | 489 | // fitInterval
|
---|
[8930] | 490 | if (type() == t_eph::IRNSS) {// not valid for IRNSS
|
---|
[8167] | 491 | out << QString(fmt)
|
---|
| 492 | .arg(tot, 19, 'e', 12)
|
---|
[8804] | 493 | .arg(0.0, 19, 'e', 12)
|
---|
[8167] | 494 | .arg("", 19, QChar(' '))
|
---|
| 495 | .arg("", 19, QChar(' '));
|
---|
| 496 | }
|
---|
| 497 | else {
|
---|
[8932] | 498 | // for GPS and QZSS in version 3.02 specified in hours
|
---|
| 499 | double fitIntervalRnx = _fitInterval;
|
---|
| 500 | // otherwise specified as flag
|
---|
| 501 | if (type() == t_eph::QZSS && version != 3.02) {
|
---|
[8926] | 502 | (_fitInterval == 2.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0;
|
---|
| 503 | }
|
---|
[8167] | 504 | out << QString(fmt)
|
---|
[8926] | 505 | .arg(tot, 19, 'e', 12)
|
---|
| 506 | .arg(fitIntervalRnx, 19, 'e', 12)
|
---|
| 507 | .arg("", 19, QChar(' '))
|
---|
| 508 | .arg("", 19, QChar(' '));
|
---|
[8167] | 509 | }
|
---|
[6801] | 510 | return rnxStr;
|
---|
[2221] | 511 | }
|
---|
| 512 |
|
---|
[6801] | 513 | // Constructor
|
---|
| 514 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 515 | t_ephGlo::t_ephGlo(float rnxVersion, const QStringList& lines) {
|
---|
[2221] | 516 |
|
---|
[6801] | 517 | const int nLines = 4;
|
---|
| 518 |
|
---|
| 519 | if (lines.size() != nLines) {
|
---|
| 520 | _checkState = bad;
|
---|
| 521 | return;
|
---|
[6518] | 522 | }
|
---|
| 523 |
|
---|
[6801] | 524 | // RINEX Format
|
---|
| 525 | // ------------
|
---|
| 526 | int fieldLen = 19;
|
---|
[2221] | 527 |
|
---|
[6801] | 528 | int pos[4];
|
---|
| 529 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 530 | pos[1] = pos[0] + fieldLen;
|
---|
| 531 | pos[2] = pos[1] + fieldLen;
|
---|
| 532 | pos[3] = pos[2] + fieldLen;
|
---|
[2221] | 533 |
|
---|
[6801] | 534 | // Read four lines
|
---|
| 535 | // ---------------
|
---|
| 536 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 537 | QString line = lines[iLine];
|
---|
[2221] | 538 |
|
---|
[6801] | 539 | if ( iLine == 0 ) {
|
---|
| 540 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
[6213] | 541 |
|
---|
[6801] | 542 | int year, month, day, hour, min;
|
---|
| 543 | double sec;
|
---|
[2221] | 544 |
|
---|
[7139] | 545 | QString prnStr, n;
|
---|
[6880] | 546 | in >> prnStr;
|
---|
[7639] | 547 | if (prnStr.size() == 1 && prnStr[0] == 'R') {
|
---|
[7139] | 548 | in >> n;
|
---|
| 549 | prnStr.append(n);
|
---|
[6880] | 550 | }
|
---|
| 551 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[6801] | 552 | if (prnStr.at(0) == 'R') {
|
---|
| 553 | _prn.set('R', prnStr.mid(1).toInt());
|
---|
| 554 | }
|
---|
| 555 | else {
|
---|
| 556 | _prn.set('R', prnStr.toInt());
|
---|
| 557 | }
|
---|
[2221] | 558 |
|
---|
[6801] | 559 | if (year < 80) {
|
---|
| 560 | year += 2000;
|
---|
| 561 | }
|
---|
| 562 | else if (year < 100) {
|
---|
| 563 | year += 1900;
|
---|
| 564 | }
|
---|
[2221] | 565 |
|
---|
[6801] | 566 | _gps_utc = gnumleap(year, month, day);
|
---|
[2221] | 567 |
|
---|
[6801] | 568 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 569 | _TOC = _TOC + _gps_utc;
|
---|
[8804] | 570 | int nd = int((_TOC.gpssec())) / (24.0*60.0*60.0);
|
---|
[6801] | 571 | if ( readDbl(line, pos[1], fieldLen, _tau ) ||
|
---|
| 572 | readDbl(line, pos[2], fieldLen, _gamma) ||
|
---|
| 573 | readDbl(line, pos[3], fieldLen, _tki ) ) {
|
---|
| 574 | _checkState = bad;
|
---|
| 575 | return;
|
---|
| 576 | }
|
---|
[8804] | 577 | _tki -= nd * 86400.0;
|
---|
| 578 | _tau = -_tau;
|
---|
[6801] | 579 | }
|
---|
| 580 |
|
---|
| 581 | else if ( iLine == 1 ) {
|
---|
| 582 | if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
|
---|
| 583 | readDbl(line, pos[1], fieldLen, _x_velocity ) ||
|
---|
| 584 | readDbl(line, pos[2], fieldLen, _x_acceleration) ||
|
---|
| 585 | readDbl(line, pos[3], fieldLen, _health ) ) {
|
---|
| 586 | _checkState = bad;
|
---|
| 587 | return;
|
---|
| 588 | }
|
---|
| 589 | }
|
---|
| 590 |
|
---|
| 591 | else if ( iLine == 2 ) {
|
---|
| 592 | if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
|
---|
| 593 | readDbl(line, pos[1], fieldLen, _y_velocity ) ||
|
---|
| 594 | readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
|
---|
| 595 | readDbl(line, pos[3], fieldLen, _frequency_number) ) {
|
---|
| 596 | _checkState = bad;
|
---|
| 597 | return;
|
---|
| 598 | }
|
---|
| 599 | }
|
---|
| 600 |
|
---|
| 601 | else if ( iLine == 3 ) {
|
---|
| 602 | if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
|
---|
| 603 | readDbl(line, pos[1], fieldLen, _z_velocity ) ||
|
---|
| 604 | readDbl(line, pos[2], fieldLen, _z_acceleration) ||
|
---|
| 605 | readDbl(line, pos[3], fieldLen, _E ) ) {
|
---|
| 606 | _checkState = bad;
|
---|
| 607 | return;
|
---|
| 608 | }
|
---|
| 609 | }
|
---|
| 610 | }
|
---|
| 611 |
|
---|
| 612 | // Initialize status vector
|
---|
| 613 | // ------------------------
|
---|
| 614 | _tt = _TOC;
|
---|
[8697] | 615 | _xv.ReSize(6); _xv = 0.0;
|
---|
[6801] | 616 | _xv(1) = _x_pos * 1.e3;
|
---|
| 617 | _xv(2) = _y_pos * 1.e3;
|
---|
| 618 | _xv(3) = _z_pos * 1.e3;
|
---|
| 619 | _xv(4) = _x_velocity * 1.e3;
|
---|
| 620 | _xv(5) = _y_velocity * 1.e3;
|
---|
| 621 | _xv(6) = _z_velocity * 1.e3;
|
---|
[2221] | 622 | }
|
---|
| 623 |
|
---|
[6801] | 624 | // Compute Glonass Satellite Position (virtual)
|
---|
[2771] | 625 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6801] | 626 | t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[2771] | 627 |
|
---|
[6801] | 628 | static const double nominalStep = 10.0;
|
---|
[2771] | 629 |
|
---|
[8541] | 630 | memset(xc, 0, 6*sizeof(double));
|
---|
[2771] | 631 | memset(vv, 0, 3*sizeof(double));
|
---|
| 632 |
|
---|
[6801] | 633 | double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
|
---|
| 634 |
|
---|
[8690] | 635 | if (fabs(dtPos) > 24 * 3600.0) {
|
---|
[6213] | 636 | return failure;
|
---|
[2771] | 637 | }
|
---|
| 638 |
|
---|
[6801] | 639 | int nSteps = int(fabs(dtPos) / nominalStep) + 1;
|
---|
| 640 | double step = dtPos / nSteps;
|
---|
[4018] | 641 |
|
---|
[6801] | 642 | double acc[3];
|
---|
| 643 | acc[0] = _x_acceleration * 1.e3;
|
---|
| 644 | acc[1] = _y_acceleration * 1.e3;
|
---|
| 645 | acc[2] = _z_acceleration * 1.e3;
|
---|
| 646 | for (int ii = 1; ii <= nSteps; ii++) {
|
---|
| 647 | _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
|
---|
| 648 | _tt = _tt + step;
|
---|
| 649 | }
|
---|
[4018] | 650 |
|
---|
[6801] | 651 | // Position and Velocity
|
---|
| 652 | // ---------------------
|
---|
| 653 | xc[0] = _xv(1);
|
---|
| 654 | xc[1] = _xv(2);
|
---|
| 655 | xc[2] = _xv(3);
|
---|
[2771] | 656 |
|
---|
[6801] | 657 | vv[0] = _xv(4);
|
---|
| 658 | vv[1] = _xv(5);
|
---|
| 659 | vv[2] = _xv(6);
|
---|
[2771] | 660 |
|
---|
[6801] | 661 | // Clock Correction
|
---|
| 662 | // ----------------
|
---|
| 663 | double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
|
---|
| 664 | xc[3] = -_tau + _gamma * dtClk;
|
---|
[2771] | 665 |
|
---|
[8541] | 666 | xc[4] = _gamma;
|
---|
| 667 | xc[5] = 0.0;
|
---|
[8484] | 668 |
|
---|
[6213] | 669 | return success;
|
---|
[2771] | 670 | }
|
---|
| 671 |
|
---|
[6801] | 672 | // RINEX Format String
|
---|
[3659] | 673 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6801] | 674 | QString t_ephGlo::toString(double version) const {
|
---|
[3664] | 675 |
|
---|
[8804] | 676 | QString rnxStr = rinexDateStr(_TOC -_gps_utc, _prn, version);
|
---|
| 677 | int nd = int((_TOC - _gps_utc).gpssec()) / (24.0*60.0*60.0);
|
---|
[6801] | 678 | QTextStream out(&rnxStr);
|
---|
[3664] | 679 |
|
---|
[6801] | 680 | out << QString("%1%2%3\n")
|
---|
[8804] | 681 | .arg(-_tau, 19, 'e', 12)
|
---|
| 682 | .arg(_gamma, 19, 'e', 12)
|
---|
| 683 | .arg(_tki+nd*86400.0, 19, 'e', 12);
|
---|
[3668] | 684 |
|
---|
[6801] | 685 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
[3664] | 686 |
|
---|
[6801] | 687 | out << QString(fmt)
|
---|
| 688 | .arg(_x_pos, 19, 'e', 12)
|
---|
| 689 | .arg(_x_velocity, 19, 'e', 12)
|
---|
| 690 | .arg(_x_acceleration, 19, 'e', 12)
|
---|
| 691 | .arg(_health, 19, 'e', 12);
|
---|
[3664] | 692 |
|
---|
[6801] | 693 | out << QString(fmt)
|
---|
| 694 | .arg(_y_pos, 19, 'e', 12)
|
---|
| 695 | .arg(_y_velocity, 19, 'e', 12)
|
---|
| 696 | .arg(_y_acceleration, 19, 'e', 12)
|
---|
| 697 | .arg(_frequency_number, 19, 'e', 12);
|
---|
[3666] | 698 |
|
---|
[6801] | 699 | out << QString(fmt)
|
---|
| 700 | .arg(_z_pos, 19, 'e', 12)
|
---|
| 701 | .arg(_z_velocity, 19, 'e', 12)
|
---|
| 702 | .arg(_z_acceleration, 19, 'e', 12)
|
---|
| 703 | .arg(_E, 19, 'e', 12);
|
---|
[3666] | 704 |
|
---|
[6801] | 705 | return rnxStr;
|
---|
[3659] | 706 | }
|
---|
| 707 |
|
---|
[6801] | 708 | // Derivative of the state vector using a simple force model (static)
|
---|
| 709 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 710 | ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector& xv,
|
---|
| 711 | double* acc) {
|
---|
[3659] | 712 |
|
---|
[6801] | 713 | // State vector components
|
---|
| 714 | // -----------------------
|
---|
| 715 | ColumnVector rr = xv.rows(1,3);
|
---|
| 716 | ColumnVector vv = xv.rows(4,6);
|
---|
[3699] | 717 |
|
---|
[6801] | 718 | // Acceleration
|
---|
[3699] | 719 | // ------------
|
---|
[6801] | 720 | static const double gmWGS = 398.60044e12;
|
---|
| 721 | static const double AE = 6378136.0;
|
---|
| 722 | static const double OMEGA = 7292115.e-11;
|
---|
| 723 | static const double C20 = -1082.6257e-6;
|
---|
[3699] | 724 |
|
---|
[6801] | 725 | double rho = rr.norm_Frobenius();
|
---|
| 726 | double t1 = -gmWGS/(rho*rho*rho);
|
---|
| 727 | double t2 = 3.0/2.0 * C20 * (gmWGS*AE*AE) / (rho*rho*rho*rho*rho);
|
---|
| 728 | double t3 = OMEGA * OMEGA;
|
---|
| 729 | double t4 = 2.0 * OMEGA;
|
---|
| 730 | double z2 = rr(3) * rr(3);
|
---|
[3699] | 731 |
|
---|
[6801] | 732 | // Vector of derivatives
|
---|
| 733 | // ---------------------
|
---|
| 734 | ColumnVector va(6);
|
---|
| 735 | va(1) = vv(1);
|
---|
| 736 | va(2) = vv(2);
|
---|
| 737 | va(3) = vv(3);
|
---|
| 738 | va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2) + acc[0];
|
---|
| 739 | va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1) + acc[1];
|
---|
| 740 | va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho)) ) * rr(3) + acc[2];
|
---|
[3699] | 741 |
|
---|
[6801] | 742 | return va;
|
---|
| 743 | }
|
---|
[3699] | 744 |
|
---|
[6801] | 745 | // IOD of Glonass Ephemeris (virtual)
|
---|
| 746 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7169] | 747 | unsigned int t_ephGlo::IOD() const {
|
---|
[6801] | 748 | bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
|
---|
[7054] | 749 | return (unsigned long)tMoscow.daysec() / 900;
|
---|
[3659] | 750 | }
|
---|
| 751 |
|
---|
[8188] | 752 | // Health status of Glonass Ephemeris (virtual)
|
---|
| 753 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 754 | unsigned int t_ephGlo::isUnhealthy() const {
|
---|
[8216] | 755 |
|
---|
[8218] | 756 | if (_almanac_health_availablility_indicator) {
|
---|
[8216] | 757 | if ((_health == 0 && _almanac_health == 0) ||
|
---|
| 758 | (_health == 1 && _almanac_health == 0) ||
|
---|
| 759 | (_health == 1 && _almanac_health == 1)) {
|
---|
| 760 | return 1;
|
---|
| 761 | }
|
---|
[8188] | 762 | }
|
---|
[8218] | 763 | else if (!_almanac_health_availablility_indicator) {
|
---|
| 764 | if (_health) {
|
---|
| 765 | return 1;
|
---|
| 766 | }
|
---|
| 767 | }
|
---|
[8216] | 768 | return 0; /* (_health == 0 && _almanac_health == 1) or (_health == 0) */
|
---|
[8188] | 769 | }
|
---|
| 770 |
|
---|
[3659] | 771 | // Constructor
|
---|
| 772 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4891] | 773 | t_ephGal::t_ephGal(float rnxVersion, const QStringList& lines) {
|
---|
[6809] | 774 | int year, month, day, hour, min;
|
---|
| 775 | double sec;
|
---|
| 776 | QString prnStr;
|
---|
[4891] | 777 | const int nLines = 8;
|
---|
| 778 | if (lines.size() != nLines) {
|
---|
[6518] | 779 | _checkState = bad;
|
---|
[4891] | 780 | return;
|
---|
| 781 | }
|
---|
| 782 |
|
---|
| 783 | // RINEX Format
|
---|
| 784 | // ------------
|
---|
| 785 | int fieldLen = 19;
|
---|
[6792] | 786 | double SVhealth = 0.0;
|
---|
| 787 | double datasource = 0.0;
|
---|
[6798] | 788 |
|
---|
[4891] | 789 | int pos[4];
|
---|
| 790 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 791 | pos[1] = pos[0] + fieldLen;
|
---|
| 792 | pos[2] = pos[1] + fieldLen;
|
---|
| 793 | pos[3] = pos[2] + fieldLen;
|
---|
| 794 |
|
---|
| 795 | // Read eight lines
|
---|
| 796 | // ----------------
|
---|
| 797 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 798 | QString line = lines[iLine];
|
---|
| 799 |
|
---|
| 800 | if ( iLine == 0 ) {
|
---|
| 801 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
[7140] | 802 | QString n;
|
---|
[6880] | 803 | in >> prnStr;
|
---|
[7639] | 804 | if (prnStr.size() == 1 && prnStr[0] == 'E') {
|
---|
[7139] | 805 | in >> n;
|
---|
| 806 | prnStr.append(n);
|
---|
[6880] | 807 | }
|
---|
| 808 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[4891] | 809 | if (year < 80) {
|
---|
| 810 | year += 2000;
|
---|
| 811 | }
|
---|
| 812 | else if (year < 100) {
|
---|
| 813 | year += 1900;
|
---|
| 814 | }
|
---|
| 815 |
|
---|
| 816 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 817 |
|
---|
| 818 | if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
|
---|
| 819 | readDbl(line, pos[2], fieldLen, _clock_drift ) ||
|
---|
| 820 | readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
|
---|
[6518] | 821 | _checkState = bad;
|
---|
[4891] | 822 | return;
|
---|
| 823 | }
|
---|
| 824 | }
|
---|
| 825 |
|
---|
| 826 | else if ( iLine == 1 ) {
|
---|
| 827 | if ( readDbl(line, pos[0], fieldLen, _IODnav ) ||
|
---|
| 828 | readDbl(line, pos[1], fieldLen, _Crs ) ||
|
---|
| 829 | readDbl(line, pos[2], fieldLen, _Delta_n) ||
|
---|
| 830 | readDbl(line, pos[3], fieldLen, _M0 ) ) {
|
---|
[6518] | 831 | _checkState = bad;
|
---|
[4891] | 832 | return;
|
---|
| 833 | }
|
---|
| 834 | }
|
---|
| 835 |
|
---|
| 836 | else if ( iLine == 2 ) {
|
---|
| 837 | if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
|
---|
| 838 | readDbl(line, pos[1], fieldLen, _e ) ||
|
---|
| 839 | readDbl(line, pos[2], fieldLen, _Cus ) ||
|
---|
| 840 | readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
|
---|
[6518] | 841 | _checkState = bad;
|
---|
[4891] | 842 | return;
|
---|
| 843 | }
|
---|
| 844 | }
|
---|
| 845 |
|
---|
| 846 | else if ( iLine == 3 ) {
|
---|
| 847 | if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
|
---|
| 848 | readDbl(line, pos[1], fieldLen, _Cic ) ||
|
---|
| 849 | readDbl(line, pos[2], fieldLen, _OMEGA0) ||
|
---|
| 850 | readDbl(line, pos[3], fieldLen, _Cis ) ) {
|
---|
[6518] | 851 | _checkState = bad;
|
---|
[4891] | 852 | return;
|
---|
| 853 | }
|
---|
| 854 | }
|
---|
| 855 |
|
---|
| 856 | else if ( iLine == 4 ) {
|
---|
| 857 | if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
|
---|
| 858 | readDbl(line, pos[1], fieldLen, _Crc ) ||
|
---|
| 859 | readDbl(line, pos[2], fieldLen, _omega ) ||
|
---|
| 860 | readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
|
---|
[6518] | 861 | _checkState = bad;
|
---|
[4891] | 862 | return;
|
---|
| 863 | }
|
---|
| 864 | }
|
---|
| 865 |
|
---|
| 866 | else if ( iLine == 5 ) {
|
---|
[6792] | 867 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
| 868 | readDbl(line, pos[1], fieldLen, datasource) ||
|
---|
| 869 | readDbl(line, pos[2], fieldLen, _TOEweek ) ) {
|
---|
[6518] | 870 | _checkState = bad;
|
---|
[4891] | 871 | return;
|
---|
[6792] | 872 | } else {
|
---|
| 873 | if (int(datasource) & (1<<8)) {
|
---|
[6812] | 874 | _fnav = true;
|
---|
| 875 | _inav = false;
|
---|
[6792] | 876 | } else if (int(datasource) & (1<<9)) {
|
---|
[6812] | 877 | _fnav = false;
|
---|
| 878 | _inav = true;
|
---|
[6792] | 879 | }
|
---|
[6892] | 880 | _TOEweek -= 1024.0;
|
---|
[4891] | 881 | }
|
---|
| 882 | }
|
---|
| 883 |
|
---|
| 884 | else if ( iLine == 6 ) {
|
---|
| 885 | if ( readDbl(line, pos[0], fieldLen, _SISA ) ||
|
---|
[6792] | 886 | readDbl(line, pos[1], fieldLen, SVhealth) ||
|
---|
[4891] | 887 | readDbl(line, pos[2], fieldLen, _BGD_1_5A) ||
|
---|
| 888 | readDbl(line, pos[3], fieldLen, _BGD_1_5B) ) {
|
---|
[6518] | 889 | _checkState = bad;
|
---|
[4891] | 890 | return;
|
---|
[6792] | 891 | } else {
|
---|
| 892 | // Bit 0
|
---|
[6812] | 893 | _e1DataInValid = (int(SVhealth) & (1<<0));
|
---|
[6792] | 894 | // Bit 1-2
|
---|
[6802] | 895 | _E1_bHS = double((int(SVhealth) >> 1) & 0x3);
|
---|
[6792] | 896 | // Bit 3
|
---|
[6812] | 897 | _e5aDataInValid = (int(SVhealth) & (1<<3));
|
---|
[6792] | 898 | // Bit 4-5
|
---|
[6802] | 899 | _E5aHS = double((int(SVhealth) >> 4) & 0x3);
|
---|
[6792] | 900 | // Bit 6
|
---|
[6812] | 901 | _e5bDataInValid = (int(SVhealth) & (1<<6));
|
---|
[6792] | 902 | // Bit 7-8
|
---|
[6802] | 903 | _E5bHS = double((int(SVhealth) >> 7) & 0x3);
|
---|
[6809] | 904 |
|
---|
| 905 | if (prnStr.at(0) == 'E') {
|
---|
[7140] | 906 | _prn.set('E', prnStr.mid(1).toInt(), _inav ? 1 : 0);
|
---|
[6809] | 907 | }
|
---|
[4891] | 908 | }
|
---|
| 909 | }
|
---|
| 910 |
|
---|
| 911 | else if ( iLine == 7 ) {
|
---|
| 912 | if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
|
---|
[6518] | 913 | _checkState = bad;
|
---|
[4891] | 914 | return;
|
---|
| 915 | }
|
---|
| 916 | }
|
---|
| 917 | }
|
---|
[3659] | 918 | }
|
---|
[4013] | 919 |
|
---|
[6801] | 920 | // Compute Galileo Satellite Position (virtual)
|
---|
| 921 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 922 | t_irc t_ephGal::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[4013] | 923 |
|
---|
[6801] | 924 | static const double omegaEarth = 7292115.1467e-11;
|
---|
[8213] | 925 | static const double gmWGS = 398.6004418e12;
|
---|
[4023] | 926 |
|
---|
[8541] | 927 | memset(xc, 0, 6*sizeof(double));
|
---|
[6801] | 928 | memset(vv, 0, 3*sizeof(double));
|
---|
[4023] | 929 |
|
---|
[6801] | 930 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 931 | if (a0 == 0) {
|
---|
| 932 | return failure;
|
---|
| 933 | }
|
---|
[4023] | 934 |
|
---|
[6801] | 935 | double n0 = sqrt(gmWGS/(a0*a0*a0));
|
---|
[4023] | 936 |
|
---|
[6801] | 937 | bncTime tt(GPSweek, GPSweeks);
|
---|
| 938 | double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
|
---|
[4023] | 939 |
|
---|
[6801] | 940 | double n = n0 + _Delta_n;
|
---|
| 941 | double M = _M0 + n*tk;
|
---|
| 942 | double E = M;
|
---|
| 943 | double E_last;
|
---|
[8370] | 944 | int nLoop = 0;
|
---|
[6801] | 945 | do {
|
---|
| 946 | E_last = E;
|
---|
| 947 | E = M + _e*sin(E);
|
---|
[8370] | 948 |
|
---|
| 949 | if (++nLoop == 100) {
|
---|
| 950 | return failure;
|
---|
| 951 | }
|
---|
[6801] | 952 | } while ( fabs(E-E_last)*a0 > 0.001 );
|
---|
| 953 | double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
|
---|
| 954 | double u0 = v + _omega;
|
---|
| 955 | double sin2u0 = sin(2*u0);
|
---|
| 956 | double cos2u0 = cos(2*u0);
|
---|
| 957 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
| 958 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
| 959 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
| 960 | double xp = r*cos(u);
|
---|
| 961 | double yp = r*sin(u);
|
---|
| 962 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
|
---|
| 963 | omegaEarth*_TOEsec;
|
---|
[4023] | 964 |
|
---|
[6801] | 965 | double sinom = sin(OM);
|
---|
| 966 | double cosom = cos(OM);
|
---|
| 967 | double sini = sin(i);
|
---|
| 968 | double cosi = cos(i);
|
---|
| 969 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
| 970 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
| 971 | xc[2] = yp*sini;
|
---|
[4023] | 972 |
|
---|
[6801] | 973 | double tc = tt - _TOC;
|
---|
| 974 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
[4023] | 975 |
|
---|
[6801] | 976 | // Velocity
|
---|
| 977 | // --------
|
---|
| 978 | double tanv2 = tan(v/2);
|
---|
| 979 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
| 980 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
|
---|
| 981 | * dEdM * n;
|
---|
| 982 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
| 983 | double dotom = _OMEGADOT - omegaEarth;
|
---|
| 984 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
| 985 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
| 986 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
| 987 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
| 988 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
[4023] | 989 |
|
---|
[6801] | 990 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
| 991 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
| 992 | + yp*sini*sinom*doti; // dX / di
|
---|
| 993 |
|
---|
| 994 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
| 995 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
| 996 | - yp*sini*cosom*doti;
|
---|
| 997 |
|
---|
| 998 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
| 999 |
|
---|
| 1000 | // Relativistic Correction
|
---|
| 1001 | // -----------------------
|
---|
[7481] | 1002 | // correspondent to Galileo ICD and to SSR standard
|
---|
| 1003 | xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
|
---|
| 1004 | // correspondent to IGS convention
|
---|
| 1005 | //xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
|
---|
[6801] | 1006 |
|
---|
[8541] | 1007 | xc[4] = _clock_drift + _clock_driftrate*tc;
|
---|
| 1008 | xc[5] = _clock_driftrate;
|
---|
| 1009 |
|
---|
[6801] | 1010 | return success;
|
---|
[4023] | 1011 | }
|
---|
| 1012 |
|
---|
[8188] | 1013 | // Health status of Galileo Ephemeris (virtual)
|
---|
| 1014 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1015 | unsigned int t_ephGal::isUnhealthy() const {
|
---|
| 1016 | if (_E5aHS && _E5bHS && _E1_bHS) {
|
---|
| 1017 | return 1;
|
---|
| 1018 | }
|
---|
| 1019 | return 0;
|
---|
| 1020 | }
|
---|
| 1021 |
|
---|
[4023] | 1022 | // RINEX Format String
|
---|
| 1023 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1024 | QString t_ephGal::toString(double version) const {
|
---|
| 1025 |
|
---|
[4029] | 1026 | QString rnxStr = rinexDateStr(_TOC, _prn, version);
|
---|
[4023] | 1027 |
|
---|
| 1028 | QTextStream out(&rnxStr);
|
---|
| 1029 |
|
---|
| 1030 | out << QString("%1%2%3\n")
|
---|
| 1031 | .arg(_clock_bias, 19, 'e', 12)
|
---|
| 1032 | .arg(_clock_drift, 19, 'e', 12)
|
---|
| 1033 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
| 1034 |
|
---|
| 1035 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
| 1036 |
|
---|
| 1037 | out << QString(fmt)
|
---|
| 1038 | .arg(_IODnav, 19, 'e', 12)
|
---|
| 1039 | .arg(_Crs, 19, 'e', 12)
|
---|
| 1040 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 1041 | .arg(_M0, 19, 'e', 12);
|
---|
| 1042 |
|
---|
| 1043 | out << QString(fmt)
|
---|
| 1044 | .arg(_Cuc, 19, 'e', 12)
|
---|
| 1045 | .arg(_e, 19, 'e', 12)
|
---|
| 1046 | .arg(_Cus, 19, 'e', 12)
|
---|
| 1047 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
| 1048 |
|
---|
| 1049 | out << QString(fmt)
|
---|
| 1050 | .arg(_TOEsec, 19, 'e', 12)
|
---|
| 1051 | .arg(_Cic, 19, 'e', 12)
|
---|
| 1052 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 1053 | .arg(_Cis, 19, 'e', 12);
|
---|
| 1054 |
|
---|
| 1055 | out << QString(fmt)
|
---|
| 1056 | .arg(_i0, 19, 'e', 12)
|
---|
| 1057 | .arg(_Crc, 19, 'e', 12)
|
---|
| 1058 | .arg(_omega, 19, 'e', 12)
|
---|
| 1059 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
| 1060 |
|
---|
[6792] | 1061 | int dataSource = 0;
|
---|
| 1062 | int SVhealth = 0;
|
---|
| 1063 | double BGD_1_5A = _BGD_1_5A;
|
---|
| 1064 | double BGD_1_5B = _BGD_1_5B;
|
---|
[6812] | 1065 | if (_fnav) {
|
---|
[6792] | 1066 | dataSource |= (1<<1);
|
---|
| 1067 | dataSource |= (1<<8);
|
---|
| 1068 | BGD_1_5B = 0.0;
|
---|
| 1069 | // SVhealth
|
---|
| 1070 | // Bit 3 : E5a DVS
|
---|
[6812] | 1071 | if (_e5aDataInValid) {
|
---|
[6792] | 1072 | SVhealth |= (1<<3);
|
---|
| 1073 | }
|
---|
| 1074 | // Bit 4-5: E5a HS
|
---|
| 1075 | if (_E5aHS == 1.0) {
|
---|
| 1076 | SVhealth |= (1<<4);
|
---|
| 1077 | }
|
---|
| 1078 | else if (_E5aHS == 2.0) {
|
---|
| 1079 | SVhealth |= (1<<5);
|
---|
| 1080 | }
|
---|
| 1081 | else if (_E5aHS == 3.0) {
|
---|
| 1082 | SVhealth |= (1<<4);
|
---|
| 1083 | SVhealth |= (1<<5);
|
---|
| 1084 | }
|
---|
| 1085 | }
|
---|
[6812] | 1086 | else if(_inav) {
|
---|
[6803] | 1087 | // Bit 2 and 0 are set because from MT1046 the data source cannot be determined
|
---|
| 1088 | // and RNXv3.03 says both can be set if the navigation messages were merged
|
---|
[5539] | 1089 | dataSource |= (1<<0);
|
---|
[6792] | 1090 | dataSource |= (1<<2);
|
---|
[5540] | 1091 | dataSource |= (1<<9);
|
---|
[6792] | 1092 | // SVhealth
|
---|
| 1093 | // Bit 0 : E1-B DVS
|
---|
[6812] | 1094 | if (_e1DataInValid) {
|
---|
[6792] | 1095 | SVhealth |= (1<<0);
|
---|
| 1096 | }
|
---|
| 1097 | // Bit 1-2: E1-B HS
|
---|
| 1098 | if (_E1_bHS == 1.0) {
|
---|
| 1099 | SVhealth |= (1<<1);
|
---|
| 1100 | }
|
---|
| 1101 | else if (_E1_bHS == 2.0) {
|
---|
| 1102 | SVhealth |= (1<<2);
|
---|
| 1103 | }
|
---|
[6803] | 1104 | else if (_E1_bHS == 3.0) {
|
---|
[6792] | 1105 | SVhealth |= (1<<1);
|
---|
| 1106 | SVhealth |= (1<<2);
|
---|
| 1107 | }
|
---|
[6802] | 1108 | // Bit 3 : E5a DVS
|
---|
[6812] | 1109 | if (_e5aDataInValid) {
|
---|
[6802] | 1110 | SVhealth |= (1<<3);
|
---|
| 1111 | }
|
---|
| 1112 | // Bit 4-5: E5a HS
|
---|
| 1113 | if (_E5aHS == 1.0) {
|
---|
| 1114 | SVhealth |= (1<<4);
|
---|
| 1115 | }
|
---|
| 1116 | else if (_E5aHS == 2.0) {
|
---|
| 1117 | SVhealth |= (1<<5);
|
---|
| 1118 | }
|
---|
[6803] | 1119 | else if (_E5aHS == 3.0) {
|
---|
[6802] | 1120 | SVhealth |= (1<<4);
|
---|
| 1121 | SVhealth |= (1<<5);
|
---|
| 1122 | }
|
---|
[6792] | 1123 | // Bit 6 : E5b DVS
|
---|
[6812] | 1124 | if (_e5bDataInValid) {
|
---|
[6792] | 1125 | SVhealth |= (1<<6);
|
---|
| 1126 | }
|
---|
| 1127 | // Bit 7-8: E5b HS
|
---|
| 1128 | if (_E5bHS == 1.0) {
|
---|
| 1129 | SVhealth |= (1<<7);
|
---|
| 1130 | }
|
---|
| 1131 | else if (_E5bHS == 2.0) {
|
---|
| 1132 | SVhealth |= (1<<8);
|
---|
| 1133 | }
|
---|
[6803] | 1134 | else if (_E5bHS == 3.0) {
|
---|
[6792] | 1135 | SVhealth |= (1<<7);
|
---|
| 1136 | SVhealth |= (1<<8);
|
---|
| 1137 | }
|
---|
[5539] | 1138 | }
|
---|
[6792] | 1139 |
|
---|
[4023] | 1140 | out << QString(fmt)
|
---|
[5532] | 1141 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 1142 | .arg(double(dataSource), 19, 'e', 12)
|
---|
[6892] | 1143 | .arg(_TOEweek + 1024.0, 19, 'e', 12)
|
---|
[5532] | 1144 | .arg(0.0, 19, 'e', 12);
|
---|
[4023] | 1145 |
|
---|
| 1146 | out << QString(fmt)
|
---|
[6798] | 1147 | .arg(_SISA, 19, 'e', 12)
|
---|
[6792] | 1148 | .arg(double(SVhealth), 19, 'e', 12)
|
---|
| 1149 | .arg(BGD_1_5A, 19, 'e', 12)
|
---|
| 1150 | .arg(BGD_1_5B, 19, 'e', 12);
|
---|
[4023] | 1151 |
|
---|
[7923] | 1152 | double tot = _TOT;
|
---|
| 1153 | if (tot == 0.9999e9 && version < 3.0) {
|
---|
| 1154 | tot = 0.0;
|
---|
| 1155 | }
|
---|
[4023] | 1156 | out << QString(fmt)
|
---|
[7923] | 1157 | .arg(tot, 19, 'e', 12)
|
---|
[4024] | 1158 | .arg("", 19, QChar(' '))
|
---|
| 1159 | .arg("", 19, QChar(' '))
|
---|
| 1160 | .arg("", 19, QChar(' '));
|
---|
[4023] | 1161 |
|
---|
| 1162 | return rnxStr;
|
---|
| 1163 | }
|
---|
| 1164 |
|
---|
[6385] | 1165 | // Constructor
|
---|
| 1166 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6390] | 1167 | t_ephSBAS::t_ephSBAS(float rnxVersion, const QStringList& lines) {
|
---|
| 1168 |
|
---|
| 1169 | const int nLines = 4;
|
---|
| 1170 |
|
---|
| 1171 | if (lines.size() != nLines) {
|
---|
[6518] | 1172 | _checkState = bad;
|
---|
[6390] | 1173 | return;
|
---|
| 1174 | }
|
---|
| 1175 |
|
---|
| 1176 | // RINEX Format
|
---|
| 1177 | // ------------
|
---|
| 1178 | int fieldLen = 19;
|
---|
| 1179 |
|
---|
| 1180 | int pos[4];
|
---|
| 1181 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 1182 | pos[1] = pos[0] + fieldLen;
|
---|
| 1183 | pos[2] = pos[1] + fieldLen;
|
---|
| 1184 | pos[3] = pos[2] + fieldLen;
|
---|
| 1185 |
|
---|
| 1186 | // Read four lines
|
---|
| 1187 | // ---------------
|
---|
| 1188 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 1189 | QString line = lines[iLine];
|
---|
| 1190 |
|
---|
| 1191 | if ( iLine == 0 ) {
|
---|
| 1192 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
| 1193 |
|
---|
| 1194 | int year, month, day, hour, min;
|
---|
| 1195 | double sec;
|
---|
[6880] | 1196 |
|
---|
[7139] | 1197 | QString prnStr, n;
|
---|
[6880] | 1198 | in >> prnStr;
|
---|
[7639] | 1199 | if (prnStr.size() == 1 && prnStr[0] == 'S') {
|
---|
[7139] | 1200 | in >> n;
|
---|
| 1201 | prnStr.append(n);
|
---|
[6880] | 1202 | }
|
---|
| 1203 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[6390] | 1204 | if (prnStr.at(0) == 'S') {
|
---|
| 1205 | _prn.set('S', prnStr.mid(1).toInt());
|
---|
| 1206 | }
|
---|
| 1207 | else {
|
---|
| 1208 | _prn.set('S', prnStr.toInt());
|
---|
| 1209 | }
|
---|
| 1210 |
|
---|
| 1211 | if (year < 80) {
|
---|
| 1212 | year += 2000;
|
---|
| 1213 | }
|
---|
| 1214 | else if (year < 100) {
|
---|
| 1215 | year += 1900;
|
---|
| 1216 | }
|
---|
| 1217 |
|
---|
| 1218 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 1219 |
|
---|
| 1220 | if ( readDbl(line, pos[1], fieldLen, _agf0 ) ||
|
---|
| 1221 | readDbl(line, pos[2], fieldLen, _agf1 ) ||
|
---|
[8455] | 1222 | readDbl(line, pos[3], fieldLen, _TOT ) ) {
|
---|
[6518] | 1223 | _checkState = bad;
|
---|
[6390] | 1224 | return;
|
---|
| 1225 | }
|
---|
| 1226 | }
|
---|
| 1227 |
|
---|
| 1228 | else if ( iLine == 1 ) {
|
---|
| 1229 | if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
|
---|
| 1230 | readDbl(line, pos[1], fieldLen, _x_velocity ) ||
|
---|
| 1231 | readDbl(line, pos[2], fieldLen, _x_acceleration) ||
|
---|
| 1232 | readDbl(line, pos[3], fieldLen, _health ) ) {
|
---|
[6518] | 1233 | _checkState = bad;
|
---|
[6390] | 1234 | return;
|
---|
| 1235 | }
|
---|
| 1236 | }
|
---|
| 1237 |
|
---|
| 1238 | else if ( iLine == 2 ) {
|
---|
| 1239 | if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
|
---|
| 1240 | readDbl(line, pos[1], fieldLen, _y_velocity ) ||
|
---|
| 1241 | readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
|
---|
| 1242 | readDbl(line, pos[3], fieldLen, _ura ) ) {
|
---|
[6518] | 1243 | _checkState = bad;
|
---|
[6390] | 1244 | return;
|
---|
| 1245 | }
|
---|
| 1246 | }
|
---|
| 1247 |
|
---|
| 1248 | else if ( iLine == 3 ) {
|
---|
[6536] | 1249 | double iodn;
|
---|
[6390] | 1250 | if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
|
---|
| 1251 | readDbl(line, pos[1], fieldLen, _z_velocity ) ||
|
---|
| 1252 | readDbl(line, pos[2], fieldLen, _z_acceleration) ||
|
---|
[6536] | 1253 | readDbl(line, pos[3], fieldLen, iodn ) ) {
|
---|
[6518] | 1254 | _checkState = bad;
|
---|
[6390] | 1255 | return;
|
---|
[6891] | 1256 | } else {
|
---|
[6536] | 1257 | _IODN = int(iodn);
|
---|
[6390] | 1258 | }
|
---|
| 1259 | }
|
---|
| 1260 | }
|
---|
| 1261 |
|
---|
[7278] | 1262 | _x_pos *= 1.e3;
|
---|
| 1263 | _y_pos *= 1.e3;
|
---|
| 1264 | _z_pos *= 1.e3;
|
---|
| 1265 | _x_velocity *= 1.e3;
|
---|
| 1266 | _y_velocity *= 1.e3;
|
---|
| 1267 | _z_velocity *= 1.e3;
|
---|
| 1268 | _x_acceleration *= 1.e3;
|
---|
| 1269 | _y_acceleration *= 1.e3;
|
---|
| 1270 | _z_acceleration *= 1.e3;
|
---|
[6385] | 1271 | }
|
---|
| 1272 |
|
---|
[7054] | 1273 | // IOD of SBAS Ephemeris (virtual)
|
---|
| 1274 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1275 |
|
---|
[7169] | 1276 | unsigned int t_ephSBAS::IOD() const {
|
---|
[7054] | 1277 | unsigned char buffer[80];
|
---|
| 1278 | int size = 0;
|
---|
| 1279 | int numbits = 0;
|
---|
| 1280 | long long bitbuffer = 0;
|
---|
| 1281 | unsigned char *startbuffer = buffer;
|
---|
| 1282 |
|
---|
| 1283 | SBASADDBITSFLOAT(30, this->_x_pos, 0.08)
|
---|
| 1284 | SBASADDBITSFLOAT(30, this->_y_pos, 0.08)
|
---|
| 1285 | SBASADDBITSFLOAT(25, this->_z_pos, 0.4)
|
---|
| 1286 | SBASADDBITSFLOAT(17, this->_x_velocity, 0.000625)
|
---|
| 1287 | SBASADDBITSFLOAT(17, this->_y_velocity, 0.000625)
|
---|
| 1288 | SBASADDBITSFLOAT(18, this->_z_velocity, 0.004)
|
---|
| 1289 | SBASADDBITSFLOAT(10, this->_x_acceleration, 0.0000125)
|
---|
| 1290 | SBASADDBITSFLOAT(10, this->_y_acceleration, 0.0000125)
|
---|
| 1291 | SBASADDBITSFLOAT(10, this->_z_acceleration, 0.0000625)
|
---|
| 1292 | SBASADDBITSFLOAT(12, this->_agf0, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1293 | SBASADDBITSFLOAT(8, this->_agf1, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<10))
|
---|
| 1294 | SBASADDBITS(5,0); // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
|
---|
| 1295 |
|
---|
| 1296 | return CRC24(size, startbuffer);
|
---|
| 1297 | }
|
---|
| 1298 |
|
---|
[6385] | 1299 | // Compute SBAS Satellite Position (virtual)
|
---|
| 1300 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1301 | t_irc t_ephSBAS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[6386] | 1302 |
|
---|
| 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 {
|
---|
[8942] | 1507 | return (int(_TOEsec)/720) % 240;
|
---|
[7054] | 1508 | }
|
---|
| 1509 |
|
---|
[6601] | 1510 | // Compute BDS Satellite Position (virtual)
|
---|
[6400] | 1511 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6600] | 1512 | t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[6400] | 1513 |
|
---|
[6602] | 1514 | static const double gmBDS = 398.6004418e12;
|
---|
| 1515 | static const double omegaBDS = 7292115.0000e-11;
|
---|
[6400] | 1516 |
|
---|
| 1517 | xc[0] = xc[1] = xc[2] = xc[3] = 0.0;
|
---|
| 1518 | vv[0] = vv[1] = vv[2] = 0.0;
|
---|
| 1519 |
|
---|
| 1520 | bncTime tt(GPSweek, GPSweeks);
|
---|
| 1521 |
|
---|
| 1522 | if (_sqrt_A == 0) {
|
---|
| 1523 | return failure;
|
---|
| 1524 | }
|
---|
| 1525 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 1526 |
|
---|
[6602] | 1527 | double n0 = sqrt(gmBDS/(a0*a0*a0));
|
---|
[6400] | 1528 | double tk = tt - _TOE;
|
---|
| 1529 | double n = n0 + _Delta_n;
|
---|
| 1530 | double M = _M0 + n*tk;
|
---|
| 1531 | double E = M;
|
---|
| 1532 | double E_last;
|
---|
| 1533 | int nLoop = 0;
|
---|
| 1534 | do {
|
---|
| 1535 | E_last = E;
|
---|
| 1536 | E = M + _e*sin(E);
|
---|
| 1537 |
|
---|
| 1538 | if (++nLoop == 100) {
|
---|
| 1539 | return failure;
|
---|
| 1540 | }
|
---|
| 1541 | } while ( fabs(E-E_last)*a0 > 0.001 );
|
---|
| 1542 |
|
---|
| 1543 | double v = atan2(sqrt(1-_e*_e) * sin(E), cos(E) - _e);
|
---|
| 1544 | double u0 = v + _omega;
|
---|
| 1545 | double sin2u0 = sin(2*u0);
|
---|
| 1546 | double cos2u0 = cos(2*u0);
|
---|
| 1547 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
| 1548 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
| 1549 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
| 1550 | double xp = r*cos(u);
|
---|
| 1551 | double yp = r*sin(u);
|
---|
| 1552 | double toesec = (_TOE.gpssec() - 14.0);
|
---|
| 1553 | double sinom = 0;
|
---|
| 1554 | double cosom = 0;
|
---|
| 1555 | double sini = 0;
|
---|
| 1556 | double cosi = 0;
|
---|
[7278] | 1557 |
|
---|
[7481] | 1558 | // Velocity
|
---|
| 1559 | // --------
|
---|
| 1560 | double tanv2 = tan(v/2);
|
---|
| 1561 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
| 1562 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2)
|
---|
| 1563 | / (1 + tanv2*tanv2) * dEdM * n;
|
---|
| 1564 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
| 1565 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
| 1566 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
| 1567 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
| 1568 |
|
---|
| 1569 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
| 1570 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
| 1571 |
|
---|
[6400] | 1572 | const double iMaxGEO = 10.0 / 180.0 * M_PI;
|
---|
| 1573 |
|
---|
| 1574 | // MEO/IGSO satellite
|
---|
| 1575 | // ------------------
|
---|
| 1576 | if (_i0 > iMaxGEO) {
|
---|
[6602] | 1577 | double OM = _OMEGA0 + (_OMEGADOT - omegaBDS)*tk - omegaBDS*toesec;
|
---|
[6400] | 1578 |
|
---|
| 1579 | sinom = sin(OM);
|
---|
| 1580 | cosom = cos(OM);
|
---|
| 1581 | sini = sin(i);
|
---|
| 1582 | cosi = cos(i);
|
---|
| 1583 |
|
---|
| 1584 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
| 1585 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
[7278] | 1586 | xc[2] = yp*sini;
|
---|
[7481] | 1587 |
|
---|
| 1588 | // Velocity
|
---|
| 1589 | // --------
|
---|
| 1590 |
|
---|
| 1591 | double dotom = _OMEGADOT - t_CST::omega;
|
---|
| 1592 |
|
---|
| 1593 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
| 1594 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
| 1595 | + yp*sini*sinom*doti; // dX / di
|
---|
| 1596 |
|
---|
| 1597 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
| 1598 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
| 1599 | - yp*sini*cosom*doti;
|
---|
| 1600 |
|
---|
| 1601 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
| 1602 |
|
---|
[6400] | 1603 | }
|
---|
| 1604 |
|
---|
| 1605 | // GEO satellite
|
---|
| 1606 | // -------------
|
---|
| 1607 | else {
|
---|
[6602] | 1608 | double OM = _OMEGA0 + _OMEGADOT*tk - omegaBDS*toesec;
|
---|
| 1609 | double ll = omegaBDS*tk;
|
---|
[6400] | 1610 |
|
---|
| 1611 | sinom = sin(OM);
|
---|
| 1612 | cosom = cos(OM);
|
---|
| 1613 | sini = sin(i);
|
---|
| 1614 | cosi = cos(i);
|
---|
| 1615 |
|
---|
| 1616 | double xx = xp*cosom - yp*cosi*sinom;
|
---|
| 1617 | double yy = xp*sinom + yp*cosi*cosom;
|
---|
[7278] | 1618 | double zz = yp*sini;
|
---|
[6400] | 1619 |
|
---|
[7487] | 1620 | Matrix RX = BNC_PPP::t_astro::rotX(-5.0 / 180.0 * M_PI);
|
---|
| 1621 | Matrix RZ = BNC_PPP::t_astro::rotZ(ll);
|
---|
[6400] | 1622 |
|
---|
| 1623 | ColumnVector X1(3); X1 << xx << yy << zz;
|
---|
[7487] | 1624 | ColumnVector X2 = RZ*RX*X1;
|
---|
[6400] | 1625 |
|
---|
| 1626 | xc[0] = X2(1);
|
---|
| 1627 | xc[1] = X2(2);
|
---|
| 1628 | xc[2] = X2(3);
|
---|
[7278] | 1629 |
|
---|
[7481] | 1630 | double dotom = _OMEGADOT;
|
---|
[6400] | 1631 |
|
---|
[7481] | 1632 | double vx = cosom *dotx - cosi*sinom *doty
|
---|
| 1633 | - xp*sinom*dotom - yp*cosi*cosom*dotom
|
---|
| 1634 | + yp*sini*sinom*doti;
|
---|
[6400] | 1635 |
|
---|
[7481] | 1636 | double vy = sinom *dotx + cosi*cosom *doty
|
---|
| 1637 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
| 1638 | - yp*sini*cosom*doti;
|
---|
[7278] | 1639 |
|
---|
[7501] | 1640 | double vz = sini *doty + yp*cosi *doti;
|
---|
[6400] | 1641 |
|
---|
[7501] | 1642 | ColumnVector V(3); V << vx << vy << vz;
|
---|
[7481] | 1643 |
|
---|
[7487] | 1644 | Matrix RdotZ(3,3);
|
---|
[7481] | 1645 | double C = cos(ll);
|
---|
| 1646 | double S = sin(ll);
|
---|
| 1647 | Matrix UU(3,3);
|
---|
| 1648 | UU[0][0] = -S; UU[0][1] = +C; UU[0][2] = 0.0;
|
---|
| 1649 | UU[1][0] = -C; UU[1][1] = -S; UU[1][2] = 0.0;
|
---|
| 1650 | UU[2][0] = 0.0; UU[2][1] = 0.0; UU[2][2] = 0.0;
|
---|
[7487] | 1651 | RdotZ = omegaBDS * UU;
|
---|
[7481] | 1652 |
|
---|
| 1653 | ColumnVector VV(3);
|
---|
[7487] | 1654 | VV = RZ*RX*V + RdotZ*RX*X1;
|
---|
[7481] | 1655 |
|
---|
| 1656 | vv[0] = VV(1);
|
---|
| 1657 | vv[1] = VV(2);
|
---|
| 1658 | vv[2] = VV(3);
|
---|
| 1659 | }
|
---|
| 1660 |
|
---|
| 1661 | double tc = tt - _TOC;
|
---|
| 1662 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
| 1663 |
|
---|
[7278] | 1664 | // dotC = _clock_drift + _clock_driftrate*tc
|
---|
[6400] | 1665 | // - 4.442807633e-10*_e*sqrt(a0)*cos(E) * dEdM * n;
|
---|
| 1666 |
|
---|
[7481] | 1667 | // Relativistic Correction
|
---|
| 1668 | // -----------------------
|
---|
| 1669 | // correspondent to BDS ICD and to SSR standard
|
---|
[8541] | 1670 | xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
|
---|
[7481] | 1671 | // correspondent to IGS convention
|
---|
| 1672 | // xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
|
---|
| 1673 |
|
---|
[8541] | 1674 | xc[4] = _clock_drift + _clock_driftrate*tc;
|
---|
| 1675 | xc[5] = _clock_driftrate;
|
---|
| 1676 |
|
---|
[6400] | 1677 | return success;
|
---|
| 1678 | }
|
---|
| 1679 |
|
---|
| 1680 | // RINEX Format String
|
---|
| 1681 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6600] | 1682 | QString t_ephBDS::toString(double version) const {
|
---|
[6400] | 1683 |
|
---|
[6812] | 1684 | QString rnxStr = rinexDateStr(_TOC-14.0, _prn, version);
|
---|
[6400] | 1685 |
|
---|
| 1686 | QTextStream out(&rnxStr);
|
---|
| 1687 |
|
---|
| 1688 | out << QString("%1%2%3\n")
|
---|
| 1689 | .arg(_clock_bias, 19, 'e', 12)
|
---|
| 1690 | .arg(_clock_drift, 19, 'e', 12)
|
---|
| 1691 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
| 1692 |
|
---|
| 1693 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
| 1694 |
|
---|
| 1695 | out << QString(fmt)
|
---|
| 1696 | .arg(double(_AODE), 19, 'e', 12)
|
---|
| 1697 | .arg(_Crs, 19, 'e', 12)
|
---|
| 1698 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 1699 | .arg(_M0, 19, 'e', 12);
|
---|
| 1700 |
|
---|
| 1701 | out << QString(fmt)
|
---|
| 1702 | .arg(_Cuc, 19, 'e', 12)
|
---|
| 1703 | .arg(_e, 19, 'e', 12)
|
---|
| 1704 | .arg(_Cus, 19, 'e', 12)
|
---|
| 1705 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
| 1706 |
|
---|
[6843] | 1707 | double toes = 0.0;
|
---|
| 1708 | if (_TOEweek > -1.0) {// RINEX input
|
---|
| 1709 | toes = _TOEsec;
|
---|
| 1710 | }
|
---|
| 1711 | else {// RTCM stream input
|
---|
[6812] | 1712 | toes = _TOE.bdssec();
|
---|
[6755] | 1713 | }
|
---|
[6400] | 1714 | out << QString(fmt)
|
---|
[6843] | 1715 | .arg(toes, 19, 'e', 12)
|
---|
[6755] | 1716 | .arg(_Cic, 19, 'e', 12)
|
---|
| 1717 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 1718 | .arg(_Cis, 19, 'e', 12);
|
---|
[6400] | 1719 |
|
---|
| 1720 | out << QString(fmt)
|
---|
| 1721 | .arg(_i0, 19, 'e', 12)
|
---|
| 1722 | .arg(_Crc, 19, 'e', 12)
|
---|
| 1723 | .arg(_omega, 19, 'e', 12)
|
---|
| 1724 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
| 1725 |
|
---|
[6843] | 1726 | double toew = 0.0;
|
---|
| 1727 | if (_TOEweek > -1.0) {// RINEX input
|
---|
| 1728 | toew = _TOEweek;
|
---|
| 1729 | }
|
---|
| 1730 | else {// RTCM stream input
|
---|
| 1731 | toew = double(_TOE.bdsw());
|
---|
| 1732 | }
|
---|
[6400] | 1733 | out << QString(fmt)
|
---|
[6843] | 1734 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 1735 | .arg(0.0, 19, 'e', 12)
|
---|
| 1736 | .arg(toew, 19, 'e', 12)
|
---|
| 1737 | .arg(0.0, 19, 'e', 12);
|
---|
[6400] | 1738 |
|
---|
| 1739 | out << QString(fmt)
|
---|
[6798] | 1740 | .arg(_URA, 19, 'e', 12)
|
---|
[6400] | 1741 | .arg(double(_SatH1), 19, 'e', 12)
|
---|
| 1742 | .arg(_TGD1, 19, 'e', 12)
|
---|
| 1743 | .arg(_TGD2, 19, 'e', 12);
|
---|
| 1744 |
|
---|
[6843] | 1745 | double tots = 0.0;
|
---|
| 1746 | if (_TOEweek > -1.0) {// RINEX input
|
---|
| 1747 | tots = _TOT;
|
---|
| 1748 | }
|
---|
| 1749 | else {// RTCM stream input
|
---|
[6812] | 1750 | tots = _TOE.bdssec();
|
---|
[6755] | 1751 | }
|
---|
[6400] | 1752 | out << QString(fmt)
|
---|
[6792] | 1753 | .arg(tots, 19, 'e', 12)
|
---|
[6755] | 1754 | .arg(double(_AODC), 19, 'e', 12)
|
---|
| 1755 | .arg("", 19, QChar(' '))
|
---|
| 1756 | .arg("", 19, QChar(' '));
|
---|
[6400] | 1757 | return rnxStr;
|
---|
| 1758 | }
|
---|