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