Index: trunk/BNC/src/ephemeris.cpp
===================================================================
--- trunk/BNC/src/ephemeris.cpp	(revision 6754)
+++ trunk/BNC/src/ephemeris.cpp	(revision 6755)
@@ -1336,4 +1336,5 @@
   // ------------
   int fieldLen = 19;
+  _URAI = -1; // undefined in RINEX format
 
   int pos[4];
@@ -1342,8 +1343,4 @@
   pos[2] = pos[1] + fieldLen;
   pos[3] = pos[2] + fieldLen;
-
-  double TOTs;
-  double TOEs;
-  double TOEw;
 
   // Read eight lines
@@ -1407,5 +1404,5 @@
 
     else if ( iLine == 3 ) {
-      if ( readDbl(line, pos[0], fieldLen, TOEs   )  ||
+      if ( readDbl(line, pos[0], fieldLen, _TOEs   )  ||
            readDbl(line, pos[1], fieldLen, _Cic   )  ||
            readDbl(line, pos[2], fieldLen, _OMEGA0)  ||
@@ -1428,5 +1425,5 @@
     else if ( iLine == 5 ) {
       if ( readDbl(line, pos[0], fieldLen, _IDOT    ) ||
-           readDbl(line, pos[2], fieldLen, TOEw)    ) {
+           readDbl(line, pos[2], fieldLen, _TOEw)    ) {
         _checkState = bad;
         return;
@@ -1436,5 +1433,6 @@
     else if ( iLine == 6 ) {
       double SatH1;
-      if ( readDbl(line, pos[1], fieldLen, SatH1) ||
+      if ( readDbl(line, pos[0], fieldLen, _URA ) ||
+           readDbl(line, pos[1], fieldLen, SatH1) ||
            readDbl(line, pos[2], fieldLen, _TGD1) ||
            readDbl(line, pos[3], fieldLen, _TGD2) ) {
@@ -1447,11 +1445,11 @@
     else if ( iLine == 7 ) {
       double aodc;
-      if ( readDbl(line, pos[0], fieldLen, TOTs) ||
+      if ( readDbl(line, pos[0], fieldLen, _TOTs) ||
            readDbl(line, pos[1], fieldLen, aodc) ) {
         _checkState = bad;
         return;
       }
-      if (TOTs == 0.9999e9) {  // 0.9999e9 means not known (RINEX standard)
-        TOTs = TOEs;
+      if (_TOTs == 0.9999e9) {  // 0.9999e9 means not known (RINEX standard)
+        _TOTs = _TOEs;
       }
       _AODC = int(aodc);
@@ -1459,6 +1457,6 @@
   }
 
-  TOEw += 1356;  // BDT -> GPS week number
-  _TOE_bdt.set(int(TOEw), TOEs);
+  _TOEw += 1356;  // BDT -> GPS week number
+  _TOE_bdt.set(int(_TOEw), _TOEs);
 
   // GPS->BDT
@@ -1475,4 +1473,10 @@
 ////////////////////////////////////////////////////////////////////////////
 void t_ephBDS::set(const bdsephemeris* ee) {
+
+  // RINEX File entries
+  // --------------------
+  _TOTs = 0.0;
+  _TOEs = 0.0;
+  _TOEw = 0.0;
 
   _receptDateTime = currentDateAndTimeGPS();
@@ -1677,9 +1681,13 @@
     .arg(_sqrt_A, 19, 'e', 12);
 
-  out << QString(fmt)
-    .arg(_TOE_bdt.gpssec(), 19, 'e', 12)
-    .arg(_Cic,              19, 'e', 12)
-    .arg(_OMEGA0,           19, 'e', 12)
-    .arg(_Cis,              19, 'e', 12);
+  double toes = _TOEs;
+  if (!toes) { // RTCM stream input
+    toes = _TOE_bdt.gpssec();
+  }
+  out << QString(fmt)
+    .arg(toes,   19, 'e', 12)
+    .arg(_Cic,    19, 'e', 12)
+    .arg(_OMEGA0, 19, 'e', 12)
+    .arg(_Cis,    19, 'e', 12);
 
   out << QString(fmt)
@@ -1689,11 +1697,15 @@
     .arg(_OMEGADOT, 19, 'e', 12);
 
-  out << QString(fmt)
-    .arg(_IDOT,                            19, 'e', 12)
-    .arg(0.0,                              19, 'e', 12)
-    .arg(double(_TOE_bdt.gpsw() - 1356.0), 19, 'e', 12)
-    .arg(0.0,                              19, 'e', 12);
-
-  double ura = 0.0;
+  double toew = _TOEw;
+  if (!toew) { // RTCM stream input
+    toew = double(_TOE_bdt.gpsw() - 1356.0);
+  }
+  out << QString(fmt)
+    .arg(_IDOT, 19, 'e', 12)
+    .arg(0.0,   19, 'e', 12)
+    .arg(toew,  19, 'e', 12)
+    .arg(0.0,   19, 'e', 12);
+
+  double ura = _URA; // RINEX file input
   if ((_URAI <  6) && (_URAI >= 0)) {
     ura = ceil(10.0 * pow(2.0, ((double)_URAI/2.0) + 1.0)) / 10.0;
@@ -1702,5 +1714,4 @@
     ura = ceil(10.0 * pow(2.0, ((double)_URAI/2.0)      )) / 10.0;
   }
-
   out << QString(fmt)
     .arg(ura,            19, 'e', 12)
@@ -1709,9 +1720,13 @@
     .arg(_TGD2,          19, 'e', 12);
 
-  out << QString(fmt)
-    .arg(_TOE_bdt.gpssec(), 19, 'e', 12)
-    .arg(double(_AODC),     19, 'e', 12)
-    .arg("",                19, QChar(' '))
-    .arg("",                19, QChar(' '));
+  double tots = _TOTs;
+  if (!tots) { // RTCM stream input
+    tots = _TOE_bdt.gpssec();
+  }
+  out << QString(fmt)
+    .arg(tots,         19, 'e', 12)
+    .arg(double(_AODC), 19, 'e', 12)
+    .arg("",            19, QChar(' '))
+    .arg("",            19, QChar(' '));
   return rnxStr;
 }
Index: trunk/BNC/src/ephemeris.h
===================================================================
--- trunk/BNC/src/ephemeris.h	(revision 6754)
+++ trunk/BNC/src/ephemeris.h	(revision 6755)
@@ -260,5 +260,6 @@
   int     _AODE;
   int     _AODC;
-  int     _URAI;             //  [0..15]
+  int     _URAI;             //  [0..15] from RTCM stream
+  double  _URA;              //  [m]     from RINEX file
   double  _clock_bias;       //  [s]    
   double  _clock_drift;      //  [s/s]  
@@ -282,4 +283,7 @@
   double  _TGD2;             //  [s]    
   int     _SatH1;            // 
+  double  _TOTs;             //  [s] of BDT week; RINEX file entry
+  double  _TOEs;             //  [s] of BDT week; RINEX file entry
+  double  _TOEw;             //  [-] BDT week; RINEX file entry
 };
 
