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