Index: trunk/BNC/src/rinex/reqcedit.cpp
===================================================================
--- trunk/BNC/src/rinex/reqcedit.cpp	(revision 7280)
+++ trunk/BNC/src/rinex/reqcedit.cpp	(revision 7474)
@@ -35,5 +35,5 @@
  * Created:    11-Apr-2012
  *
- * Changes:    
+ * Changes:
  *
  * -----------------------------------------------------------------------*/
@@ -88,8 +88,8 @@
 }
 
-//  
+//
 ////////////////////////////////////////////////////////////////////////////
 void t_reqcEdit::run() {
- 
+
   // Open Log File
   // -------------
@@ -120,8 +120,8 @@
           << _samplingRate << endl;
     *_log << QByteArray("Start time").leftJustified(15) << ": "
-          << _begTime.datestr().c_str() << ' ' 
+          << _begTime.datestr().c_str() << ' '
           << _begTime.timestr(0).c_str() << endl;
     *_log << QByteArray("End time").leftJustified(15) << ": "
-          << _endTime.datestr().c_str() << ' ' 
+          << _endTime.datestr().c_str() << ' '
           << _endTime.timestr(0).c_str() << endl;
     *_log << QByteArray("Input Obs Files").leftJustified(15) << ": "
@@ -159,5 +159,5 @@
 // Initialize input observation files, sort them according to start time
 ////////////////////////////////////////////////////////////////////////////
-void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames, 
+void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames,
                                  QVector<t_rnxObsFile*>& rnxObsFiles,
                                  QTextStream* log) {
@@ -172,5 +172,5 @@
       QListIterator<QFileInfo> it(dir.entryInfoList(filters));
       while (it.hasNext()) {
-        QString filePath = it.next().filePath(); 
+        QString filePath = it.next().filePath();
         t_rnxObsFile* rnxObsFile = 0;
         try {
@@ -199,9 +199,9 @@
     }
   }
-  qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(), 
+  qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(),
               t_rnxObsFile::earlierStartTime);
 }
 
-//  
+//
 ////////////////////////////////////////////////////////////////////////////
 void t_reqcEdit::editObservations() {
@@ -218,5 +218,5 @@
   // ----------------------------------
   t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
-  
+
   // Select observation types
   // ------------------------
@@ -296,6 +296,6 @@
     t_rnxObsFile* obsFile = _rnxObsFiles[ii];
     if (_log) {
-      *_log << "Processing File: " << obsFile->fileName() << "  start: " 
-            << obsFile->startTime().datestr().c_str() << ' ' 
+      *_log << "Processing File: " << obsFile->fileName() << "  start: "
+            << obsFile->startTime().datestr().c_str() << ' '
             << obsFile->startTime().timestr(0).c_str() << endl;
     }
@@ -320,4 +320,7 @@
         txtMap["COMMENT"]  = comment;
       }
+      if (int(_rnxVersion) < int(obsFile->header().version())) {
+        addRnxConversionDetails(obsFile, txtMap);
+      }
       outObsFile.header().write(outObsFile.stream(), &txtMap);
     }
@@ -331,6 +334,6 @@
           break;
         }
-      
-        if (_samplingRate == 0 || 
+
+        if (_samplingRate == 0 ||
             fmod(round(epo->tt.gpssec()), _samplingRate) == 0) {
           applyLLI(obsFile, epo);
@@ -347,5 +350,5 @@
       }
       else {
-        qDebug() << str;    
+        qDebug() << str;
       }
       return;
@@ -363,5 +366,5 @@
 }
 
-// Change RINEX Header Content  
+// Change RINEX Header Content
 ////////////////////////////////////////////////////////////////////////////
 void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
@@ -372,5 +375,5 @@
   QString newMarkerName   = settings.value("reqcNewMarkerName").toString();
   if (!newMarkerName.isEmpty()) {
-    if (oldMarkerName.isEmpty() || 
+    if (oldMarkerName.isEmpty() ||
         QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
       obsFile.setMarkerName(newMarkerName);
@@ -381,5 +384,5 @@
   QString newAntennaName  = settings.value("reqcNewAntennaName").toString();
   if (!newAntennaName.isEmpty()) {
-    if (oldAntennaName.isEmpty() || 
+    if (oldAntennaName.isEmpty() ||
         QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
       obsFile.setAntennaName(newAntennaName);
@@ -426,5 +429,5 @@
   QString newReceiverType = settings.value("reqcNewReceiverName").toString();
   if (!newReceiverType.isEmpty()) {
-    if (oldReceiverType.isEmpty() || 
+    if (oldReceiverType.isEmpty() ||
         QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
       obsFile.setReceiverType(newReceiverType);
@@ -442,7 +445,7 @@
 }
 
-// 
-////////////////////////////////////////////////////////////////////////////
-void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile, 
+//
+////////////////////////////////////////////////////////////////////////////
+void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile,
                              const t_rnxObsFile::t_rnxEpo* epo) {
 
@@ -467,10 +470,10 @@
   }
 }
-  
-// 
-////////////////////////////////////////////////////////////////////////////
-void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile, 
+
+//
+////////////////////////////////////////////////////////////////////////////
+void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile,
                           t_rnxObsFile::t_rnxEpo* epo) {
- 
+
  if (_samplingRate == 0) {
     return;
@@ -509,5 +512,5 @@
       QListIterator<QFileInfo> it(dir.entryInfoList(filters));
       while (it.hasNext()) {
-        QString filePath = it.next().filePath(); 
+        QString filePath = it.next().filePath();
         appendEphemerides(filePath, ephs);
       }
@@ -520,5 +523,5 @@
 }
 
-//  
+//
 ////////////////////////////////////////////////////////////////////////////
 void t_reqcEdit::editEphemerides() {
@@ -594,5 +597,5 @@
 }
 
-//  
+//
 ////////////////////////////////////////////////////////////////////////////
 void t_reqcEdit::appendEphemerides(const QString& fileName,
@@ -633,2 +636,37 @@
   }
 }
+
+void t_reqcEdit::addRnxConversionDetails(const t_rnxObsFile* obsFile,
+                                          QMap<QString, QString>& txtMap) {
+
+  int key = 0;
+  QString systems = obsFile->header().usedSystems();
+  QString comment = QString("RINEX 3 => 2 CONVERSION DETAILS:");
+  QString commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
+  txtMap.insert(commentKey, comment);
+
+  for(int ii = 0; ii < obsFile->numSys(); ii++) {
+    key++;
+    char sys = systems[ii].toAscii();
+    QString preferredAttrib = obsFile->signalPriorities(sys);
+    comment = QString("%1: Signal priority = %2").arg(sys).arg(preferredAttrib);
+    commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
+    txtMap.insert(commentKey, comment);
+    QStringList types = obsFile->header().obsTypes(sys);
+    for (int jj = 0; jj < types.size(); jj++) {
+      key++;
+      QString inType = types[jj];
+      for (int iPref = 0; iPref < preferredAttrib.length(); iPref++) {
+        if (preferredAttrib[iPref] == '?'                             ||
+            (inType.length() == 2 && preferredAttrib[iPref] == '_'    ) ||
+            (inType.length() == 3 && preferredAttrib[iPref] == inType[2]) ) {
+          QString outType = t_rnxObsFile::type3to2(sys, inType);
+          comment = QString("%1: %2 => %3").arg(sys).arg(inType).arg(outType);
+          commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
+          txtMap.insert(commentKey, comment);
+          break;
+        }
+      }
+    }
+  }
+}
Index: trunk/BNC/src/rinex/reqcedit.h
===================================================================
--- trunk/BNC/src/rinex/reqcedit.h	(revision 7280)
+++ trunk/BNC/src/rinex/reqcedit.h	(revision 7474)
@@ -33,5 +33,5 @@
 class t_reqcEdit : public QThread {
 Q_OBJECT
- 
+
  public:
   t_reqcEdit(QObject* parent);
@@ -42,10 +42,10 @@
  signals:
   void finished();
-   
+
  public slots:
 
  public:
   virtual void run();
-  static void initRnxObsFiles(const QStringList& obsFileNames, 
+  static void initRnxObsFiles(const QStringList& obsFileNames,
                               QVector<t_rnxObsFile*>& rnxObsFiles,
                               QTextStream* log);
@@ -53,5 +53,5 @@
                               QVector<t_eph*>& ephs);
   static void appendEphemerides(const QString& fileName, QVector<t_eph*>& ephs);
- 
+
  private:
   void editObservations();
@@ -60,4 +60,5 @@
   void rememberLLI(const t_rnxObsFile* obsFile, const t_rnxObsFile::t_rnxEpo* epo);
   void applyLLI(const t_rnxObsFile* obsFile, t_rnxObsFile::t_rnxEpo* epo);
+  void addRnxConversionDetails(const t_rnxObsFile* obsFile, QMap<QString, QString>& txtMap);
 
   QString                _logFileName;
Index: trunk/BNC/src/rinex/rnxobsfile.cpp
===================================================================
--- trunk/BNC/src/rinex/rnxobsfile.cpp	(revision 7280)
+++ trunk/BNC/src/rinex/rnxobsfile.cpp	(revision 7474)
@@ -35,5 +35,5 @@
  * Created:    24-Jan-2012
  *
- * Changes:    
+ * Changes:
  *
  * -----------------------------------------------------------------------*/
@@ -310,5 +310,5 @@
   _obsTypes.clear();
   if (_version < 3.0) {
-    _obsTypes['G'] << "C1" << "P1" << "L1" << "S1" 
+    _obsTypes['G'] << "C1" << "P1" << "L1" << "S1"
                    << "C2" << "P2" << "L2" << "S2";
     _obsTypes['R'] = _obsTypes['G'];
@@ -319,24 +319,24 @@
   }
   else {
-    _obsTypes['G'] << "C1C" << "L1C"  << "S1C" 
+    _obsTypes['G'] << "C1C" << "L1C"  << "S1C"
                    << "C1W" << "L1W"  << "S1W"
                    << "C2X" << "L2X"  << "S2X"
-                   << "C2W" << "L2W"  << "S2W" 
+                   << "C2W" << "L2W"  << "S2W"
                    << "C5X" << "L5X"  << "S5X";
 
     _obsTypes['J'] = _obsTypes['G'];
-    
-    _obsTypes['R'] << "C1C" << "L1C" << "S1C" 
+
+    _obsTypes['R'] << "C1C" << "L1C" << "S1C"
                    << "C2P" << "L2P" << "S2P";
-    
+
     _obsTypes['E'] << "C1X" << "L1X" << "SX1"
                    << "C5X" << "L5X" << "SX5"
                    << "C7X" << "L7X" << "SX7"
                    << "C8X" << "L8X" << "SX8";
-    
+
     _obsTypes['S'] << "C1C" << "L1C" << "S1C"
                    << "C5I" << "L5I" << "S5I"
                    << "C5Q" << "L5Q" << "S5Q";
-    
+
     _obsTypes['C'] << "C2I" << "L2I" << "S2I"
                    << "C6I" << "L6I" << "S6I"
@@ -359,26 +359,26 @@
     _version = t_rnxObsHeader::defaultRnxObsVersion3;
   }
-  _interval        = header._interval;    
-  _antennaNumber   = header._antennaNumber; 
-  _antennaName     = header._antennaName; 
-  _markerName      = header._markerName;  
-  _markerNumber    = header._markerNumber;  
+  _interval        = header._interval;
+  _antennaNumber   = header._antennaNumber;
+  _antennaName     = header._antennaName;
+  _markerName      = header._markerName;
+  _markerNumber    = header._markerNumber;
   _markerType      = header._markerType;
-  _antNEU          = header._antNEU;      
-  _antXYZ          = header._antXYZ;      
-  _antBSG          = header._antBSG;      
-  _xyz             = header._xyz;         
-  _observer        = header._observer;       
-  _agency          = header._agency;         
-  _receiverNumber  = header._receiverNumber; 
-  _receiverType    = header._receiverType;   
+  _antNEU          = header._antNEU;
+  _antXYZ          = header._antXYZ;
+  _antBSG          = header._antBSG;
+  _xyz             = header._xyz;
+  _observer        = header._observer;
+  _agency          = header._agency;
+  _receiverNumber  = header._receiverNumber;
+  _receiverType    = header._receiverType;
   _receiverVersion = header._receiverVersion;
-  _startTime       = header._startTime;   
+  _startTime       = header._startTime;
   _comments        = header._comments;
   _usedSystems     = header._usedSystems;
 
   for (unsigned iPrn = 1; iPrn <= t_prn::MAXPRN_GPS; iPrn++) {
-    _wlFactorsL1[iPrn] =  header._wlFactorsL1[iPrn]; 
-    _wlFactorsL2[iPrn] =  header._wlFactorsL2[iPrn]; 
+    _wlFactorsL1[iPrn] =  header._wlFactorsL1[iPrn];
+    _wlFactorsL2[iPrn] =  header._wlFactorsL2[iPrn];
   }
 
@@ -444,5 +444,5 @@
         for (int iSys = 0; iSys < _usedSystems.length(); iSys++) {
           char    sys  = _usedSystems[iSys].toAscii();
-          QString type = _version >= 3.0 ? t_rnxObsFile::type2to3(sys, useObsTypes->at(iType)) : 
+          QString type = _version >= 3.0 ? t_rnxObsFile::type2to3(sys, useObsTypes->at(iType)) :
                                            t_rnxObsFile::type3to2(sys, useObsTypes->at(iType));
           if (!_obsTypes[sys].contains(type)) {
@@ -523,5 +523,5 @@
 
   if (txtMap) {
-    QMapIterator<QString, QString> it(*txtMap);
+   QMapIterator<QString, QString> it(*txtMap);
     while (it.hasNext()) {
       it.next();
@@ -529,6 +529,6 @@
         runBy = it.value();
       }
-      else if (it.key() == "COMMENT") {
-        newComments = it.value().split("\\n", QString::SkipEmptyParts);
+      else if ((it.key().indexOf("COMMENT")) != -1) {
+        newComments += it.value().split("\\n", QString::SkipEmptyParts);
       }
     }
@@ -570,5 +570,5 @@
     .leftJustified(60)
            << "MARKER TYPE\n";
-           
+
   *stream << QString("%1%2")
     .arg(_observer, -20)
@@ -766,5 +766,5 @@
 }
 
-// 
+//
 ////////////////////////////////////////////////////////////////////////////
 char t_rnxObsHeader::system(int iSys) const {
@@ -781,4 +781,19 @@
 }
 
+//
+////////////////////////////////////////////////////////////////////////////
+QString t_rnxObsHeader::usedSystems(void) const {
+  return _usedSystems;
+}
+
+QStringList t_rnxObsHeader::obsTypes(char sys) const {
+  if (_obsTypes.contains(sys)) {
+    return _obsTypes[sys];
+  }
+  else {
+    return QStringList();
+  }
+}
+
 // Number of Observation Types (satellite-system specific)
 ////////////////////////////////////////////////////////////////////////////
@@ -873,5 +888,5 @@
     QTextStream(&hlp) << QString("%1").arg(_obsTypes[sys0].size(), 6);
     for (int ii = 0; ii < _obsTypes[sys0].size(); ii++) {
-      QTextStream(&hlp) << QString("%1").arg(_obsTypes[sys0][ii], 6);   
+      QTextStream(&hlp) << QString("%1").arg(_obsTypes[sys0][ii], 6);
       if ((ii+1) % 9 == 0 || ii == _obsTypes[sys0].size()-1) {
         strList.append(hlp.leftJustified(60) + "# / TYPES OF OBSERV\n");
@@ -887,5 +902,5 @@
       for (int iType = 0; iType < nTypes(sys); iType++) {
         QString type = obsType(sys, iType);
-        QTextStream(&hlp) << QString(" %1").arg(type, -3);   
+        QTextStream(&hlp) << QString(" %1").arg(type, -3);
         if ((iType+1) % 13 == 0 || iType == nTypes(sys)-1) {
           strList.append(hlp.leftJustified(60) + "SYS / # / OBS TYPES\n");
@@ -985,5 +1000,5 @@
 // Handle Special Epoch Flag
 ////////////////////////////////////////////////////////////////////////////
-void t_rnxObsFile::handleEpochFlag(int flag, const QString& line, 
+void t_rnxObsFile::handleEpochFlag(int flag, const QString& line,
                                    bool& headerReRead) {
 
@@ -1003,5 +1018,5 @@
 
   // Re-Read Header
-  // -------------- 
+  // --------------
   else if (flag == 3 || flag == 4 || flag == 5) {
     int numLines = 0;
@@ -1077,5 +1092,5 @@
     int numSat;
     readInt(line, 32, 3, numSat);
-  
+
     _currEpo.rnxSat.resize(numSat);
 
@@ -1090,5 +1105,5 @@
         int pos = 3 + 16*iType;
         double obsValue = 0.0;
-        int    lli      = 0; 
+        int    lli      = 0;
         int    snr      = 0;
         readDbl(line, pos,     14, obsValue);
@@ -1154,5 +1169,5 @@
     int numSat;
     readInt(line, 29, 3, numSat);
-  
+
     _currEpo.rnxSat.resize(numSat);
 
@@ -1172,5 +1187,5 @@
       int satNum; readInt(line, pos + 1, 2, satNum);
       _currEpo.rnxSat[iSat].prn.set(sys, satNum);
- 
+
       pos += 3;
     }
@@ -1206,10 +1221,10 @@
       }
     }
- 
+
     _flgPowerFail = false;
 
     return &_currEpo;
   }
- 
+
   return 0;
 }
@@ -1226,5 +1241,5 @@
     const t_rnxSat& rnxSat = epo->rnxSat[ii];
     if (_header._obsTypes[rnxSat.prn.system()].size() > 0) {
-      epoLocal.rnxSat.push_back(rnxSat);    
+      epoLocal.rnxSat.push_back(rnxSat);
     }
   }
@@ -1240,5 +1255,5 @@
 // Write Data Epoch (RINEX Version 2)
 ////////////////////////////////////////////////////////////////////////////
-void t_rnxObsFile::writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header, 
+void t_rnxObsFile::writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header,
                                 const t_rnxEpo* epo) {
 
@@ -1278,5 +1293,5 @@
       QString typeV2 = header.obsType(sys, iTypeV2);
       bool    found  = false;
-   
+
       QString preferredAttrib = signalPriorities(sys);
       for (int iPref = 0; iPref < preferredAttrib.length(); iPref++) {
@@ -1324,5 +1339,5 @@
 // Write Data Epoch (RINEX Version 3)
 ////////////////////////////////////////////////////////////////////////////
-void t_rnxObsFile::writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header, 
+void t_rnxObsFile::writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header,
                                 const t_rnxEpo* epo) {
 
@@ -1431,5 +1446,5 @@
 // Set Observations from RINEX File
 ////////////////////////////////////////////////////////////////////////////
-void t_rnxObsFile::setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo, 
+void t_rnxObsFile::setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo,
                                  const t_rnxObsFile::t_rnxSat& rnxSat, t_satObs& obs) {
   obs._staID = rnxObsFile->markerName().toAscii().constData();
@@ -1461,5 +1476,5 @@
       if (rnxObs.value != 0.0) {
         string type2ch(typeV3.mid(1).toAscii().data());
-        
+
         t_frqObs* frqObs = 0;
         for (unsigned iFrq = 0; iFrq < obs._obs.size(); iFrq++) {
@@ -1474,5 +1489,5 @@
           obs._obs.push_back(frqObs);
         }
-        
+
         switch( typeV3.toAscii().data()[0] ) {
         case 'C':
Index: trunk/BNC/src/rinex/rnxobsfile.h
===================================================================
--- trunk/BNC/src/rinex/rnxobsfile.h	(revision 7280)
+++ trunk/BNC/src/rinex/rnxobsfile.h	(revision 7474)
@@ -62,4 +62,6 @@
   int         numGloSlots() const;
   QString     obsType(char sys, int index, double version = 0.0) const;
+  QString     usedSystems() const;
+  QStringList obsTypes(char sys) const;
   QStringList phaseShifts() const;
   QStringList gloBiases() const;
@@ -136,5 +138,5 @@
   t_rnxObsFile(const QString& fileName, e_inpOut inpOut);
   ~t_rnxObsFile();
-  
+
   double         version() const {return _header._version;}
   double         interval() const {return _header._interval;}
@@ -177,5 +179,5 @@
   void  setStartTime(const bncTime& startTime) {_header._startTime = startTime;}
 
-  t_rnxEpo* nextEpoch(); 
+  t_rnxEpo* nextEpoch();
 
   int wlFactorL1(unsigned iPrn) {
@@ -198,9 +200,10 @@
   QTextStream* stream() {return _stream;}
 
-  static void setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo, 
+  static void setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo,
                             const t_rnxObsFile::t_rnxSat& rnxSat, t_satObs& obs);
 
   static QString type2to3(char sys, const QString& typeV2);
   static QString type3to2(char sys, const QString& typeV3);
+  static QString signalPriorities(char sys);
 
   static void writeEpoch(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo) {
@@ -216,5 +219,4 @@
   static void writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
   static void writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
-  static QString signalPriorities(char sys);
   t_rnxObsFile() {};
   void openRead(const QString& fileName);
