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