[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);
|
---|
[8929] | 309 | if (type() == t_eph::GPS) {
|
---|
| 310 | if (rnxVersion < 3.03) {// specified as flag for GPS
|
---|
| 311 | _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::GPS);
|
---|
| 312 | } else { // specified as time period for GPS since 3.03
|
---|
| 313 | _fitInterval = fitIntervalRnx;
|
---|
| 314 | }
|
---|
[8926] | 315 | } else if (type() == t_eph::QZSS) { // specified as flag for QZSS
|
---|
| 316 | _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::QZSS);
|
---|
| 317 | }
|
---|
| 318 | }
|
---|
[6801] | 319 | }
|
---|
| 320 | }
|
---|
| 321 | }
|
---|
| 322 |
|
---|
[2222] | 323 | // Compute GPS Satellite Position (virtual)
|
---|
[1025] | 324 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6213] | 325 | t_irc t_ephGPS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[1025] | 326 |
|
---|
[1098] | 327 | static const double omegaEarth = 7292115.1467e-11;
|
---|
[5277] | 328 | static const double gmGRS = 398.6005e12;
|
---|
[1025] | 329 |
|
---|
[8541] | 330 | memset(xc, 0, 6*sizeof(double));
|
---|
[1025] | 331 | memset(vv, 0, 3*sizeof(double));
|
---|
| 332 |
|
---|
| 333 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 334 | if (a0 == 0) {
|
---|
[6213] | 335 | return failure;
|
---|
[1025] | 336 | }
|
---|
| 337 |
|
---|
[5277] | 338 | double n0 = sqrt(gmGRS/(a0*a0*a0));
|
---|
[4018] | 339 |
|
---|
| 340 | bncTime tt(GPSweek, GPSweeks);
|
---|
[4543] | 341 | double tk = tt - bncTime(int(_TOEweek), _TOEsec);
|
---|
[4018] | 342 |
|
---|
[1025] | 343 | double n = n0 + _Delta_n;
|
---|
| 344 | double M = _M0 + n*tk;
|
---|
| 345 | double E = M;
|
---|
| 346 | double E_last;
|
---|
[8370] | 347 | int nLoop = 0;
|
---|
[1025] | 348 | do {
|
---|
| 349 | E_last = E;
|
---|
| 350 | E = M + _e*sin(E);
|
---|
[8455] | 351 |
|
---|
[8370] | 352 | if (++nLoop == 100) {
|
---|
| 353 | return failure;
|
---|
| 354 | }
|
---|
[1025] | 355 | } while ( fabs(E-E_last)*a0 > 0.001 );
|
---|
| 356 | double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
|
---|
| 357 | double u0 = v + _omega;
|
---|
| 358 | double sin2u0 = sin(2*u0);
|
---|
| 359 | double cos2u0 = cos(2*u0);
|
---|
| 360 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
| 361 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
| 362 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
| 363 | double xp = r*cos(u);
|
---|
| 364 | double yp = r*sin(u);
|
---|
[7481] | 365 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
|
---|
[4018] | 366 | omegaEarth*_TOEsec;
|
---|
[7278] | 367 |
|
---|
[1025] | 368 | double sinom = sin(OM);
|
---|
| 369 | double cosom = cos(OM);
|
---|
| 370 | double sini = sin(i);
|
---|
| 371 | double cosi = cos(i);
|
---|
| 372 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
| 373 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
[7481] | 374 | xc[2] = yp*sini;
|
---|
| 375 |
|
---|
[4018] | 376 | double tc = tt - _TOC;
|
---|
[2429] | 377 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
[1025] | 378 |
|
---|
| 379 | // Velocity
|
---|
| 380 | // --------
|
---|
| 381 | double tanv2 = tan(v/2);
|
---|
| 382 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
[7278] | 383 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
|
---|
[1025] | 384 | * dEdM * n;
|
---|
| 385 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
| 386 | double dotom = _OMEGADOT - omegaEarth;
|
---|
| 387 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
[7278] | 388 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
[1025] | 389 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
| 390 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
| 391 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
| 392 |
|
---|
| 393 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
| 394 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
| 395 | + yp*sini*sinom*doti; // dX / di
|
---|
| 396 |
|
---|
| 397 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
| 398 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
| 399 | - yp*sini*cosom*doti;
|
---|
| 400 |
|
---|
| 401 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
[2429] | 402 |
|
---|
| 403 | // Relativistic Correction
|
---|
| 404 | // -----------------------
|
---|
[7481] | 405 | // correspondent to IGS convention and GPS ICD (and SSR standard)
|
---|
[2429] | 406 | xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
|
---|
[6213] | 407 |
|
---|
[8541] | 408 | xc[4] = _clock_drift + _clock_driftrate*tc;
|
---|
| 409 | xc[5] = _clock_driftrate;
|
---|
| 410 |
|
---|
[6213] | 411 | return success;
|
---|
[1025] | 412 | }
|
---|
| 413 |
|
---|
[6801] | 414 | // RINEX Format String
|
---|
| 415 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 416 | QString t_ephGPS::toString(double version) const {
|
---|
[2221] | 417 |
|
---|
[6801] | 418 | QString rnxStr = rinexDateStr(_TOC, _prn, version);
|
---|
[2221] | 419 |
|
---|
[6801] | 420 | QTextStream out(&rnxStr);
|
---|
[2221] | 421 |
|
---|
[6801] | 422 | out << QString("%1%2%3\n")
|
---|
| 423 | .arg(_clock_bias, 19, 'e', 12)
|
---|
| 424 | .arg(_clock_drift, 19, 'e', 12)
|
---|
| 425 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
[2221] | 426 |
|
---|
[6801] | 427 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
[2221] | 428 |
|
---|
[8167] | 429 | out << QString(fmt)
|
---|
[6801] | 430 | .arg(_IODE, 19, 'e', 12)
|
---|
| 431 | .arg(_Crs, 19, 'e', 12)
|
---|
| 432 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 433 | .arg(_M0, 19, 'e', 12);
|
---|
| 434 |
|
---|
| 435 | out << QString(fmt)
|
---|
| 436 | .arg(_Cuc, 19, 'e', 12)
|
---|
| 437 | .arg(_e, 19, 'e', 12)
|
---|
| 438 | .arg(_Cus, 19, 'e', 12)
|
---|
| 439 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
| 440 |
|
---|
| 441 | out << QString(fmt)
|
---|
| 442 | .arg(_TOEsec, 19, 'e', 12)
|
---|
| 443 | .arg(_Cic, 19, 'e', 12)
|
---|
| 444 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 445 | .arg(_Cis, 19, 'e', 12);
|
---|
| 446 |
|
---|
| 447 | out << QString(fmt)
|
---|
| 448 | .arg(_i0, 19, 'e', 12)
|
---|
| 449 | .arg(_Crc, 19, 'e', 12)
|
---|
| 450 | .arg(_omega, 19, 'e', 12)
|
---|
| 451 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
| 452 |
|
---|
[8167] | 453 | if (type() == t_eph::IRNSS) {
|
---|
| 454 | out << QString(fmt)
|
---|
| 455 | .arg(_IDOT, 19, 'e', 12)
|
---|
[8804] | 456 | .arg(0.0, 19, 'e', 12)
|
---|
[8167] | 457 | .arg(_TOEweek, 19, 'e', 12)
|
---|
[8804] | 458 | .arg(0.0, 19, 'e', 12);
|
---|
[8167] | 459 | }
|
---|
| 460 | else {
|
---|
| 461 | out << QString(fmt)
|
---|
| 462 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 463 | .arg(_L2Codes, 19, 'e', 12)
|
---|
| 464 | .arg(_TOEweek, 19, 'e', 12)
|
---|
| 465 | .arg(_L2PFlag, 19, 'e', 12);
|
---|
| 466 | }
|
---|
[6801] | 467 |
|
---|
[8167] | 468 | if (type() == t_eph::IRNSS) {
|
---|
| 469 | out << QString(fmt)
|
---|
| 470 | .arg(_ura, 19, 'e', 12)
|
---|
| 471 | .arg(_health, 19, 'e', 12)
|
---|
| 472 | .arg(_TGD, 19, 'e', 12)
|
---|
[8804] | 473 | .arg(0.0, 19, 'e', 12);
|
---|
[8167] | 474 | }
|
---|
| 475 | else {
|
---|
| 476 | out << QString(fmt)
|
---|
| 477 | .arg(_ura, 19, 'e', 12)
|
---|
| 478 | .arg(_health, 19, 'e', 12)
|
---|
| 479 | .arg(_TGD, 19, 'e', 12)
|
---|
| 480 | .arg(_IODC, 19, 'e', 12);
|
---|
| 481 | }
|
---|
[6801] | 482 |
|
---|
[7923] | 483 | double tot = _TOT;
|
---|
| 484 | if (tot == 0.9999e9 && version < 3.0) {
|
---|
| 485 | tot = 0.0;
|
---|
| 486 | }
|
---|
[8926] | 487 | // fitInterval
|
---|
[8930] | 488 | if (type() == t_eph::IRNSS) {// not valid for IRNSS
|
---|
[8167] | 489 | out << QString(fmt)
|
---|
| 490 | .arg(tot, 19, 'e', 12)
|
---|
[8804] | 491 | .arg(0.0, 19, 'e', 12)
|
---|
[8167] | 492 | .arg("", 19, QChar(' '))
|
---|
| 493 | .arg("", 19, QChar(' '));
|
---|
| 494 | }
|
---|
| 495 | else {
|
---|
[8930] | 496 | double fitIntervalRnx;
|
---|
| 497 | if (type() == t_eph::GPS) {
|
---|
| 498 | if (version < 3.03) { // specified as flag)
|
---|
| 499 | (_fitInterval == 4.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0;
|
---|
| 500 | }
|
---|
| 501 | else {
|
---|
| 502 | fitIntervalRnx = _fitInterval; // specified as time period in hours
|
---|
| 503 | }
|
---|
[8929] | 504 | }
|
---|
[8930] | 505 | else if (type() == t_eph::QZSS) { // specified as flag
|
---|
[8926] | 506 | (_fitInterval == 2.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0;
|
---|
| 507 | }
|
---|
[8167] | 508 | out << QString(fmt)
|
---|
[8926] | 509 | .arg(tot, 19, 'e', 12)
|
---|
| 510 | .arg(fitIntervalRnx, 19, 'e', 12)
|
---|
| 511 | .arg("", 19, QChar(' '))
|
---|
| 512 | .arg("", 19, QChar(' '));
|
---|
[8167] | 513 | }
|
---|
[6801] | 514 |
|
---|
| 515 | return rnxStr;
|
---|
[2221] | 516 | }
|
---|
| 517 |
|
---|
[6801] | 518 | // Constructor
|
---|
| 519 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 520 | t_ephGlo::t_ephGlo(float rnxVersion, const QStringList& lines) {
|
---|
[2221] | 521 |
|
---|
[6801] | 522 | const int nLines = 4;
|
---|
| 523 |
|
---|
| 524 | if (lines.size() != nLines) {
|
---|
| 525 | _checkState = bad;
|
---|
| 526 | return;
|
---|
[6518] | 527 | }
|
---|
| 528 |
|
---|
[6801] | 529 | // RINEX Format
|
---|
| 530 | // ------------
|
---|
| 531 | int fieldLen = 19;
|
---|
[2221] | 532 |
|
---|
[6801] | 533 | int pos[4];
|
---|
| 534 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 535 | pos[1] = pos[0] + fieldLen;
|
---|
| 536 | pos[2] = pos[1] + fieldLen;
|
---|
| 537 | pos[3] = pos[2] + fieldLen;
|
---|
[2221] | 538 |
|
---|
[6801] | 539 | // Read four lines
|
---|
| 540 | // ---------------
|
---|
| 541 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 542 | QString line = lines[iLine];
|
---|
[2221] | 543 |
|
---|
[6801] | 544 | if ( iLine == 0 ) {
|
---|
| 545 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
[6213] | 546 |
|
---|
[6801] | 547 | int year, month, day, hour, min;
|
---|
| 548 | double sec;
|
---|
[2221] | 549 |
|
---|
[7139] | 550 | QString prnStr, n;
|
---|
[6880] | 551 | in >> prnStr;
|
---|
[7639] | 552 | if (prnStr.size() == 1 && prnStr[0] == 'R') {
|
---|
[7139] | 553 | in >> n;
|
---|
| 554 | prnStr.append(n);
|
---|
[6880] | 555 | }
|
---|
| 556 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[6801] | 557 | if (prnStr.at(0) == 'R') {
|
---|
| 558 | _prn.set('R', prnStr.mid(1).toInt());
|
---|
| 559 | }
|
---|
| 560 | else {
|
---|
| 561 | _prn.set('R', prnStr.toInt());
|
---|
| 562 | }
|
---|
[2221] | 563 |
|
---|
[6801] | 564 | if (year < 80) {
|
---|
| 565 | year += 2000;
|
---|
| 566 | }
|
---|
| 567 | else if (year < 100) {
|
---|
| 568 | year += 1900;
|
---|
| 569 | }
|
---|
[2221] | 570 |
|
---|
[6801] | 571 | _gps_utc = gnumleap(year, month, day);
|
---|
[2221] | 572 |
|
---|
[6801] | 573 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 574 | _TOC = _TOC + _gps_utc;
|
---|
[8804] | 575 | int nd = int((_TOC.gpssec())) / (24.0*60.0*60.0);
|
---|
[6801] | 576 | if ( readDbl(line, pos[1], fieldLen, _tau ) ||
|
---|
| 577 | readDbl(line, pos[2], fieldLen, _gamma) ||
|
---|
| 578 | readDbl(line, pos[3], fieldLen, _tki ) ) {
|
---|
| 579 | _checkState = bad;
|
---|
| 580 | return;
|
---|
| 581 | }
|
---|
[8804] | 582 | _tki -= nd * 86400.0;
|
---|
| 583 | _tau = -_tau;
|
---|
[6801] | 584 | }
|
---|
| 585 |
|
---|
| 586 | else if ( iLine == 1 ) {
|
---|
| 587 | if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
|
---|
| 588 | readDbl(line, pos[1], fieldLen, _x_velocity ) ||
|
---|
| 589 | readDbl(line, pos[2], fieldLen, _x_acceleration) ||
|
---|
| 590 | readDbl(line, pos[3], fieldLen, _health ) ) {
|
---|
| 591 | _checkState = bad;
|
---|
| 592 | return;
|
---|
| 593 | }
|
---|
| 594 | }
|
---|
| 595 |
|
---|
| 596 | else if ( iLine == 2 ) {
|
---|
| 597 | if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
|
---|
| 598 | readDbl(line, pos[1], fieldLen, _y_velocity ) ||
|
---|
| 599 | readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
|
---|
| 600 | readDbl(line, pos[3], fieldLen, _frequency_number) ) {
|
---|
| 601 | _checkState = bad;
|
---|
| 602 | return;
|
---|
| 603 | }
|
---|
| 604 | }
|
---|
| 605 |
|
---|
| 606 | else if ( iLine == 3 ) {
|
---|
| 607 | if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
|
---|
| 608 | readDbl(line, pos[1], fieldLen, _z_velocity ) ||
|
---|
| 609 | readDbl(line, pos[2], fieldLen, _z_acceleration) ||
|
---|
| 610 | readDbl(line, pos[3], fieldLen, _E ) ) {
|
---|
| 611 | _checkState = bad;
|
---|
| 612 | return;
|
---|
| 613 | }
|
---|
| 614 | }
|
---|
| 615 | }
|
---|
| 616 |
|
---|
| 617 | // Initialize status vector
|
---|
| 618 | // ------------------------
|
---|
| 619 | _tt = _TOC;
|
---|
[8697] | 620 | _xv.ReSize(6); _xv = 0.0;
|
---|
[6801] | 621 | _xv(1) = _x_pos * 1.e3;
|
---|
| 622 | _xv(2) = _y_pos * 1.e3;
|
---|
| 623 | _xv(3) = _z_pos * 1.e3;
|
---|
| 624 | _xv(4) = _x_velocity * 1.e3;
|
---|
| 625 | _xv(5) = _y_velocity * 1.e3;
|
---|
| 626 | _xv(6) = _z_velocity * 1.e3;
|
---|
[2221] | 627 | }
|
---|
| 628 |
|
---|
[6801] | 629 | // Compute Glonass Satellite Position (virtual)
|
---|
[2771] | 630 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6801] | 631 | t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[2771] | 632 |
|
---|
[6801] | 633 | static const double nominalStep = 10.0;
|
---|
[2771] | 634 |
|
---|
[8541] | 635 | memset(xc, 0, 6*sizeof(double));
|
---|
[2771] | 636 | memset(vv, 0, 3*sizeof(double));
|
---|
| 637 |
|
---|
[6801] | 638 | double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
|
---|
| 639 |
|
---|
[8690] | 640 | if (fabs(dtPos) > 24 * 3600.0) {
|
---|
[6213] | 641 | return failure;
|
---|
[2771] | 642 | }
|
---|
| 643 |
|
---|
[6801] | 644 | int nSteps = int(fabs(dtPos) / nominalStep) + 1;
|
---|
| 645 | double step = dtPos / nSteps;
|
---|
[4018] | 646 |
|
---|
[6801] | 647 | double acc[3];
|
---|
| 648 | acc[0] = _x_acceleration * 1.e3;
|
---|
| 649 | acc[1] = _y_acceleration * 1.e3;
|
---|
| 650 | acc[2] = _z_acceleration * 1.e3;
|
---|
| 651 | for (int ii = 1; ii <= nSteps; ii++) {
|
---|
| 652 | _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
|
---|
| 653 | _tt = _tt + step;
|
---|
| 654 | }
|
---|
[4018] | 655 |
|
---|
[6801] | 656 | // Position and Velocity
|
---|
| 657 | // ---------------------
|
---|
| 658 | xc[0] = _xv(1);
|
---|
| 659 | xc[1] = _xv(2);
|
---|
| 660 | xc[2] = _xv(3);
|
---|
[2771] | 661 |
|
---|
[6801] | 662 | vv[0] = _xv(4);
|
---|
| 663 | vv[1] = _xv(5);
|
---|
| 664 | vv[2] = _xv(6);
|
---|
[2771] | 665 |
|
---|
[6801] | 666 | // Clock Correction
|
---|
| 667 | // ----------------
|
---|
| 668 | double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
|
---|
| 669 | xc[3] = -_tau + _gamma * dtClk;
|
---|
[2771] | 670 |
|
---|
[8541] | 671 | xc[4] = _gamma;
|
---|
| 672 | xc[5] = 0.0;
|
---|
[8484] | 673 |
|
---|
[6213] | 674 | return success;
|
---|
[2771] | 675 | }
|
---|
| 676 |
|
---|
[6801] | 677 | // RINEX Format String
|
---|
[3659] | 678 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6801] | 679 | QString t_ephGlo::toString(double version) const {
|
---|
[3664] | 680 |
|
---|
[8804] | 681 | QString rnxStr = rinexDateStr(_TOC -_gps_utc, _prn, version);
|
---|
| 682 | int nd = int((_TOC - _gps_utc).gpssec()) / (24.0*60.0*60.0);
|
---|
[6801] | 683 | QTextStream out(&rnxStr);
|
---|
[3664] | 684 |
|
---|
[6801] | 685 | out << QString("%1%2%3\n")
|
---|
[8804] | 686 | .arg(-_tau, 19, 'e', 12)
|
---|
| 687 | .arg(_gamma, 19, 'e', 12)
|
---|
| 688 | .arg(_tki+nd*86400.0, 19, 'e', 12);
|
---|
[3668] | 689 |
|
---|
[6801] | 690 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
[3664] | 691 |
|
---|
[6801] | 692 | out << QString(fmt)
|
---|
| 693 | .arg(_x_pos, 19, 'e', 12)
|
---|
| 694 | .arg(_x_velocity, 19, 'e', 12)
|
---|
| 695 | .arg(_x_acceleration, 19, 'e', 12)
|
---|
| 696 | .arg(_health, 19, 'e', 12);
|
---|
[3664] | 697 |
|
---|
[6801] | 698 | out << QString(fmt)
|
---|
| 699 | .arg(_y_pos, 19, 'e', 12)
|
---|
| 700 | .arg(_y_velocity, 19, 'e', 12)
|
---|
| 701 | .arg(_y_acceleration, 19, 'e', 12)
|
---|
| 702 | .arg(_frequency_number, 19, 'e', 12);
|
---|
[3666] | 703 |
|
---|
[6801] | 704 | out << QString(fmt)
|
---|
| 705 | .arg(_z_pos, 19, 'e', 12)
|
---|
| 706 | .arg(_z_velocity, 19, 'e', 12)
|
---|
| 707 | .arg(_z_acceleration, 19, 'e', 12)
|
---|
| 708 | .arg(_E, 19, 'e', 12);
|
---|
[3666] | 709 |
|
---|
[6801] | 710 | return rnxStr;
|
---|
[3659] | 711 | }
|
---|
| 712 |
|
---|
[6801] | 713 | // Derivative of the state vector using a simple force model (static)
|
---|
| 714 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 715 | ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector& xv,
|
---|
| 716 | double* acc) {
|
---|
[3659] | 717 |
|
---|
[6801] | 718 | // State vector components
|
---|
| 719 | // -----------------------
|
---|
| 720 | ColumnVector rr = xv.rows(1,3);
|
---|
| 721 | ColumnVector vv = xv.rows(4,6);
|
---|
[3699] | 722 |
|
---|
[6801] | 723 | // Acceleration
|
---|
[3699] | 724 | // ------------
|
---|
[6801] | 725 | static const double gmWGS = 398.60044e12;
|
---|
| 726 | static const double AE = 6378136.0;
|
---|
| 727 | static const double OMEGA = 7292115.e-11;
|
---|
| 728 | static const double C20 = -1082.6257e-6;
|
---|
[3699] | 729 |
|
---|
[6801] | 730 | double rho = rr.norm_Frobenius();
|
---|
| 731 | double t1 = -gmWGS/(rho*rho*rho);
|
---|
| 732 | double t2 = 3.0/2.0 * C20 * (gmWGS*AE*AE) / (rho*rho*rho*rho*rho);
|
---|
| 733 | double t3 = OMEGA * OMEGA;
|
---|
| 734 | double t4 = 2.0 * OMEGA;
|
---|
| 735 | double z2 = rr(3) * rr(3);
|
---|
[3699] | 736 |
|
---|
[6801] | 737 | // Vector of derivatives
|
---|
| 738 | // ---------------------
|
---|
| 739 | ColumnVector va(6);
|
---|
| 740 | va(1) = vv(1);
|
---|
| 741 | va(2) = vv(2);
|
---|
| 742 | va(3) = vv(3);
|
---|
| 743 | va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2) + acc[0];
|
---|
| 744 | va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1) + acc[1];
|
---|
| 745 | va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho)) ) * rr(3) + acc[2];
|
---|
[3699] | 746 |
|
---|
[6801] | 747 | return va;
|
---|
| 748 | }
|
---|
[3699] | 749 |
|
---|
[6801] | 750 | // IOD of Glonass Ephemeris (virtual)
|
---|
| 751 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7169] | 752 | unsigned int t_ephGlo::IOD() const {
|
---|
[6801] | 753 | bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
|
---|
[7054] | 754 | return (unsigned long)tMoscow.daysec() / 900;
|
---|
[3659] | 755 | }
|
---|
| 756 |
|
---|
[8188] | 757 | // Health status of Glonass Ephemeris (virtual)
|
---|
| 758 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 759 | unsigned int t_ephGlo::isUnhealthy() const {
|
---|
[8216] | 760 |
|
---|
[8218] | 761 | if (_almanac_health_availablility_indicator) {
|
---|
[8216] | 762 | if ((_health == 0 && _almanac_health == 0) ||
|
---|
| 763 | (_health == 1 && _almanac_health == 0) ||
|
---|
| 764 | (_health == 1 && _almanac_health == 1)) {
|
---|
| 765 | return 1;
|
---|
| 766 | }
|
---|
[8188] | 767 | }
|
---|
[8218] | 768 | else if (!_almanac_health_availablility_indicator) {
|
---|
| 769 | if (_health) {
|
---|
| 770 | return 1;
|
---|
| 771 | }
|
---|
| 772 | }
|
---|
[8216] | 773 | return 0; /* (_health == 0 && _almanac_health == 1) or (_health == 0) */
|
---|
[8188] | 774 | }
|
---|
| 775 |
|
---|
[3659] | 776 | // Constructor
|
---|
| 777 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4891] | 778 | t_ephGal::t_ephGal(float rnxVersion, const QStringList& lines) {
|
---|
[6809] | 779 | int year, month, day, hour, min;
|
---|
| 780 | double sec;
|
---|
| 781 | QString prnStr;
|
---|
[4891] | 782 | const int nLines = 8;
|
---|
| 783 | if (lines.size() != nLines) {
|
---|
[6518] | 784 | _checkState = bad;
|
---|
[4891] | 785 | return;
|
---|
| 786 | }
|
---|
| 787 |
|
---|
| 788 | // RINEX Format
|
---|
| 789 | // ------------
|
---|
| 790 | int fieldLen = 19;
|
---|
[6792] | 791 | double SVhealth = 0.0;
|
---|
| 792 | double datasource = 0.0;
|
---|
[6798] | 793 |
|
---|
[4891] | 794 | int pos[4];
|
---|
| 795 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 796 | pos[1] = pos[0] + fieldLen;
|
---|
| 797 | pos[2] = pos[1] + fieldLen;
|
---|
| 798 | pos[3] = pos[2] + fieldLen;
|
---|
| 799 |
|
---|
| 800 | // Read eight lines
|
---|
| 801 | // ----------------
|
---|
| 802 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 803 | QString line = lines[iLine];
|
---|
| 804 |
|
---|
| 805 | if ( iLine == 0 ) {
|
---|
| 806 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
[7140] | 807 | QString n;
|
---|
[6880] | 808 | in >> prnStr;
|
---|
[7639] | 809 | if (prnStr.size() == 1 && prnStr[0] == 'E') {
|
---|
[7139] | 810 | in >> n;
|
---|
| 811 | prnStr.append(n);
|
---|
[6880] | 812 | }
|
---|
| 813 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[4891] | 814 | if (year < 80) {
|
---|
| 815 | year += 2000;
|
---|
| 816 | }
|
---|
| 817 | else if (year < 100) {
|
---|
| 818 | year += 1900;
|
---|
| 819 | }
|
---|
| 820 |
|
---|
| 821 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 822 |
|
---|
| 823 | if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
|
---|
| 824 | readDbl(line, pos[2], fieldLen, _clock_drift ) ||
|
---|
| 825 | readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
|
---|
[6518] | 826 | _checkState = bad;
|
---|
[4891] | 827 | return;
|
---|
| 828 | }
|
---|
| 829 | }
|
---|
| 830 |
|
---|
| 831 | else if ( iLine == 1 ) {
|
---|
| 832 | if ( readDbl(line, pos[0], fieldLen, _IODnav ) ||
|
---|
| 833 | readDbl(line, pos[1], fieldLen, _Crs ) ||
|
---|
| 834 | readDbl(line, pos[2], fieldLen, _Delta_n) ||
|
---|
| 835 | readDbl(line, pos[3], fieldLen, _M0 ) ) {
|
---|
[6518] | 836 | _checkState = bad;
|
---|
[4891] | 837 | return;
|
---|
| 838 | }
|
---|
| 839 | }
|
---|
| 840 |
|
---|
| 841 | else if ( iLine == 2 ) {
|
---|
| 842 | if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
|
---|
| 843 | readDbl(line, pos[1], fieldLen, _e ) ||
|
---|
| 844 | readDbl(line, pos[2], fieldLen, _Cus ) ||
|
---|
| 845 | readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
|
---|
[6518] | 846 | _checkState = bad;
|
---|
[4891] | 847 | return;
|
---|
| 848 | }
|
---|
| 849 | }
|
---|
| 850 |
|
---|
| 851 | else if ( iLine == 3 ) {
|
---|
| 852 | if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
|
---|
| 853 | readDbl(line, pos[1], fieldLen, _Cic ) ||
|
---|
| 854 | readDbl(line, pos[2], fieldLen, _OMEGA0) ||
|
---|
| 855 | readDbl(line, pos[3], fieldLen, _Cis ) ) {
|
---|
[6518] | 856 | _checkState = bad;
|
---|
[4891] | 857 | return;
|
---|
| 858 | }
|
---|
| 859 | }
|
---|
| 860 |
|
---|
| 861 | else if ( iLine == 4 ) {
|
---|
| 862 | if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
|
---|
| 863 | readDbl(line, pos[1], fieldLen, _Crc ) ||
|
---|
| 864 | readDbl(line, pos[2], fieldLen, _omega ) ||
|
---|
| 865 | readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
|
---|
[6518] | 866 | _checkState = bad;
|
---|
[4891] | 867 | return;
|
---|
| 868 | }
|
---|
| 869 | }
|
---|
| 870 |
|
---|
| 871 | else if ( iLine == 5 ) {
|
---|
[6792] | 872 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
| 873 | readDbl(line, pos[1], fieldLen, datasource) ||
|
---|
| 874 | readDbl(line, pos[2], fieldLen, _TOEweek ) ) {
|
---|
[6518] | 875 | _checkState = bad;
|
---|
[4891] | 876 | return;
|
---|
[6792] | 877 | } else {
|
---|
| 878 | if (int(datasource) & (1<<8)) {
|
---|
[6812] | 879 | _fnav = true;
|
---|
| 880 | _inav = false;
|
---|
[6792] | 881 | } else if (int(datasource) & (1<<9)) {
|
---|
[6812] | 882 | _fnav = false;
|
---|
| 883 | _inav = true;
|
---|
[6792] | 884 | }
|
---|
[6892] | 885 | _TOEweek -= 1024.0;
|
---|
[4891] | 886 | }
|
---|
| 887 | }
|
---|
| 888 |
|
---|
| 889 | else if ( iLine == 6 ) {
|
---|
| 890 | if ( readDbl(line, pos[0], fieldLen, _SISA ) ||
|
---|
[6792] | 891 | readDbl(line, pos[1], fieldLen, SVhealth) ||
|
---|
[4891] | 892 | readDbl(line, pos[2], fieldLen, _BGD_1_5A) ||
|
---|
| 893 | readDbl(line, pos[3], fieldLen, _BGD_1_5B) ) {
|
---|
[6518] | 894 | _checkState = bad;
|
---|
[4891] | 895 | return;
|
---|
[6792] | 896 | } else {
|
---|
| 897 | // Bit 0
|
---|
[6812] | 898 | _e1DataInValid = (int(SVhealth) & (1<<0));
|
---|
[6792] | 899 | // Bit 1-2
|
---|
[6802] | 900 | _E1_bHS = double((int(SVhealth) >> 1) & 0x3);
|
---|
[6792] | 901 | // Bit 3
|
---|
[6812] | 902 | _e5aDataInValid = (int(SVhealth) & (1<<3));
|
---|
[6792] | 903 | // Bit 4-5
|
---|
[6802] | 904 | _E5aHS = double((int(SVhealth) >> 4) & 0x3);
|
---|
[6792] | 905 | // Bit 6
|
---|
[6812] | 906 | _e5bDataInValid = (int(SVhealth) & (1<<6));
|
---|
[6792] | 907 | // Bit 7-8
|
---|
[6802] | 908 | _E5bHS = double((int(SVhealth) >> 7) & 0x3);
|
---|
[6809] | 909 |
|
---|
| 910 | if (prnStr.at(0) == 'E') {
|
---|
[7140] | 911 | _prn.set('E', prnStr.mid(1).toInt(), _inav ? 1 : 0);
|
---|
[6809] | 912 | }
|
---|
[4891] | 913 | }
|
---|
| 914 | }
|
---|
| 915 |
|
---|
| 916 | else if ( iLine == 7 ) {
|
---|
| 917 | if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
|
---|
[6518] | 918 | _checkState = bad;
|
---|
[4891] | 919 | return;
|
---|
| 920 | }
|
---|
| 921 | }
|
---|
| 922 | }
|
---|
[3659] | 923 | }
|
---|
[4013] | 924 |
|
---|
[6801] | 925 | // Compute Galileo Satellite Position (virtual)
|
---|
| 926 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 927 | t_irc t_ephGal::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[4013] | 928 |
|
---|
[6801] | 929 | static const double omegaEarth = 7292115.1467e-11;
|
---|
[8213] | 930 | static const double gmWGS = 398.6004418e12;
|
---|
[4023] | 931 |
|
---|
[8541] | 932 | memset(xc, 0, 6*sizeof(double));
|
---|
[6801] | 933 | memset(vv, 0, 3*sizeof(double));
|
---|
[4023] | 934 |
|
---|
[6801] | 935 | double a0 = _sqrt_A * _sqrt_A;
|
---|
| 936 | if (a0 == 0) {
|
---|
| 937 | return failure;
|
---|
| 938 | }
|
---|
[4023] | 939 |
|
---|
[6801] | 940 | double n0 = sqrt(gmWGS/(a0*a0*a0));
|
---|
[4023] | 941 |
|
---|
[6801] | 942 | bncTime tt(GPSweek, GPSweeks);
|
---|
| 943 | double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
|
---|
[4023] | 944 |
|
---|
[6801] | 945 | double n = n0 + _Delta_n;
|
---|
| 946 | double M = _M0 + n*tk;
|
---|
| 947 | double E = M;
|
---|
| 948 | double E_last;
|
---|
[8370] | 949 | int nLoop = 0;
|
---|
[6801] | 950 | do {
|
---|
| 951 | E_last = E;
|
---|
| 952 | E = M + _e*sin(E);
|
---|
[8370] | 953 |
|
---|
| 954 | if (++nLoop == 100) {
|
---|
| 955 | return failure;
|
---|
| 956 | }
|
---|
[6801] | 957 | } while ( fabs(E-E_last)*a0 > 0.001 );
|
---|
| 958 | double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
|
---|
| 959 | double u0 = v + _omega;
|
---|
| 960 | double sin2u0 = sin(2*u0);
|
---|
| 961 | double cos2u0 = cos(2*u0);
|
---|
| 962 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
| 963 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
| 964 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
| 965 | double xp = r*cos(u);
|
---|
| 966 | double yp = r*sin(u);
|
---|
| 967 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
|
---|
| 968 | omegaEarth*_TOEsec;
|
---|
[4023] | 969 |
|
---|
[6801] | 970 | double sinom = sin(OM);
|
---|
| 971 | double cosom = cos(OM);
|
---|
| 972 | double sini = sin(i);
|
---|
| 973 | double cosi = cos(i);
|
---|
| 974 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
| 975 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
| 976 | xc[2] = yp*sini;
|
---|
[4023] | 977 |
|
---|
[6801] | 978 | double tc = tt - _TOC;
|
---|
| 979 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
[4023] | 980 |
|
---|
[6801] | 981 | // Velocity
|
---|
| 982 | // --------
|
---|
| 983 | double tanv2 = tan(v/2);
|
---|
| 984 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
| 985 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
|
---|
| 986 | * dEdM * n;
|
---|
| 987 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
| 988 | double dotom = _OMEGADOT - omegaEarth;
|
---|
| 989 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
| 990 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
| 991 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
| 992 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
| 993 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
[4023] | 994 |
|
---|
[6801] | 995 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
| 996 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
| 997 | + yp*sini*sinom*doti; // dX / di
|
---|
| 998 |
|
---|
| 999 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
| 1000 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
| 1001 | - yp*sini*cosom*doti;
|
---|
| 1002 |
|
---|
| 1003 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
| 1004 |
|
---|
| 1005 | // Relativistic Correction
|
---|
| 1006 | // -----------------------
|
---|
[7481] | 1007 | // correspondent to Galileo ICD and to SSR standard
|
---|
| 1008 | xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
|
---|
| 1009 | // correspondent to IGS convention
|
---|
| 1010 | //xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
|
---|
[6801] | 1011 |
|
---|
[8541] | 1012 | xc[4] = _clock_drift + _clock_driftrate*tc;
|
---|
| 1013 | xc[5] = _clock_driftrate;
|
---|
| 1014 |
|
---|
[6801] | 1015 | return success;
|
---|
[4023] | 1016 | }
|
---|
| 1017 |
|
---|
[8188] | 1018 | // Health status of Galileo Ephemeris (virtual)
|
---|
| 1019 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1020 | unsigned int t_ephGal::isUnhealthy() const {
|
---|
| 1021 | if (_E5aHS && _E5bHS && _E1_bHS) {
|
---|
| 1022 | return 1;
|
---|
| 1023 | }
|
---|
| 1024 | return 0;
|
---|
| 1025 | }
|
---|
| 1026 |
|
---|
[4023] | 1027 | // RINEX Format String
|
---|
| 1028 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1029 | QString t_ephGal::toString(double version) const {
|
---|
| 1030 |
|
---|
[4029] | 1031 | QString rnxStr = rinexDateStr(_TOC, _prn, version);
|
---|
[4023] | 1032 |
|
---|
| 1033 | QTextStream out(&rnxStr);
|
---|
| 1034 |
|
---|
| 1035 | out << QString("%1%2%3\n")
|
---|
| 1036 | .arg(_clock_bias, 19, 'e', 12)
|
---|
| 1037 | .arg(_clock_drift, 19, 'e', 12)
|
---|
| 1038 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
| 1039 |
|
---|
| 1040 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
| 1041 |
|
---|
| 1042 | out << QString(fmt)
|
---|
| 1043 | .arg(_IODnav, 19, 'e', 12)
|
---|
| 1044 | .arg(_Crs, 19, 'e', 12)
|
---|
| 1045 | .arg(_Delta_n, 19, 'e', 12)
|
---|
| 1046 | .arg(_M0, 19, 'e', 12);
|
---|
| 1047 |
|
---|
| 1048 | out << QString(fmt)
|
---|
| 1049 | .arg(_Cuc, 19, 'e', 12)
|
---|
| 1050 | .arg(_e, 19, 'e', 12)
|
---|
| 1051 | .arg(_Cus, 19, 'e', 12)
|
---|
| 1052 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
| 1053 |
|
---|
| 1054 | out << QString(fmt)
|
---|
| 1055 | .arg(_TOEsec, 19, 'e', 12)
|
---|
| 1056 | .arg(_Cic, 19, 'e', 12)
|
---|
| 1057 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
| 1058 | .arg(_Cis, 19, 'e', 12);
|
---|
| 1059 |
|
---|
| 1060 | out << QString(fmt)
|
---|
| 1061 | .arg(_i0, 19, 'e', 12)
|
---|
| 1062 | .arg(_Crc, 19, 'e', 12)
|
---|
| 1063 | .arg(_omega, 19, 'e', 12)
|
---|
| 1064 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
| 1065 |
|
---|
[6792] | 1066 | int dataSource = 0;
|
---|
| 1067 | int SVhealth = 0;
|
---|
| 1068 | double BGD_1_5A = _BGD_1_5A;
|
---|
| 1069 | double BGD_1_5B = _BGD_1_5B;
|
---|
[6812] | 1070 | if (_fnav) {
|
---|
[6792] | 1071 | dataSource |= (1<<1);
|
---|
| 1072 | dataSource |= (1<<8);
|
---|
| 1073 | BGD_1_5B = 0.0;
|
---|
| 1074 | // SVhealth
|
---|
| 1075 | // Bit 3 : E5a DVS
|
---|
[6812] | 1076 | if (_e5aDataInValid) {
|
---|
[6792] | 1077 | SVhealth |= (1<<3);
|
---|
| 1078 | }
|
---|
| 1079 | // Bit 4-5: E5a HS
|
---|
| 1080 | if (_E5aHS == 1.0) {
|
---|
| 1081 | SVhealth |= (1<<4);
|
---|
| 1082 | }
|
---|
| 1083 | else if (_E5aHS == 2.0) {
|
---|
| 1084 | SVhealth |= (1<<5);
|
---|
| 1085 | }
|
---|
| 1086 | else if (_E5aHS == 3.0) {
|
---|
| 1087 | SVhealth |= (1<<4);
|
---|
| 1088 | SVhealth |= (1<<5);
|
---|
| 1089 | }
|
---|
| 1090 | }
|
---|
[6812] | 1091 | else if(_inav) {
|
---|
[6803] | 1092 | // Bit 2 and 0 are set because from MT1046 the data source cannot be determined
|
---|
| 1093 | // and RNXv3.03 says both can be set if the navigation messages were merged
|
---|
[5539] | 1094 | dataSource |= (1<<0);
|
---|
[6792] | 1095 | dataSource |= (1<<2);
|
---|
[5540] | 1096 | dataSource |= (1<<9);
|
---|
[6792] | 1097 | // SVhealth
|
---|
| 1098 | // Bit 0 : E1-B DVS
|
---|
[6812] | 1099 | if (_e1DataInValid) {
|
---|
[6792] | 1100 | SVhealth |= (1<<0);
|
---|
| 1101 | }
|
---|
| 1102 | // Bit 1-2: E1-B HS
|
---|
| 1103 | if (_E1_bHS == 1.0) {
|
---|
| 1104 | SVhealth |= (1<<1);
|
---|
| 1105 | }
|
---|
| 1106 | else if (_E1_bHS == 2.0) {
|
---|
| 1107 | SVhealth |= (1<<2);
|
---|
| 1108 | }
|
---|
[6803] | 1109 | else if (_E1_bHS == 3.0) {
|
---|
[6792] | 1110 | SVhealth |= (1<<1);
|
---|
| 1111 | SVhealth |= (1<<2);
|
---|
| 1112 | }
|
---|
[6802] | 1113 | // Bit 3 : E5a DVS
|
---|
[6812] | 1114 | if (_e5aDataInValid) {
|
---|
[6802] | 1115 | SVhealth |= (1<<3);
|
---|
| 1116 | }
|
---|
| 1117 | // Bit 4-5: E5a HS
|
---|
| 1118 | if (_E5aHS == 1.0) {
|
---|
| 1119 | SVhealth |= (1<<4);
|
---|
| 1120 | }
|
---|
| 1121 | else if (_E5aHS == 2.0) {
|
---|
| 1122 | SVhealth |= (1<<5);
|
---|
| 1123 | }
|
---|
[6803] | 1124 | else if (_E5aHS == 3.0) {
|
---|
[6802] | 1125 | SVhealth |= (1<<4);
|
---|
| 1126 | SVhealth |= (1<<5);
|
---|
| 1127 | }
|
---|
[6792] | 1128 | // Bit 6 : E5b DVS
|
---|
[6812] | 1129 | if (_e5bDataInValid) {
|
---|
[6792] | 1130 | SVhealth |= (1<<6);
|
---|
| 1131 | }
|
---|
| 1132 | // Bit 7-8: E5b HS
|
---|
| 1133 | if (_E5bHS == 1.0) {
|
---|
| 1134 | SVhealth |= (1<<7);
|
---|
| 1135 | }
|
---|
| 1136 | else if (_E5bHS == 2.0) {
|
---|
| 1137 | SVhealth |= (1<<8);
|
---|
| 1138 | }
|
---|
[6803] | 1139 | else if (_E5bHS == 3.0) {
|
---|
[6792] | 1140 | SVhealth |= (1<<7);
|
---|
| 1141 | SVhealth |= (1<<8);
|
---|
| 1142 | }
|
---|
[5539] | 1143 | }
|
---|
[6792] | 1144 |
|
---|
[4023] | 1145 | out << QString(fmt)
|
---|
[5532] | 1146 | .arg(_IDOT, 19, 'e', 12)
|
---|
| 1147 | .arg(double(dataSource), 19, 'e', 12)
|
---|
[6892] | 1148 | .arg(_TOEweek + 1024.0, 19, 'e', 12)
|
---|
[5532] | 1149 | .arg(0.0, 19, 'e', 12);
|
---|
[4023] | 1150 |
|
---|
| 1151 | out << QString(fmt)
|
---|
[6798] | 1152 | .arg(_SISA, 19, 'e', 12)
|
---|
[6792] | 1153 | .arg(double(SVhealth), 19, 'e', 12)
|
---|
| 1154 | .arg(BGD_1_5A, 19, 'e', 12)
|
---|
| 1155 | .arg(BGD_1_5B, 19, 'e', 12);
|
---|
[4023] | 1156 |
|
---|
[7923] | 1157 | double tot = _TOT;
|
---|
| 1158 | if (tot == 0.9999e9 && version < 3.0) {
|
---|
| 1159 | tot = 0.0;
|
---|
| 1160 | }
|
---|
[4023] | 1161 | out << QString(fmt)
|
---|
[7923] | 1162 | .arg(tot, 19, 'e', 12)
|
---|
[4024] | 1163 | .arg("", 19, QChar(' '))
|
---|
| 1164 | .arg("", 19, QChar(' '))
|
---|
| 1165 | .arg("", 19, QChar(' '));
|
---|
[4023] | 1166 |
|
---|
| 1167 | return rnxStr;
|
---|
| 1168 | }
|
---|
| 1169 |
|
---|
[6385] | 1170 | // Constructor
|
---|
| 1171 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6390] | 1172 | t_ephSBAS::t_ephSBAS(float rnxVersion, const QStringList& lines) {
|
---|
| 1173 |
|
---|
| 1174 | const int nLines = 4;
|
---|
| 1175 |
|
---|
| 1176 | if (lines.size() != nLines) {
|
---|
[6518] | 1177 | _checkState = bad;
|
---|
[6390] | 1178 | return;
|
---|
| 1179 | }
|
---|
| 1180 |
|
---|
| 1181 | // RINEX Format
|
---|
| 1182 | // ------------
|
---|
| 1183 | int fieldLen = 19;
|
---|
| 1184 |
|
---|
| 1185 | int pos[4];
|
---|
| 1186 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 1187 | pos[1] = pos[0] + fieldLen;
|
---|
| 1188 | pos[2] = pos[1] + fieldLen;
|
---|
| 1189 | pos[3] = pos[2] + fieldLen;
|
---|
| 1190 |
|
---|
| 1191 | // Read four lines
|
---|
| 1192 | // ---------------
|
---|
| 1193 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 1194 | QString line = lines[iLine];
|
---|
| 1195 |
|
---|
| 1196 | if ( iLine == 0 ) {
|
---|
| 1197 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
| 1198 |
|
---|
| 1199 | int year, month, day, hour, min;
|
---|
| 1200 | double sec;
|
---|
[6880] | 1201 |
|
---|
[7139] | 1202 | QString prnStr, n;
|
---|
[6880] | 1203 | in >> prnStr;
|
---|
[7639] | 1204 | if (prnStr.size() == 1 && prnStr[0] == 'S') {
|
---|
[7139] | 1205 | in >> n;
|
---|
| 1206 | prnStr.append(n);
|
---|
[6880] | 1207 | }
|
---|
| 1208 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[6390] | 1209 | if (prnStr.at(0) == 'S') {
|
---|
| 1210 | _prn.set('S', prnStr.mid(1).toInt());
|
---|
| 1211 | }
|
---|
| 1212 | else {
|
---|
| 1213 | _prn.set('S', prnStr.toInt());
|
---|
| 1214 | }
|
---|
| 1215 |
|
---|
| 1216 | if (year < 80) {
|
---|
| 1217 | year += 2000;
|
---|
| 1218 | }
|
---|
| 1219 | else if (year < 100) {
|
---|
| 1220 | year += 1900;
|
---|
| 1221 | }
|
---|
| 1222 |
|
---|
| 1223 | _TOC.set(year, month, day, hour, min, sec);
|
---|
| 1224 |
|
---|
| 1225 | if ( readDbl(line, pos[1], fieldLen, _agf0 ) ||
|
---|
| 1226 | readDbl(line, pos[2], fieldLen, _agf1 ) ||
|
---|
[8455] | 1227 | readDbl(line, pos[3], fieldLen, _TOT ) ) {
|
---|
[6518] | 1228 | _checkState = bad;
|
---|
[6390] | 1229 | return;
|
---|
| 1230 | }
|
---|
| 1231 | }
|
---|
| 1232 |
|
---|
| 1233 | else if ( iLine == 1 ) {
|
---|
| 1234 | if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
|
---|
| 1235 | readDbl(line, pos[1], fieldLen, _x_velocity ) ||
|
---|
| 1236 | readDbl(line, pos[2], fieldLen, _x_acceleration) ||
|
---|
| 1237 | readDbl(line, pos[3], fieldLen, _health ) ) {
|
---|
[6518] | 1238 | _checkState = bad;
|
---|
[6390] | 1239 | return;
|
---|
| 1240 | }
|
---|
| 1241 | }
|
---|
| 1242 |
|
---|
| 1243 | else if ( iLine == 2 ) {
|
---|
| 1244 | if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
|
---|
| 1245 | readDbl(line, pos[1], fieldLen, _y_velocity ) ||
|
---|
| 1246 | readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
|
---|
| 1247 | readDbl(line, pos[3], fieldLen, _ura ) ) {
|
---|
[6518] | 1248 | _checkState = bad;
|
---|
[6390] | 1249 | return;
|
---|
| 1250 | }
|
---|
| 1251 | }
|
---|
| 1252 |
|
---|
| 1253 | else if ( iLine == 3 ) {
|
---|
[6536] | 1254 | double iodn;
|
---|
[6390] | 1255 | if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
|
---|
| 1256 | readDbl(line, pos[1], fieldLen, _z_velocity ) ||
|
---|
| 1257 | readDbl(line, pos[2], fieldLen, _z_acceleration) ||
|
---|
[6536] | 1258 | readDbl(line, pos[3], fieldLen, iodn ) ) {
|
---|
[6518] | 1259 | _checkState = bad;
|
---|
[6390] | 1260 | return;
|
---|
[6891] | 1261 | } else {
|
---|
[6536] | 1262 | _IODN = int(iodn);
|
---|
[6390] | 1263 | }
|
---|
| 1264 | }
|
---|
| 1265 | }
|
---|
| 1266 |
|
---|
[7278] | 1267 | _x_pos *= 1.e3;
|
---|
| 1268 | _y_pos *= 1.e3;
|
---|
| 1269 | _z_pos *= 1.e3;
|
---|
| 1270 | _x_velocity *= 1.e3;
|
---|
| 1271 | _y_velocity *= 1.e3;
|
---|
| 1272 | _z_velocity *= 1.e3;
|
---|
| 1273 | _x_acceleration *= 1.e3;
|
---|
| 1274 | _y_acceleration *= 1.e3;
|
---|
| 1275 | _z_acceleration *= 1.e3;
|
---|
[6385] | 1276 | }
|
---|
| 1277 |
|
---|
[7054] | 1278 | // IOD of SBAS Ephemeris (virtual)
|
---|
| 1279 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1280 |
|
---|
[7169] | 1281 | unsigned int t_ephSBAS::IOD() const {
|
---|
[7054] | 1282 | unsigned char buffer[80];
|
---|
| 1283 | int size = 0;
|
---|
| 1284 | int numbits = 0;
|
---|
| 1285 | long long bitbuffer = 0;
|
---|
| 1286 | unsigned char *startbuffer = buffer;
|
---|
| 1287 |
|
---|
| 1288 | SBASADDBITSFLOAT(30, this->_x_pos, 0.08)
|
---|
| 1289 | SBASADDBITSFLOAT(30, this->_y_pos, 0.08)
|
---|
| 1290 | SBASADDBITSFLOAT(25, this->_z_pos, 0.4)
|
---|
| 1291 | SBASADDBITSFLOAT(17, this->_x_velocity, 0.000625)
|
---|
| 1292 | SBASADDBITSFLOAT(17, this->_y_velocity, 0.000625)
|
---|
| 1293 | SBASADDBITSFLOAT(18, this->_z_velocity, 0.004)
|
---|
| 1294 | SBASADDBITSFLOAT(10, this->_x_acceleration, 0.0000125)
|
---|
| 1295 | SBASADDBITSFLOAT(10, this->_y_acceleration, 0.0000125)
|
---|
| 1296 | SBASADDBITSFLOAT(10, this->_z_acceleration, 0.0000625)
|
---|
| 1297 | SBASADDBITSFLOAT(12, this->_agf0, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1298 | SBASADDBITSFLOAT(8, this->_agf1, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<10))
|
---|
| 1299 | SBASADDBITS(5,0); // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
|
---|
| 1300 |
|
---|
| 1301 | return CRC24(size, startbuffer);
|
---|
| 1302 | }
|
---|
| 1303 |
|
---|
[6385] | 1304 | // Compute SBAS Satellite Position (virtual)
|
---|
| 1305 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1306 | t_irc t_ephSBAS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[6386] | 1307 |
|
---|
| 1308 | bncTime tt(GPSweek, GPSweeks);
|
---|
| 1309 | double dt = tt - _TOC;
|
---|
| 1310 |
|
---|
[7278] | 1311 | xc[0] = _x_pos + _x_velocity * dt + _x_acceleration * dt * dt / 2.0;
|
---|
| 1312 | xc[1] = _y_pos + _y_velocity * dt + _y_acceleration * dt * dt / 2.0;
|
---|
| 1313 | xc[2] = _z_pos + _z_velocity * dt + _z_acceleration * dt * dt / 2.0;
|
---|
[6386] | 1314 |
|
---|
| 1315 | vv[0] = _x_velocity + _x_acceleration * dt;
|
---|
| 1316 | vv[1] = _y_velocity + _y_acceleration * dt;
|
---|
| 1317 | vv[2] = _z_velocity + _z_acceleration * dt;
|
---|
| 1318 |
|
---|
| 1319 | xc[3] = _agf0 + _agf1 * dt;
|
---|
| 1320 |
|
---|
[8541] | 1321 | xc[4] = _agf1;
|
---|
| 1322 | xc[5] = 0.0;
|
---|
[8484] | 1323 |
|
---|
[6386] | 1324 | return success;
|
---|
[6385] | 1325 | }
|
---|
| 1326 |
|
---|
| 1327 | // RINEX Format String
|
---|
| 1328 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6388] | 1329 | QString t_ephSBAS::toString(double version) const {
|
---|
| 1330 |
|
---|
| 1331 | QString rnxStr = rinexDateStr(_TOC, _prn, version);
|
---|
| 1332 |
|
---|
| 1333 | QTextStream out(&rnxStr);
|
---|
| 1334 |
|
---|
| 1335 | out << QString("%1%2%3\n")
|
---|
[6390] | 1336 | .arg(_agf0, 19, 'e', 12)
|
---|
| 1337 | .arg(_agf1, 19, 'e', 12)
|
---|
[8455] | 1338 | .arg(_TOT, 19, 'e', 12);
|
---|
[6388] | 1339 |
|
---|
| 1340 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
| 1341 |
|
---|
| 1342 | out << QString(fmt)
|
---|
| 1343 | .arg(1.e-3*_x_pos, 19, 'e', 12)
|
---|
| 1344 | .arg(1.e-3*_x_velocity, 19, 'e', 12)
|
---|
| 1345 | .arg(1.e-3*_x_acceleration, 19, 'e', 12)
|
---|
[6390] | 1346 | .arg(_health, 19, 'e', 12);
|
---|
[6388] | 1347 |
|
---|
| 1348 | out << QString(fmt)
|
---|
| 1349 | .arg(1.e-3*_y_pos, 19, 'e', 12)
|
---|
| 1350 | .arg(1.e-3*_y_velocity, 19, 'e', 12)
|
---|
| 1351 | .arg(1.e-3*_y_acceleration, 19, 'e', 12)
|
---|
[6390] | 1352 | .arg(_ura, 19, 'e', 12);
|
---|
[6388] | 1353 |
|
---|
| 1354 | out << QString(fmt)
|
---|
| 1355 | .arg(1.e-3*_z_pos, 19, 'e', 12)
|
---|
| 1356 | .arg(1.e-3*_z_velocity, 19, 'e', 12)
|
---|
| 1357 | .arg(1.e-3*_z_acceleration, 19, 'e', 12)
|
---|
[6536] | 1358 | .arg(double(_IODN), 19, 'e', 12);
|
---|
[6388] | 1359 |
|
---|
| 1360 | return rnxStr;
|
---|
[6385] | 1361 | }
|
---|
[6400] | 1362 |
|
---|
| 1363 | // Constructor
|
---|
| 1364 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6600] | 1365 | t_ephBDS::t_ephBDS(float rnxVersion, const QStringList& lines) {
|
---|
[6400] | 1366 |
|
---|
| 1367 | const int nLines = 8;
|
---|
| 1368 |
|
---|
| 1369 | if (lines.size() != nLines) {
|
---|
[6518] | 1370 | _checkState = bad;
|
---|
[6400] | 1371 | return;
|
---|
| 1372 | }
|
---|
| 1373 |
|
---|
| 1374 | // RINEX Format
|
---|
| 1375 | // ------------
|
---|
| 1376 | int fieldLen = 19;
|
---|
| 1377 |
|
---|
| 1378 | int pos[4];
|
---|
| 1379 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
| 1380 | pos[1] = pos[0] + fieldLen;
|
---|
| 1381 | pos[2] = pos[1] + fieldLen;
|
---|
| 1382 | pos[3] = pos[2] + fieldLen;
|
---|
| 1383 |
|
---|
| 1384 | // Read eight lines
|
---|
| 1385 | // ----------------
|
---|
| 1386 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
| 1387 | QString line = lines[iLine];
|
---|
| 1388 |
|
---|
| 1389 | if ( iLine == 0 ) {
|
---|
| 1390 | QTextStream in(line.left(pos[1]).toAscii());
|
---|
| 1391 |
|
---|
| 1392 | int year, month, day, hour, min;
|
---|
| 1393 | double sec;
|
---|
[6880] | 1394 |
|
---|
[7139] | 1395 | QString prnStr, n;
|
---|
[6880] | 1396 | in >> prnStr;
|
---|
[7639] | 1397 | if (prnStr.size() == 1 && prnStr[0] == 'C') {
|
---|
[7139] | 1398 | in >> n;
|
---|
| 1399 | prnStr.append(n);
|
---|
[6880] | 1400 | }
|
---|
| 1401 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[6400] | 1402 | if (prnStr.at(0) == 'C') {
|
---|
| 1403 | _prn.set('C', prnStr.mid(1).toInt());
|
---|
| 1404 | }
|
---|
| 1405 | else {
|
---|
| 1406 | _prn.set('C', prnStr.toInt());
|
---|
| 1407 | }
|
---|
| 1408 |
|
---|
| 1409 | if (year < 80) {
|
---|
| 1410 | year += 2000;
|
---|
| 1411 | }
|
---|
| 1412 | else if (year < 100) {
|
---|
| 1413 | year += 1900;
|
---|
| 1414 | }
|
---|
| 1415 |
|
---|
[6812] | 1416 | _TOC.setBDS(year, month, day, hour, min, sec);
|
---|
[6400] | 1417 |
|
---|
| 1418 | if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
|
---|
| 1419 | readDbl(line, pos[2], fieldLen, _clock_drift ) ||
|
---|
| 1420 | readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
|
---|
[6518] | 1421 | _checkState = bad;
|
---|
[6400] | 1422 | return;
|
---|
| 1423 | }
|
---|
| 1424 | }
|
---|
| 1425 |
|
---|
| 1426 | else if ( iLine == 1 ) {
|
---|
| 1427 | double aode;
|
---|
| 1428 | if ( readDbl(line, pos[0], fieldLen, aode ) ||
|
---|
| 1429 | readDbl(line, pos[1], fieldLen, _Crs ) ||
|
---|
| 1430 | readDbl(line, pos[2], fieldLen, _Delta_n) ||
|
---|
| 1431 | readDbl(line, pos[3], fieldLen, _M0 ) ) {
|
---|
[6518] | 1432 | _checkState = bad;
|
---|
[6400] | 1433 | return;
|
---|
| 1434 | }
|
---|
| 1435 | _AODE = int(aode);
|
---|
| 1436 | }
|
---|
| 1437 |
|
---|
| 1438 | else if ( iLine == 2 ) {
|
---|
| 1439 | if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
|
---|
| 1440 | readDbl(line, pos[1], fieldLen, _e ) ||
|
---|
| 1441 | readDbl(line, pos[2], fieldLen, _Cus ) ||
|
---|
| 1442 | readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
|
---|
[6518] | 1443 | _checkState = bad;
|
---|
[6400] | 1444 | return;
|
---|
| 1445 | }
|
---|
| 1446 | }
|
---|
| 1447 |
|
---|
| 1448 | else if ( iLine == 3 ) {
|
---|
[6812] | 1449 | if ( readDbl(line, pos[0], fieldLen, _TOEsec ) ||
|
---|
[6400] | 1450 | readDbl(line, pos[1], fieldLen, _Cic ) ||
|
---|
| 1451 | readDbl(line, pos[2], fieldLen, _OMEGA0) ||
|
---|
| 1452 | readDbl(line, pos[3], fieldLen, _Cis ) ) {
|
---|
[6518] | 1453 | _checkState = bad;
|
---|
[6400] | 1454 | return;
|
---|
| 1455 | }
|
---|
| 1456 | }
|
---|
| 1457 |
|
---|
| 1458 | else if ( iLine == 4 ) {
|
---|
| 1459 | if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
|
---|
| 1460 | readDbl(line, pos[1], fieldLen, _Crc ) ||
|
---|
| 1461 | readDbl(line, pos[2], fieldLen, _omega ) ||
|
---|
| 1462 | readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
|
---|
[6518] | 1463 | _checkState = bad;
|
---|
[6400] | 1464 | return;
|
---|
| 1465 | }
|
---|
| 1466 | }
|
---|
| 1467 |
|
---|
| 1468 | else if ( iLine == 5 ) {
|
---|
| 1469 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
[6812] | 1470 | readDbl(line, pos[2], fieldLen, _TOEweek)) {
|
---|
[6518] | 1471 | _checkState = bad;
|
---|
[6400] | 1472 | return;
|
---|
| 1473 | }
|
---|
| 1474 | }
|
---|
| 1475 |
|
---|
| 1476 | else if ( iLine == 6 ) {
|
---|
| 1477 | double SatH1;
|
---|
[6755] | 1478 | if ( readDbl(line, pos[0], fieldLen, _URA ) ||
|
---|
| 1479 | readDbl(line, pos[1], fieldLen, SatH1) ||
|
---|
[6400] | 1480 | readDbl(line, pos[2], fieldLen, _TGD1) ||
|
---|
| 1481 | readDbl(line, pos[3], fieldLen, _TGD2) ) {
|
---|
[6518] | 1482 | _checkState = bad;
|
---|
[6400] | 1483 | return;
|
---|
| 1484 | }
|
---|
| 1485 | _SatH1 = int(SatH1);
|
---|
| 1486 | }
|
---|
| 1487 |
|
---|
| 1488 | else if ( iLine == 7 ) {
|
---|
| 1489 | double aodc;
|
---|
[6812] | 1490 | if ( readDbl(line, pos[0], fieldLen, _TOT) ||
|
---|
[6400] | 1491 | readDbl(line, pos[1], fieldLen, aodc) ) {
|
---|
[6518] | 1492 | _checkState = bad;
|
---|
[6400] | 1493 | return;
|
---|
| 1494 | }
|
---|
[6812] | 1495 | if (_TOT == 0.9999e9) { // 0.9999e9 means not known (RINEX standard)
|
---|
| 1496 | _TOT = _TOEsec;
|
---|
[6400] | 1497 | }
|
---|
| 1498 | _AODC = int(aodc);
|
---|
| 1499 | }
|
---|
| 1500 | }
|
---|
| 1501 |
|
---|
[7138] | 1502 | _TOE.setBDS(int(_TOEweek), _TOEsec);
|
---|
| 1503 |
|
---|
[6400] | 1504 | // remark: actually should be computed from second_tot
|
---|
| 1505 | // but it seems to be unreliable in RINEX files
|
---|
[6843] | 1506 | //_TOT = _TOC.bdssec();
|
---|
[6400] | 1507 | }
|
---|
| 1508 |
|
---|
[7054] | 1509 | // IOD of BDS Ephemeris (virtual)
|
---|
| 1510 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7169] | 1511 | unsigned int t_ephBDS::IOD() const {
|
---|
[7054] | 1512 | unsigned char buffer[80];
|
---|
| 1513 | int size = 0;
|
---|
| 1514 | int numbits = 0;
|
---|
| 1515 | long long bitbuffer = 0;
|
---|
| 1516 | unsigned char *startbuffer = buffer;
|
---|
| 1517 |
|
---|
| 1518 | BDSADDBITSFLOAT(14, this->_IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 1519 | BDSADDBITSFLOAT(11, this->_clock_driftrate, 1.0/static_cast<double>(1<<30)
|
---|
| 1520 | /static_cast<double>(1<<30)/static_cast<double>(1<<6))
|
---|
| 1521 | BDSADDBITSFLOAT(22, this->_clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<20))
|
---|
| 1522 | BDSADDBITSFLOAT(24, this->_clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 1523 | BDSADDBITSFLOAT(18, this->_Crs, 1.0/static_cast<double>(1<<6))
|
---|
| 1524 | BDSADDBITSFLOAT(16, this->_Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 1525 | BDSADDBITSFLOAT(32, this->_M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1526 | BDSADDBITSFLOAT(18, this->_Cuc, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1527 | BDSADDBITSFLOAT(32, this->_e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
|
---|
| 1528 | BDSADDBITSFLOAT(18, this->_Cus, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1529 | BDSADDBITSFLOAT(32, this->_sqrt_A, 1.0/static_cast<double>(1<<19))
|
---|
| 1530 | BDSADDBITSFLOAT(18, this->_Cic, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1531 | BDSADDBITSFLOAT(32, this->_OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1532 | BDSADDBITSFLOAT(18, this->_Cis, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1533 | BDSADDBITSFLOAT(32, this->_i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1534 | BDSADDBITSFLOAT(18, this->_Crc, 1.0/static_cast<double>(1<<6))
|
---|
| 1535 | BDSADDBITSFLOAT(32, this->_omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
| 1536 | BDSADDBITSFLOAT(24, this->_OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
|
---|
| 1537 | BDSADDBITS(5, 0) // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
|
---|
| 1538 |
|
---|
| 1539 | return CRC24(size, startbuffer);
|
---|
| 1540 | }
|
---|
| 1541 |
|
---|
[6601] | 1542 | // Compute BDS Satellite Position (virtual)
|
---|
[6400] | 1543 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6600] | 1544 | t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
[6400] | 1545 |
|
---|
[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 | }
|
---|