Changeset 6137 in ntrip for trunk/BNC/src/bncrinex.cpp


Ignore:
Timestamp:
Sep 13, 2014, 12:19:37 PM (10 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncrinex.cpp

    r6120 r6137  
    439439// Stores Observation into Internal Array
    440440////////////////////////////////////////////////////////////////////////////
    441 void bncRinex::deepCopy(t_obs obs) {
     441void bncRinex::deepCopy(t_satObs obs) {
    442442  _obs.push_back(obs);
    443443}
     
    449449  // Select observations older than maxTime
    450450  // --------------------------------------
    451   QList<t_obs> dumpList;
    452   QMutableListIterator<t_obs> mIt(_obs);
     451  QList<t_satObs> dumpList;
     452  QMutableListIterator<t_satObs> mIt(_obs);
    453453  while (mIt.hasNext()) {
    454     t_obs obs = mIt.next();
    455     if (obs.GPSWeek * 7*24*3600 + obs.GPSWeeks < maxTime - 0.05) {
     454    t_satObs obs = mIt.next();
     455    if (obs._time.gpsw() * 7*24*3600 + obs._time.gpssec() < maxTime - 0.05) {
    456456      dumpList.push_back(obs);
    457457      mIt.remove();
     
    467467  // Time of Epoch
    468468  // -------------
    469   const t_obs& fObs   = dumpList.first();
    470   QDateTime datTim    = dateAndTimeFromGPSweek(fObs.GPSWeek, fObs.GPSWeeks);
    471   QDateTime datTimNom = dateAndTimeFromGPSweek(fObs.GPSWeek,
    472                                                floor(fObs.GPSWeeks+0.5));
     469  const t_satObs& fObs   = dumpList.first();
     470  QDateTime datTim    = dateAndTimeFromGPSweek(fObs._time.gpsw(), fObs._time.gpssec());
     471  QDateTime datTimNom = dateAndTimeFromGPSweek(fObs._time.gpsw(),
     472                                               floor(fObs._time.gpssec()+0.5));
    473473
    474474  // Close the file
     
    482482  // ------------------
    483483  if (!_headerWritten) {
    484     _header._startTime.set(fObs.GPSWeek, fObs.GPSWeeks);
     484    _header._startTime.set(fObs._time.gpsw(), fObs._time.gpssec());
    485485    writeHeader(format, datTimNom);
    486486  }
     
    488488  // Check whether observation types available
    489489  // -----------------------------------------
    490   QMutableListIterator<t_obs> mItDump(dumpList);
     490  QMutableListIterator<t_satObs> mItDump(dumpList);
    491491  while (mItDump.hasNext()) {
    492     t_obs& obs = mItDump.next();
    493     if (!_header._obsTypes.contains(obs.satSys) && !_header._obsTypes.contains(obs.satSys)) {
     492    t_satObs& obs = mItDump.next();
     493    if (!_header._obsTypes.contains(obs._prn.system()) && !_header._obsTypes.contains(obs._prn.system())) {
    494494      mItDump.remove();
    495495    }
     
    499499  }
    500500
    501   double sec = double(datTim.time().second()) + fmod(fObs.GPSWeeks,1.0);
     501  double sec = double(datTim.time().second()) + fmod(fObs._time.gpssec(),1.0);
    502502
    503503  // Epoch header line: RINEX Version 3
     
    515515         << "  " << 0 << setw(3)  << dumpList.size();
    516516
    517     QListIterator<t_obs> it(dumpList); int iSat = 0;
     517    QListIterator<t_satObs> it(dumpList); int iSat = 0;
    518518    while (it.hasNext()) {
    519519      iSat++;
    520       const t_obs& obs = it.next();
    521       _out << obs.satSys << setw(2) << obs.satNum;
     520      const t_satObs& obs = it.next();
     521      _out << obs._prn;
    522522      if (iSat == 12 && it.hasNext()) {
    523523        _out << endl << "                                ";
     
    528528  }
    529529
    530   QListIterator<t_obs> it(dumpList);
     530  QListIterator<t_satObs> it(dumpList);
    531531  while (it.hasNext()) {
    532     const t_obs& obs = it.next();
     532    const t_satObs& obs = it.next();
    533533
    534534    // Cycle slips detection
    535535    // ---------------------
    536     QString prn = QString("%1%2").arg(obs.satSys)
    537                             .arg(obs.satNum, 2, 10, QChar('0'));
    538 
    539     char lli1 = ' ';
    540     char lli2 = ' ';
    541     char lli5 = ' ';
    542     if      ( obs.slip_cnt_L1 >= 0 ) {
    543       if ( _slip_cnt_L1.find(prn)         != _slip_cnt_L1.end() &&
    544            _slip_cnt_L1.find(prn).value() != obs.slip_cnt_L1 ) {
    545         lli1 = '1';
    546       }
    547     }
    548 
    549     if ( obs.slip_cnt_L2 >= 0 ) {
    550       if ( _slip_cnt_L2.find(prn)         != _slip_cnt_L2.end() &&
    551            _slip_cnt_L2.find(prn).value() != obs.slip_cnt_L2 ) {
    552         lli2 = '1';
    553       }
    554     }
    555 
    556     if ( obs.slip_cnt_L5 >= 0 ) {
    557       if ( _slip_cnt_L5.find(prn)         != _slip_cnt_L5.end() &&
    558            _slip_cnt_L5.find(prn).value() != obs.slip_cnt_L5 ) {
    559         lli5 = '1';
    560       }
    561     }
    562 
    563     _slip_cnt_L1[prn]   = obs.slip_cnt_L1;
    564     _slip_cnt_L2[prn]   = obs.slip_cnt_L2;
    565     _slip_cnt_L5[prn]   = obs.slip_cnt_L5;
     536    QString prn(obs._prn.toString().c_str());
     537    char  lli1 = ' ';
     538    char  lli2 = ' ';
     539    char  lli5 = ' ';
     540    char* lli = 0;
     541
     542    for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
     543      const t_frqObs*     frqObs   = obs._obs[iFrq];
     544      QMap<QString, int>* slip_cnt = 0;
     545      if      (frqObs->_rnxType2ch[0] == '1') {
     546        slip_cnt  = &_slip_cnt_L1;
     547        lli       = &lli1;
     548      }
     549      else if (frqObs->_rnxType2ch[0] == '2') {
     550        slip_cnt  = &_slip_cnt_L2;
     551        lli       = &lli2;
     552      }
     553      else if (frqObs->_rnxType2ch[0] == '5') {
     554        slip_cnt  = &_slip_cnt_L5;
     555        lli       = &lli5;
     556      }
     557      else {
     558        continue;
     559      }
     560      if (frqObs->_slip) {
     561        if ( slip_cnt->find(prn)         != slip_cnt->end() &&
     562             slip_cnt->find(prn).value() != frqObs->_slipCounter ) {
     563          *lli = '1';
     564        }
     565      }
     566      (*slip_cnt)[prn] = frqObs->_slipCounter;
     567    }
    566568
    567569    // Write the data
     
    594596// One Line in RINEX v2 or v3
    595597////////////////////////////////////////////////////////////////////////////
    596 string bncRinex::rinexSatLine(const t_obs& obs, char lli1, char lli2,
    597                               char lli5) {
     598string bncRinex::rinexSatLine(const t_satObs& obs, char lli1, char lli2, char lli5) {
    598599  ostringstream str;
    599   str.setf(ios::showpoint | ios::fixed);
    600 
    601   if (_header._version >= 3.0) {
    602     str << obs.satSys
    603         << setw(2) << setfill('0') << obs.satNum << setfill(' ');
    604   }
    605 
    606   const QVector<QString>& types = _header._obsTypes[obs.satSys];
    607   for (int ii = 0; ii < types.size(); ii++) {
    608     if (_header._version < 3.0 && ii > 0 && ii % 5 == 0) {
    609       str << endl;
    610     }
    611     double value = obs.measdata(types[ii], _header._version);
    612     str << setw(14) << setprecision(3) << value;
    613     if      (value != 0.0 && types[ii].indexOf("L1") == 0) {
    614       str << lli1 << ' ';
    615     }
    616     else if (value != 0.0 && types[ii].indexOf("L2") == 0) {
    617       str << lli2 << ' ';
    618     }
    619     else if (value != 0.0 && types[ii].indexOf("L5") == 0) {
    620       str << lli5 << ' ';
    621     }
    622     else {
    623       str << "  ";
    624     }
    625   }
     600////  str.setf(ios::showpoint | ios::fixed);
     601////
     602////  if (_header._version >= 3.0) {
     603////    str << obs._prn;
     604////  }
     605////
     606////  const QVector<QString>& types = _header._obsTypes[obs._prn.system()];
     607////  for (int ii = 0; ii < types.size(); ii++) {
     608////    if (_header._version < 3.0 && ii > 0 && ii % 5 == 0) {
     609////      str << endl;
     610////    }
     611////    for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
     612////      const t_frqObs*     frqObs   = obs._obs[iFrq];
     613////
     614////
     615////    double value = obs.measdata(types[ii], _header._version);
     616////    str << setw(14) << setprecision(3) << value;
     617////    if      (value != 0.0 && types[ii].indexOf("L1") == 0) {
     618////      str << lli1 << ' ';
     619////    }
     620////    else if (value != 0.0 && types[ii].indexOf("L2") == 0) {
     621////      str << lli2 << ' ';
     622////    }
     623////    else if (value != 0.0 && types[ii].indexOf("L5") == 0) {
     624////      str << lli5 << ' ';
     625////    }
     626////    else {
     627////      str << "  ";
     628////    }
     629////  }
    626630
    627631  return str.str();
     
    644648// One Line in ASCII (Internal) Format
    645649////////////////////////////////////////////////////////////////////////////
    646 string bncRinex::asciiSatLine(const t_obs& obs) {
     650string bncRinex::asciiSatLine(const t_satObs& obs) {
    647651
    648652  ostringstream str;
    649   str.setf(ios::showpoint | ios::fixed);
    650 
    651   str << obs.satSys << setw(2) << setfill('0') << obs.satNum << setfill(' ');
    652 
    653   if (obs.satSys == 'R') { // Glonass
    654     str << ' ' << setw(2) << obs.slotNum << ' ';
    655   }
    656   else {
    657     str << "    ";
    658   }
    659 
    660   float rnxVers = 3.0;
    661 
    662   for (int ie = 0; ie < GNSSENTRY_NUMBER; ie++) {
    663     QString rnxStr = obs.rnxStr(ie);
    664     if (rnxStr.length() >= 2) {
    665       double data = obs.measdata(rnxStr, rnxVers);
    666       if (data != 0.0) {
    667         int width = (rnxStr[0] == 'S') ? 8 : 14;
    668         int prec  = 3;
    669         str << ' ' << rnxStr.toAscii().data()
    670             << ' ' << obsToStr(data, width, prec);
    671         if (rnxStr[0] == 'L') {
    672           int slipCnt = 0;
    673           if      (rnxStr[1] == '1') {
    674             slipCnt = obs.slip_cnt_L1;
    675           }
    676           else if (rnxStr[1] == '2') {
    677             slipCnt = obs.slip_cnt_L2;
    678           }
    679           else if (rnxStr[1] == '5') {
    680             slipCnt = obs.slip_cnt_L5;
    681           }
    682           str << ' ' << setw(3)  << slipCnt;
    683         }
    684       }
    685     }
    686   }
     653////  str.setf(ios::showpoint | ios::fixed);
     654////
     655////  str << obs._prn << ' ';
     656////
     657////  float rnxVers = 3.0;
     658////
     659////  for (int ie = 0; ie < GNSSENTRY_NUMBER; ie++) {
     660////    QString rnxStr = obs.rnxStr(ie);
     661////    if (rnxStr.length() >= 2) {
     662////      double data = obs.measdata(rnxStr, rnxVers);
     663////      if (data != 0.0) {
     664////        int width = (rnxStr[0] == 'S') ? 8 : 14;
     665////        int prec  = 3;
     666////        str << ' ' << rnxStr.toAscii().data()
     667////            << ' ' << obsToStr(data, width, prec);
     668////        if (rnxStr[0] == 'L') {
     669////          int slipCnt = 0;
     670////          if      (rnxStr[1] == '1') {
     671////            slipCnt = obs.slip_cnt_L1;
     672////          }
     673////          else if (rnxStr[1] == '2') {
     674////            slipCnt = obs.slip_cnt_L2;
     675////          }
     676////          else if (rnxStr[1] == '5') {
     677////            slipCnt = obs.slip_cnt_L5;
     678////          }
     679////          str << ' ' << setw(3)  << slipCnt;
     680////        }
     681////      }
     682////    }
     683////  }
    687684
    688685  return str.str();
Note: See TracChangeset for help on using the changeset viewer.