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