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