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