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