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