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