Changeset 7474 in ntrip for trunk


Ignore:
Timestamp:
Sep 29, 2015, 9:29:30 AM (9 years ago)
Author:
stuerze
Message:

in case of RINEX3 to RINEX 2 conversion now some comment lines are written into the RINEX header

Location:
trunk/BNC/src/rinex
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/rinex/reqcedit.cpp

    r7280 r7474  
    3535 * Created:    11-Apr-2012
    3636 *
    37  * Changes:   
     37 * Changes:
    3838 *
    3939 * -----------------------------------------------------------------------*/
     
    8888}
    8989
    90 // 
     90//
    9191////////////////////////////////////////////////////////////////////////////
    9292void t_reqcEdit::run() {
    93  
     93
    9494  // Open Log File
    9595  // -------------
     
    120120          << _samplingRate << endl;
    121121    *_log << QByteArray("Start time").leftJustified(15) << ": "
    122           << _begTime.datestr().c_str() << ' ' 
     122          << _begTime.datestr().c_str() << ' '
    123123          << _begTime.timestr(0).c_str() << endl;
    124124    *_log << QByteArray("End time").leftJustified(15) << ": "
    125           << _endTime.datestr().c_str() << ' ' 
     125          << _endTime.datestr().c_str() << ' '
    126126          << _endTime.timestr(0).c_str() << endl;
    127127    *_log << QByteArray("Input Obs Files").leftJustified(15) << ": "
     
    159159// Initialize input observation files, sort them according to start time
    160160////////////////////////////////////////////////////////////////////////////
    161 void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames, 
     161void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames,
    162162                                 QVector<t_rnxObsFile*>& rnxObsFiles,
    163163                                 QTextStream* log) {
     
    172172      QListIterator<QFileInfo> it(dir.entryInfoList(filters));
    173173      while (it.hasNext()) {
    174         QString filePath = it.next().filePath(); 
     174        QString filePath = it.next().filePath();
    175175        t_rnxObsFile* rnxObsFile = 0;
    176176        try {
     
    199199    }
    200200  }
    201   qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(), 
     201  qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(),
    202202              t_rnxObsFile::earlierStartTime);
    203203}
    204204
    205 // 
     205//
    206206////////////////////////////////////////////////////////////////////////////
    207207void t_reqcEdit::editObservations() {
     
    218218  // ----------------------------------
    219219  t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
    220  
     220
    221221  // Select observation types
    222222  // ------------------------
     
    296296    t_rnxObsFile* obsFile = _rnxObsFiles[ii];
    297297    if (_log) {
    298       *_log << "Processing File: " << obsFile->fileName() << "  start: " 
    299             << obsFile->startTime().datestr().c_str() << ' ' 
     298      *_log << "Processing File: " << obsFile->fileName() << "  start: "
     299            << obsFile->startTime().datestr().c_str() << ' '
    300300            << obsFile->startTime().timestr(0).c_str() << endl;
    301301    }
     
    320320        txtMap["COMMENT"]  = comment;
    321321      }
     322      if (int(_rnxVersion) < int(obsFile->header().version())) {
     323        addRnxConversionDetails(obsFile, txtMap);
     324      }
    322325      outObsFile.header().write(outObsFile.stream(), &txtMap);
    323326    }
     
    331334          break;
    332335        }
    333      
    334         if (_samplingRate == 0 || 
     336
     337        if (_samplingRate == 0 ||
    335338            fmod(round(epo->tt.gpssec()), _samplingRate) == 0) {
    336339          applyLLI(obsFile, epo);
     
    347350      }
    348351      else {
    349         qDebug() << str;   
     352        qDebug() << str;
    350353      }
    351354      return;
     
    363366}
    364367
    365 // Change RINEX Header Content 
     368// Change RINEX Header Content
    366369////////////////////////////////////////////////////////////////////////////
    367370void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
     
    372375  QString newMarkerName   = settings.value("reqcNewMarkerName").toString();
    373376  if (!newMarkerName.isEmpty()) {
    374     if (oldMarkerName.isEmpty() || 
     377    if (oldMarkerName.isEmpty() ||
    375378        QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
    376379      obsFile.setMarkerName(newMarkerName);
     
    381384  QString newAntennaName  = settings.value("reqcNewAntennaName").toString();
    382385  if (!newAntennaName.isEmpty()) {
    383     if (oldAntennaName.isEmpty() || 
     386    if (oldAntennaName.isEmpty() ||
    384387        QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
    385388      obsFile.setAntennaName(newAntennaName);
     
    426429  QString newReceiverType = settings.value("reqcNewReceiverName").toString();
    427430  if (!newReceiverType.isEmpty()) {
    428     if (oldReceiverType.isEmpty() || 
     431    if (oldReceiverType.isEmpty() ||
    429432        QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
    430433      obsFile.setReceiverType(newReceiverType);
     
    442445}
    443446
    444 // 
    445 ////////////////////////////////////////////////////////////////////////////
    446 void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile, 
     447//
     448////////////////////////////////////////////////////////////////////////////
     449void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile,
    447450                             const t_rnxObsFile::t_rnxEpo* epo) {
    448451
     
    467470  }
    468471}
    469  
    470 // 
    471 ////////////////////////////////////////////////////////////////////////////
    472 void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile, 
     472
     473//
     474////////////////////////////////////////////////////////////////////////////
     475void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile,
    473476                          t_rnxObsFile::t_rnxEpo* epo) {
    474  
     477
    475478 if (_samplingRate == 0) {
    476479    return;
     
    509512      QListIterator<QFileInfo> it(dir.entryInfoList(filters));
    510513      while (it.hasNext()) {
    511         QString filePath = it.next().filePath(); 
     514        QString filePath = it.next().filePath();
    512515        appendEphemerides(filePath, ephs);
    513516      }
     
    520523}
    521524
    522 // 
     525//
    523526////////////////////////////////////////////////////////////////////////////
    524527void t_reqcEdit::editEphemerides() {
     
    594597}
    595598
    596 // 
     599//
    597600////////////////////////////////////////////////////////////////////////////
    598601void t_reqcEdit::appendEphemerides(const QString& fileName,
     
    633636  }
    634637}
     638
     639void t_reqcEdit::addRnxConversionDetails(const t_rnxObsFile* obsFile,
     640                                          QMap<QString, QString>& txtMap) {
     641
     642  int key = 0;
     643  QString systems = obsFile->header().usedSystems();
     644  QString comment = QString("RINEX 3 => 2 CONVERSION DETAILS:");
     645  QString commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
     646  txtMap.insert(commentKey, comment);
     647
     648  for(int ii = 0; ii < obsFile->numSys(); ii++) {
     649    key++;
     650    char sys = systems[ii].toAscii();
     651    QString preferredAttrib = obsFile->signalPriorities(sys);
     652    comment = QString("%1: Signal priority = %2").arg(sys).arg(preferredAttrib);
     653    commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
     654    txtMap.insert(commentKey, comment);
     655    QStringList types = obsFile->header().obsTypes(sys);
     656    for (int jj = 0; jj < types.size(); jj++) {
     657      key++;
     658      QString inType = types[jj];
     659      for (int iPref = 0; iPref < preferredAttrib.length(); iPref++) {
     660        if (preferredAttrib[iPref] == '?'                             ||
     661            (inType.length() == 2 && preferredAttrib[iPref] == '_'    ) ||
     662            (inType.length() == 3 && preferredAttrib[iPref] == inType[2]) ) {
     663          QString outType = t_rnxObsFile::type3to2(sys, inType);
     664          comment = QString("%1: %2 => %3").arg(sys).arg(inType).arg(outType);
     665          commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
     666          txtMap.insert(commentKey, comment);
     667          break;
     668        }
     669      }
     670    }
     671  }
     672}
  • trunk/BNC/src/rinex/reqcedit.h

    r5738 r7474  
    3333class t_reqcEdit : public QThread {
    3434Q_OBJECT
    35  
     35
    3636 public:
    3737  t_reqcEdit(QObject* parent);
     
    4242 signals:
    4343  void finished();
    44    
     44
    4545 public slots:
    4646
    4747 public:
    4848  virtual void run();
    49   static void initRnxObsFiles(const QStringList& obsFileNames, 
     49  static void initRnxObsFiles(const QStringList& obsFileNames,
    5050                              QVector<t_rnxObsFile*>& rnxObsFiles,
    5151                              QTextStream* log);
     
    5353                              QVector<t_eph*>& ephs);
    5454  static void appendEphemerides(const QString& fileName, QVector<t_eph*>& ephs);
    55  
     55
    5656 private:
    5757  void editObservations();
     
    6060  void rememberLLI(const t_rnxObsFile* obsFile, const t_rnxObsFile::t_rnxEpo* epo);
    6161  void applyLLI(const t_rnxObsFile* obsFile, t_rnxObsFile::t_rnxEpo* epo);
     62  void addRnxConversionDetails(const t_rnxObsFile* obsFile, QMap<QString, QString>& txtMap);
    6263
    6364  QString                _logFileName;
  • trunk/BNC/src/rinex/rnxobsfile.cpp

    r6943 r7474  
    3535 * Created:    24-Jan-2012
    3636 *
    37  * Changes:   
     37 * Changes:
    3838 *
    3939 * -----------------------------------------------------------------------*/
     
    310310  _obsTypes.clear();
    311311  if (_version < 3.0) {
    312     _obsTypes['G'] << "C1" << "P1" << "L1" << "S1" 
     312    _obsTypes['G'] << "C1" << "P1" << "L1" << "S1"
    313313                   << "C2" << "P2" << "L2" << "S2";
    314314    _obsTypes['R'] = _obsTypes['G'];
     
    319319  }
    320320  else {
    321     _obsTypes['G'] << "C1C" << "L1C"  << "S1C" 
     321    _obsTypes['G'] << "C1C" << "L1C"  << "S1C"
    322322                   << "C1W" << "L1W"  << "S1W"
    323323                   << "C2X" << "L2X"  << "S2X"
    324                    << "C2W" << "L2W"  << "S2W" 
     324                   << "C2W" << "L2W"  << "S2W"
    325325                   << "C5X" << "L5X"  << "S5X";
    326326
    327327    _obsTypes['J'] = _obsTypes['G'];
    328    
    329     _obsTypes['R'] << "C1C" << "L1C" << "S1C" 
     328
     329    _obsTypes['R'] << "C1C" << "L1C" << "S1C"
    330330                   << "C2P" << "L2P" << "S2P";
    331    
     331
    332332    _obsTypes['E'] << "C1X" << "L1X" << "SX1"
    333333                   << "C5X" << "L5X" << "SX5"
    334334                   << "C7X" << "L7X" << "SX7"
    335335                   << "C8X" << "L8X" << "SX8";
    336    
     336
    337337    _obsTypes['S'] << "C1C" << "L1C" << "S1C"
    338338                   << "C5I" << "L5I" << "S5I"
    339339                   << "C5Q" << "L5Q" << "S5Q";
    340    
     340
    341341    _obsTypes['C'] << "C2I" << "L2I" << "S2I"
    342342                   << "C6I" << "L6I" << "S6I"
     
    359359    _version = t_rnxObsHeader::defaultRnxObsVersion3;
    360360  }
    361   _interval        = header._interval;   
    362   _antennaNumber   = header._antennaNumber; 
    363   _antennaName     = header._antennaName; 
    364   _markerName      = header._markerName; 
    365   _markerNumber    = header._markerNumber; 
     361  _interval        = header._interval;
     362  _antennaNumber   = header._antennaNumber;
     363  _antennaName     = header._antennaName;
     364  _markerName      = header._markerName;
     365  _markerNumber    = header._markerNumber;
    366366  _markerType      = header._markerType;
    367   _antNEU          = header._antNEU;     
    368   _antXYZ          = header._antXYZ;     
    369   _antBSG          = header._antBSG;     
    370   _xyz             = header._xyz;         
    371   _observer        = header._observer;       
    372   _agency          = header._agency;         
    373   _receiverNumber  = header._receiverNumber; 
    374   _receiverType    = header._receiverType;   
     367  _antNEU          = header._antNEU;
     368  _antXYZ          = header._antXYZ;
     369  _antBSG          = header._antBSG;
     370  _xyz             = header._xyz;
     371  _observer        = header._observer;
     372  _agency          = header._agency;
     373  _receiverNumber  = header._receiverNumber;
     374  _receiverType    = header._receiverType;
    375375  _receiverVersion = header._receiverVersion;
    376   _startTime       = header._startTime;   
     376  _startTime       = header._startTime;
    377377  _comments        = header._comments;
    378378  _usedSystems     = header._usedSystems;
    379379
    380380  for (unsigned iPrn = 1; iPrn <= t_prn::MAXPRN_GPS; iPrn++) {
    381     _wlFactorsL1[iPrn] =  header._wlFactorsL1[iPrn]; 
    382     _wlFactorsL2[iPrn] =  header._wlFactorsL2[iPrn]; 
     381    _wlFactorsL1[iPrn] =  header._wlFactorsL1[iPrn];
     382    _wlFactorsL2[iPrn] =  header._wlFactorsL2[iPrn];
    383383  }
    384384
     
    444444        for (int iSys = 0; iSys < _usedSystems.length(); iSys++) {
    445445          char    sys  = _usedSystems[iSys].toAscii();
    446           QString type = _version >= 3.0 ? t_rnxObsFile::type2to3(sys, useObsTypes->at(iType)) : 
     446          QString type = _version >= 3.0 ? t_rnxObsFile::type2to3(sys, useObsTypes->at(iType)) :
    447447                                           t_rnxObsFile::type3to2(sys, useObsTypes->at(iType));
    448448          if (!_obsTypes[sys].contains(type)) {
     
    523523
    524524  if (txtMap) {
    525     QMapIterator<QString, QString> it(*txtMap);
     525   QMapIterator<QString, QString> it(*txtMap);
    526526    while (it.hasNext()) {
    527527      it.next();
     
    529529        runBy = it.value();
    530530      }
    531       else if (it.key() == "COMMENT") {
    532         newComments = it.value().split("\\n", QString::SkipEmptyParts);
     531      else if ((it.key().indexOf("COMMENT")) != -1) {
     532        newComments += it.value().split("\\n", QString::SkipEmptyParts);
    533533      }
    534534    }
     
    570570    .leftJustified(60)
    571571           << "MARKER TYPE\n";
    572            
     572
    573573  *stream << QString("%1%2")
    574574    .arg(_observer, -20)
     
    766766}
    767767
    768 // 
     768//
    769769////////////////////////////////////////////////////////////////////////////
    770770char t_rnxObsHeader::system(int iSys) const {
     
    781781}
    782782
     783//
     784////////////////////////////////////////////////////////////////////////////
     785QString t_rnxObsHeader::usedSystems(void) const {
     786  return _usedSystems;
     787}
     788
     789QStringList t_rnxObsHeader::obsTypes(char sys) const {
     790  if (_obsTypes.contains(sys)) {
     791    return _obsTypes[sys];
     792  }
     793  else {
     794    return QStringList();
     795  }
     796}
     797
    783798// Number of Observation Types (satellite-system specific)
    784799////////////////////////////////////////////////////////////////////////////
     
    873888    QTextStream(&hlp) << QString("%1").arg(_obsTypes[sys0].size(), 6);
    874889    for (int ii = 0; ii < _obsTypes[sys0].size(); ii++) {
    875       QTextStream(&hlp) << QString("%1").arg(_obsTypes[sys0][ii], 6);   
     890      QTextStream(&hlp) << QString("%1").arg(_obsTypes[sys0][ii], 6);
    876891      if ((ii+1) % 9 == 0 || ii == _obsTypes[sys0].size()-1) {
    877892        strList.append(hlp.leftJustified(60) + "# / TYPES OF OBSERV\n");
     
    887902      for (int iType = 0; iType < nTypes(sys); iType++) {
    888903        QString type = obsType(sys, iType);
    889         QTextStream(&hlp) << QString(" %1").arg(type, -3);   
     904        QTextStream(&hlp) << QString(" %1").arg(type, -3);
    890905        if ((iType+1) % 13 == 0 || iType == nTypes(sys)-1) {
    891906          strList.append(hlp.leftJustified(60) + "SYS / # / OBS TYPES\n");
     
    9851000// Handle Special Epoch Flag
    9861001////////////////////////////////////////////////////////////////////////////
    987 void t_rnxObsFile::handleEpochFlag(int flag, const QString& line, 
     1002void t_rnxObsFile::handleEpochFlag(int flag, const QString& line,
    9881003                                   bool& headerReRead) {
    9891004
     
    10031018
    10041019  // Re-Read Header
    1005   // -------------- 
     1020  // --------------
    10061021  else if (flag == 3 || flag == 4 || flag == 5) {
    10071022    int numLines = 0;
     
    10771092    int numSat;
    10781093    readInt(line, 32, 3, numSat);
    1079  
     1094
    10801095    _currEpo.rnxSat.resize(numSat);
    10811096
     
    10901105        int pos = 3 + 16*iType;
    10911106        double obsValue = 0.0;
    1092         int    lli      = 0; 
     1107        int    lli      = 0;
    10931108        int    snr      = 0;
    10941109        readDbl(line, pos,     14, obsValue);
     
    11541169    int numSat;
    11551170    readInt(line, 29, 3, numSat);
    1156  
     1171
    11571172    _currEpo.rnxSat.resize(numSat);
    11581173
     
    11721187      int satNum; readInt(line, pos + 1, 2, satNum);
    11731188      _currEpo.rnxSat[iSat].prn.set(sys, satNum);
    1174  
     1189
    11751190      pos += 3;
    11761191    }
     
    12061221      }
    12071222    }
    1208  
     1223
    12091224    _flgPowerFail = false;
    12101225
    12111226    return &_currEpo;
    12121227  }
    1213  
     1228
    12141229  return 0;
    12151230}
     
    12261241    const t_rnxSat& rnxSat = epo->rnxSat[ii];
    12271242    if (_header._obsTypes[rnxSat.prn.system()].size() > 0) {
    1228       epoLocal.rnxSat.push_back(rnxSat);   
     1243      epoLocal.rnxSat.push_back(rnxSat);
    12291244    }
    12301245  }
     
    12401255// Write Data Epoch (RINEX Version 2)
    12411256////////////////////////////////////////////////////////////////////////////
    1242 void t_rnxObsFile::writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header, 
     1257void t_rnxObsFile::writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header,
    12431258                                const t_rnxEpo* epo) {
    12441259
     
    12781293      QString typeV2 = header.obsType(sys, iTypeV2);
    12791294      bool    found  = false;
    1280    
     1295
    12811296      QString preferredAttrib = signalPriorities(sys);
    12821297      for (int iPref = 0; iPref < preferredAttrib.length(); iPref++) {
     
    13241339// Write Data Epoch (RINEX Version 3)
    13251340////////////////////////////////////////////////////////////////////////////
    1326 void t_rnxObsFile::writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header, 
     1341void t_rnxObsFile::writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header,
    13271342                                const t_rnxEpo* epo) {
    13281343
     
    14311446// Set Observations from RINEX File
    14321447////////////////////////////////////////////////////////////////////////////
    1433 void t_rnxObsFile::setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo, 
     1448void t_rnxObsFile::setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo,
    14341449                                 const t_rnxObsFile::t_rnxSat& rnxSat, t_satObs& obs) {
    14351450  obs._staID = rnxObsFile->markerName().toAscii().constData();
     
    14611476      if (rnxObs.value != 0.0) {
    14621477        string type2ch(typeV3.mid(1).toAscii().data());
    1463        
     1478
    14641479        t_frqObs* frqObs = 0;
    14651480        for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
     
    14741489          obs._obs.push_back(frqObs);
    14751490        }
    1476        
     1491
    14771492        switch( typeV3.toAscii().data()[0] ) {
    14781493        case 'C':
  • trunk/BNC/src/rinex/rnxobsfile.h

    r6941 r7474  
    6262  int         numGloSlots() const;
    6363  QString     obsType(char sys, int index, double version = 0.0) const;
     64  QString     usedSystems() const;
     65  QStringList obsTypes(char sys) const;
    6466  QStringList phaseShifts() const;
    6567  QStringList gloBiases() const;
     
    136138  t_rnxObsFile(const QString& fileName, e_inpOut inpOut);
    137139  ~t_rnxObsFile();
    138  
     140
    139141  double         version() const {return _header._version;}
    140142  double         interval() const {return _header._interval;}
     
    177179  void  setStartTime(const bncTime& startTime) {_header._startTime = startTime;}
    178180
    179   t_rnxEpo* nextEpoch(); 
     181  t_rnxEpo* nextEpoch();
    180182
    181183  int wlFactorL1(unsigned iPrn) {
     
    198200  QTextStream* stream() {return _stream;}
    199201
    200   static void setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo, 
     202  static void setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo,
    201203                            const t_rnxObsFile::t_rnxSat& rnxSat, t_satObs& obs);
    202204
    203205  static QString type2to3(char sys, const QString& typeV2);
    204206  static QString type3to2(char sys, const QString& typeV3);
     207  static QString signalPriorities(char sys);
    205208
    206209  static void writeEpoch(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo) {
     
    216219  static void writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
    217220  static void writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
    218   static QString signalPriorities(char sys);
    219221  t_rnxObsFile() {};
    220222  void openRead(const QString& fileName);
Note: See TracChangeset for help on using the changeset viewer.