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