Changeset 6225 in ntrip
- Timestamp:
- Oct 11, 2014, 3:09:24 PM (10 years ago)
- Location:
- trunk/BNC/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bncrinex.cpp
r6223 r6225 97 97 bncRinex::~bncRinex() { 98 98 bncSettings settings; 99 if ((_header. _version>= 3.0) && ( Qt::CheckState(settings.value("rnxAppend").toInt()) != Qt::Checked) ) {99 if ((_header.version() >= 3.0) && ( Qt::CheckState(settings.value("rnxAppend").toInt()) != Qt::Checked) ) { 100 100 _out << "> 4 1" << endl; 101 101 _out << "END OF FILE" << endl; … … 389 389 // Select observations older than maxTime 390 390 // -------------------------------------- 391 QList<t_satObs> dumpList;391 QList<t_satObs> obsList; 392 392 QMutableListIterator<t_satObs> mIt(_obs); 393 393 while (mIt.hasNext()) { 394 394 t_satObs obs = mIt.next(); 395 395 if (obs._time.gpsw() * 7*24*3600 + obs._time.gpssec() < maxTime - 0.05) { 396 dumpList.push_back(obs);396 obsList.push_back(obs); 397 397 mIt.remove(); 398 398 } … … 401 401 // Easy Return 402 402 // ----------- 403 if ( dumpList.isEmpty()) {403 if (obsList.isEmpty()) { 404 404 return; 405 405 } … … 407 407 // Time of Epoch 408 408 // ------------- 409 const t_satObs& fObs = dumpList.first(); 410 QDateTime datTim = dateAndTimeFromGPSweek(fObs._time.gpsw(), fObs._time.gpssec()); 411 QDateTime datTimNom = dateAndTimeFromGPSweek(fObs._time.gpsw(), 412 floor(fObs._time.gpssec()+0.5)); 409 const t_satObs& fObs = obsList.first(); 410 QDateTime datTim = dateAndTimeFromGPSweek(fObs._time.gpsw(), fObs._time.gpssec()); 411 QDateTime datTimNom = dateAndTimeFromGPSweek(fObs._time.gpsw(), floor(fObs._time.gpssec()+0.5)); 413 412 414 413 // Close the file … … 422 421 // ------------------ 423 422 if (!_headerWritten) { 424 _header. _startTime.set(fObs._time.gpsw(), fObs._time.gpssec());423 _header.setStartTime(fObs._time); 425 424 writeHeader(format, datTimNom); 426 425 } 427 426 428 // Check whether observation types available 429 // ----------------------------------------- 430 QMutableListIterator<t_satObs> mItDump(dumpList); 431 while (mItDump.hasNext()) { 432 t_satObs& obs = mItDump.next(); 433 if (!_header._obsTypes.contains(obs._prn.system()) && !_header._obsTypes.contains(obs._prn.system())) { 434 mItDump.remove(); 435 } 436 } 437 if (dumpList.isEmpty()) { 438 return; 439 } 440 441 double sec = double(datTim.time().second()) + fmod(fObs._time.gpssec(),1.0); 442 443 // Epoch header line: RINEX Version 3 444 // ---------------------------------- 445 if (_header._version >= 3.0) { 446 _out << datTim.toString("> yyyy MM dd hh mm ").toAscii().data() 447 << setw(10) << setprecision(7) << sec 448 << " " << 0 << setw(3) << dumpList.size() << endl; 449 } 450 // Epoch header line: RINEX Version 2 451 // ---------------------------------- 452 else { 453 _out << datTim.toString(" yy MM dd hh mm ").toAscii().data() 454 << setw(10) << setprecision(7) << sec 455 << " " << 0 << setw(3) << dumpList.size(); 456 457 QListIterator<t_satObs> it(dumpList); int iSat = 0; 458 while (it.hasNext()) { 459 iSat++; 460 const t_satObs& obs = it.next(); 461 _out << obs._prn.toString(); 462 if (iSat == 12 && it.hasNext()) { 463 _out << endl << " "; 464 iSat = 0; 465 } 466 } 467 _out << endl; 468 } 469 470 QListIterator<t_satObs> it(dumpList); 427 // Prepare structure t_rnxEpo 428 // -------------------------- 429 t_rnxObsFile::t_rnxEpo rnxEpo; 430 rnxEpo.tt = fObs._time; 431 432 QListIterator<t_satObs> it(obsList); 471 433 while (it.hasNext()) { 472 const t_satObs& obs = it.next(); 473 474 // Cycle slips detection 475 // --------------------- 476 QString prn(obs._prn.toString().c_str()); 477 char lli1 = ' '; 478 char lli2 = ' '; 479 char lli5 = ' '; 480 char* lli = 0; 481 482 for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) { 483 const t_frqObs* frqObs = obs._obs[iFrq]; 484 QMap<QString, int>* slip_cnt = 0; 485 if (frqObs->_rnxType2ch[0] == '1') { 486 slip_cnt = &_slip_cnt_L1; 487 lli = &lli1; 488 } 489 else if (frqObs->_rnxType2ch[0] == '2') { 490 slip_cnt = &_slip_cnt_L2; 491 lli = &lli2; 492 } 493 else if (frqObs->_rnxType2ch[0] == '5') { 494 slip_cnt = &_slip_cnt_L5; 495 lli = &lli5; 496 } 497 else { 498 continue; 499 } 500 if (frqObs->_slip) { 501 if ( slip_cnt->find(prn) != slip_cnt->end() && 502 slip_cnt->find(prn).value() != frqObs->_slipCounter ) { 503 *lli = '1'; 504 } 505 } 506 (*slip_cnt)[prn] = frqObs->_slipCounter; 507 } 508 509 // Write the data 510 // -------------- 511 _out << rinexSatLine(obs, lli1, lli2, lli5) << endl; 512 } 513 434 const t_satObs& satObs = it.next(); 435 t_rnxObsFile::t_rnxSat rnxSat; 436 rnxSat.prn = satObs._prn; 437 438 rnxEpo.rnxSat.push_back(rnxSat); 439 } 440 441 // Write the epoch 442 // --------------- 443 QString outLines; 444 QTextStream outStream(&outLines); 445 t_rnxObsFile::writeEpoch(&outStream, _header, &rnxEpo); 446 447 _out << outLines.toAscii().data(); 514 448 _out.flush(); 515 449 } … … 518 452 //////////////////////////////////////////////////////////////////////////// 519 453 void bncRinex::closeFile() { 520 if (_header. _version== 3) {454 if (_header.version() == 3) { 521 455 _out << "> 4 1" << endl; 522 456 _out << "END OF FILE" << endl; … … 534 468 } 535 469 536 // One Line in RINEX v2 or v3537 ////////////////////////////////////////////////////////////////////////////538 string bncRinex::rinexSatLine(const t_satObs& obs, char lli1, char lli2, char lli5) {539 ostringstream str;540 str.setf(ios::showpoint | ios::fixed);541 542 if (_header._version >= 3.0) {543 str << obs._prn.toString();544 }545 546 const QString obsKinds = "LCDS";547 548 char sys = obs._prn.system();549 const QVector<QString>& types = _header._obsTypes[sys];550 for (int ii = 0; ii < types.size(); ii++) {551 if (_header._version < 3.0 && ii > 0 && ii % 5 == 0) {552 str << endl;553 }554 double obsValue = 0.0;555 char lli = ' ';556 QString rnxType = t_rnxObsFile::type2to3(sys, types[ii]);557 for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {558 const t_frqObs* frqObs = obs._obs[iFrq];559 for (int ik = 0; ik < obsKinds.length(); ik++) {560 QChar ch = obsKinds[ik];561 QString obsType = (ch + QString(frqObs->_rnxType2ch.c_str()));562 obsType = t_rnxObsFile::type2to3(sys, obsType).left(rnxType.length());563 if (rnxType == obsType) {564 if (ch == 'L' && frqObs->_phaseValid) {565 obsValue = frqObs->_phase;566 if (obsType[1] == '1') {567 lli = lli1;568 }569 else if (obsType[1] == '2') {570 lli = lli2;571 }572 else if (obsType[1] == '5') {573 lli = lli5;574 }575 }576 else if (ch == 'C' && frqObs->_codeValid) {577 obsValue = frqObs->_code;578 }579 else if (ch == 'D' && frqObs->_dopplerValid) {580 obsValue = frqObs->_doppler;581 }582 else if (ch == 'S' && frqObs->_snrValid) {583 obsValue = frqObs->_snr;584 }585 }586 }587 }588 str << setw(14) << setprecision(3) << obsValue << lli << ' ';589 }590 591 return str.str();592 }593 594 //595 ////////////////////////////////////////////////////////////////////////////596 string bncRinex::obsToStr(double val, int width, int precision) {597 if (val != 0.0) {598 ostringstream str;599 str.setf(ios::showpoint | ios::fixed);600 str << setw(width) << setprecision(precision) << val;601 return str.str();602 }603 else {604 return "0.0";605 }606 }607 608 470 // One Line in ASCII (Internal) Format 609 471 //////////////////////////////////////////////////////////////////////////// -
trunk/BNC/src/bncrinex.h
r6223 r6225 51 51 52 52 private: 53 std::string rinexSatLine(const t_satObs& obs, char lli1, char lli2, char lli5);54 static std::string obsToStr(double val, int width = 14, int precision = 3);55 53 void resolveFileName(const QDateTime& datTim); 56 54 bool readSkeleton(); -
trunk/BNC/src/rinex/rnxobsfile.h
r6222 r6225 41 41 42 42 friend class t_rnxObsFile; 43 friend class bncRinex;44 43 45 44 public: … … 51 50 ~t_rnxObsHeader(); 52 51 52 double version() const {return _version;} 53 53 t_irc read(QTextStream* stream, int maxLines = 0); 54 54 void setDefault(const QString& markerName, int version); … … 58 58 int nTypes(char sys) const; 59 59 QString obsType(char sys, int index, double version = 0.0) const; 60 void write(QTextStream* stream, const QMap<QString, QString>* txtMap = 0) const; 61 bncTime startTime() const {return _startTime;} 62 void setStartTime(const bncTime& startTime) {_startTime = startTime;} 63 64 private: 60 65 QStringList obsTypesStrings() const; 61 void write(QTextStream* stream, const QMap<QString, QString>* txtMap = 0) const; 62 63 private: 64 float _version; 66 double _version; 65 67 double _interval; 66 68 QString _antennaNumber; … … 120 122 ~t_rnxObsFile(); 121 123 122 floatversion() const {return _header._version;}124 double version() const {return _header._version;} 123 125 double interval() const {return _header._interval;} 124 126 int numSys() const {return _header.numSys();} … … 171 173 static QString type3to2(char sys, const QString& typeV3); 172 174 175 static void writeEpoch(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo) { 176 if (header.version() >= 3.0) { 177 writeEpochV3(stream, header, epo); 178 } 179 else { 180 writeEpochV2(stream, header, epo); 181 } 182 } 183 184 private: 173 185 static void writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo); 174 186 static void writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo); 175 176 private:177 187 t_rnxObsFile() {}; 178 188 void openRead(const QString& fileName); 179 189 void openWrite(const QString& fileName); 180 190 void close(); 181 void writeEpochV2(const t_rnxEpo* epo);182 void writeEpochV3(const t_rnxEpo* epo);183 191 t_rnxEpo* nextEpochV2(); 184 192 t_rnxEpo* nextEpochV3();
Note:
See TracChangeset
for help on using the changeset viewer.