Index: trunk/BNC/src/rinex/reqcedit.cpp
===================================================================
--- trunk/BNC/src/rinex/reqcedit.cpp	(revision 9760)
+++ trunk/BNC/src/rinex/reqcedit.cpp	(revision 9765)
@@ -63,9 +63,12 @@
   _outNavFileName = settings.value("reqcOutNavFile").toString();
   int version     = settings.value("reqcRnxVersion").toInt();
-  if (version < 3) {
+  if (version == 2) {
     _rnxVersion = defaultRnxObsVersion2;
   }
-  else {
+  if (version == 3) {
     _rnxVersion = defaultRnxObsVersion3;
+  }
+  if (version == 4) {
+    _rnxVersion = defaultRnxObsVersion4;
   }
   _samplingRate   = settings.value("reqcSampling").toString().split("sec").first().toDouble();
@@ -601,9 +604,19 @@
   outNavFile.setGlonass(haveGlonass);
 
-  if ( (haveGPS && haveGlonass) || _rnxVersion >= 3.0) {
+  if (_rnxVersion < 3.0) {
+    if (haveGPS && haveGlonass) {
+      outNavFile.setVersion(defaultRnxNavVersion3);
+    }
+    if (haveGPS && !haveGlonass) {
+      outNavFile.setVersion(defaultRnxNavVersion2);
+    }
+  }
+
+  if (_rnxVersion >= 3.0 &&  _rnxVersion < 4.0) {
     outNavFile.setVersion(defaultRnxNavVersion3);
   }
-  else {
-    outNavFile.setVersion(defaultRnxNavVersion2);
+
+  if (_rnxVersion >= 4.0) {
+    outNavFile.setVersion(defaultRnxNavVersion4);
   }
 
@@ -626,5 +639,12 @@
   }
 
-  outNavFile.writeHeader(&txtMap);
+  int mergedNavFiles = _navFileNames.size();
+  unsigned year, month, day;
+  int gps_utc = 0;
+  if (_ephs.size()) {
+    _ephs.at(0)->TOC().civil_date(year, month, day);
+    gps_utc = gnumleap(year, month, day);
+  }
+  outNavFile.writeHeader(&txtMap, mergedNavFiles, gps_utc);
 
   // Loop over all ephemerides
@@ -645,4 +665,8 @@
     }
     if (eph->checkState() == t_eph::bad) {
+      continue;
+    }
+    if (outNavFile.version() >= 4.0 &&
+        eph->navType() == t_eph::undefined) { // input files < version 4.0
       continue;
     }
Index: trunk/BNC/src/rinex/rnxnavfile.cpp
===================================================================
--- trunk/BNC/src/rinex/rnxnavfile.cpp	(revision 9760)
+++ trunk/BNC/src/rinex/rnxnavfile.cpp	(revision 9765)
@@ -146,14 +146,40 @@
 ////////////////////////////////////////////////////////////////////////////
 void t_rnxNavFile::read(QTextStream* stream) {
+  QString navTypeStr;
 
   while (stream->status() == QTextStream::Ok && !stream->atEnd()) {
+
     QString line = stream->readLine();
     if (line.isEmpty()) {
       continue;
     }
+
     QStringList hlp = line.split(QRegExp("\\s+"), QString::SkipEmptyParts);
+    QString firstStr = hlp.at(0);
     QString prn;
-    if (version() >= 3.0) {
-      prn = hlp.at(0);
+
+    if      (version() >= 3.0 &&  firstStr != ">") {
+      prn = firstStr;
+    }
+    else if (version() >= 4.0 && firstStr == ">") {
+      int lines2skip = 0;
+      QString key = hlp.at(1);
+      // EPH is used
+      if (key == "EPH") {
+          navTypeStr = hlp.at(3);
+      }
+      // all others are currently ignored
+      else if (key == "STO") {
+        lines2skip = 2;
+      }
+      else if (key == "EOP" || key == "ION") {
+        lines2skip = 3;
+      }
+      if (lines2skip) {
+        for (int ii = 1; ii < lines2skip; ii++) {
+          stream->readLine();
+        }
+      }
+      continue;
     }
     else {
@@ -213,4 +239,13 @@
       }
       eph = new t_ephGPS(version(), lines);
+    }
+    else {
+      continue;
+    }
+    if (version() >= 4.0) {
+      if (eph->setNavType(navTypeStr) != success) {
+        delete eph;
+        continue;
+      }
     }
     _ephs.push_back(eph);
@@ -264,5 +299,5 @@
 //
 ////////////////////////////////////////////////////////////////////////////
-void t_rnxNavFile::writeHeader(const QMap<QString, QString>* txtMap) {
+void t_rnxNavFile::writeHeader(const QMap<QString, QString>* txtMap, int numMergedFiles, int leapSecs) {
 
   QString     runBy = BNC_CORE->userName();
@@ -334,4 +369,12 @@
            << "PGM / RUN BY / DATE\n";
 
+  if (version() >= 4.0) {
+    *_stream << QString("%1").arg(leapSecs, 6, 10, QLatin1Char(' ')).left(60).leftJustified(60)
+        << "LEAP SECONDS\n";
+
+    *_stream << QString("%1").arg(numMergedFiles, 19, 10, QLatin1Char(' ')).leftJustified(60)
+        << "MERGED FILE\n";
+  }
+
   QStringListIterator itCmnt(comments);
   while (itCmnt.hasNext()) {
@@ -339,4 +382,5 @@
   }
 
+
   *_stream << QString()
     .leftJustified(60)
Index: trunk/BNC/src/rinex/rnxnavfile.h
===================================================================
--- trunk/BNC/src/rinex/rnxnavfile.h	(revision 9760)
+++ trunk/BNC/src/rinex/rnxnavfile.h	(revision 9765)
@@ -25,5 +25,5 @@
 #ifndef RNXNAVFILE_H
 #define RNXNAVFILE_H
-
+#include <iostream>
 #include <queue>
 #include <QtCore>
@@ -35,5 +35,5 @@
 class bncPPPclient;
 class t_eph;
-
+using namespace std;
 #define defaultRnxNavVersion2 2.11
 #define defaultRnxNavVersion3 3.05
@@ -68,5 +68,5 @@
   void   setGlonass(bool glo) {_header._glonass = glo;}
   void   setGnssTypeV3(t_eph::e_type sys) {_header._satSys = sys;}
-  void   writeHeader(const QMap<QString, QString>* txtMap = 0);
+  void   writeHeader(const QMap<QString, QString>* txtMap = 0, int numMergedFiles = 0, int leapSecs = 0);
   void   writeEph(const t_eph* eph);
 
