Index: branches/BNC_2.12/src/RTCM3/ephEncoder.cpp
===================================================================
--- branches/BNC_2.12/src/RTCM3/ephEncoder.cpp	(revision 8806)
+++ branches/BNC_2.12/src/RTCM3/ephEncoder.cpp	(revision 8814)
@@ -15,18 +15,16 @@
   unsigned long long bitbuffer = 0;
   int ura = indexFromAccuracy(eph._ura, eph.type());
+  int L5Flag, SFlag;
+  
   if (eph.type() == t_eph::QZSS) {
     GPSADDBITS(12, 1044)
     GPSADDBITS(4,eph._prn.number())
     GPSADDBITS(16, static_cast<int>(eph._TOC.gpssec())>>4)
-    GPSADDBITSFLOAT(8, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)
-    /static_cast<double>(1<<25))
-    GPSADDBITSFLOAT(16, eph._clock_drift, 1.0/static_cast<double>(1<<30)
-    /static_cast<double>(1<<13))
-    GPSADDBITSFLOAT(22, eph._clock_bias, 1.0/static_cast<double>(1<<30)
-    /static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(8, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<25))
+    GPSADDBITSFLOAT(16, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(22, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITS(8, eph._IODE)
     GPSADDBITSFLOAT(16, eph._Crs, 1.0/static_cast<double>(1<<5))
-    GPSADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
     GPSADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITSFLOAT(16, eph._Cuc, 1.0/static_cast<double>(1<<29))
@@ -36,15 +34,11 @@
     GPSADDBITS(16, static_cast<int>(eph._TOEsec)>>4)
     GPSADDBITSFLOAT(16, eph._Cic, 1.0/static_cast<double>(1<<29))
-    GPSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITSFLOAT(16, eph._Cis, 1.0/static_cast<double>(1<<29))
     GPSADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITSFLOAT(16, eph._Crc, 1.0/static_cast<double>(1<<5))
-    GPSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<1))
-    GPSADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<13))
-    GPSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
     GPSADDBITS(2,eph._L2Codes)
     GPSADDBITS(10, eph._TOC.gpsw())
@@ -55,6 +49,50 @@
     GPSADDBITS(1, eph._fitInterval)
     GPSADDBITS(3, 0) /* padding */
-  }
-  else {
+ } else if (eph.type() == t_eph::IRNSS) {
+    GPSADDBITS(12, 29)
+    GPSADDBITS(6, eph._prn.number())
+    GPSADDBITS(10, eph._TOC.gpsw())
+    GPSADDBITSFLOAT(22, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(16, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(8, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<25))
+    GPSADDBITS(4, ura)
+    GPSADDBITS(16, static_cast<int>(eph._TOC.gpssec())>>4)
+    GPSADDBITSFLOAT(8, eph._TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(22, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<11))
+    GPSADDBITS(8, eph._IODE) // Issue Of Data Ephemeris and Clock
+    GPSADDBITS(10, 0) /* padding */
+    if        (eph._health == 0.0) {
+      L5Flag = 0;
+      SFlag  = 0;
+    } else if (eph._health == 1.0) {
+      L5Flag = 0;
+      SFlag  = 1;
+    } else if (eph._health == 2.0) {
+      L5Flag = 1;
+      SFlag  = 0;
+    } else if (eph._health == 3.0) {
+      L5Flag = 1;
+      SFlag  = 1;
+    }
+    GPSADDBITS(1, L5Flag)
+    GPSADDBITS(1, SFlag)
+    GPSADDBITSFLOAT(15, eph._Cuc, 1.0/static_cast<double>(1<<28))
+    GPSADDBITSFLOAT(15, eph._Cus, 1.0/static_cast<double>(1<<28))
+    GPSADDBITSFLOAT(15, eph._Cic, 1.0/static_cast<double>(1<<28))
+    GPSADDBITSFLOAT(15, eph._Cis, 1.0/static_cast<double>(1<<28))
+    GPSADDBITSFLOAT(15, eph._Crc, 1.0/static_cast<double>(1<< 4))
+    GPSADDBITSFLOAT(15, eph._Crs, 1.0/static_cast<double>(1<< 4))
+    GPSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+    GPSADDBITS(16, static_cast<int>(eph._TOEsec)>>4)
+    GPSADDBITSFLOAT(32, eph._e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
+    GPSADDBITSFLOAT(32, eph._sqrt_A, 1.0/static_cast<double>(1<<19))
+    GPSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(22, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<11))
+    GPSADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+    GPSADDBITS(2, 0) /* padding */
+    GPSADDBITS(2, 0) /* padding */
+  } else {
     GPSADDBITS(12, 1019)
     GPSADDBITS(6,eph._prn.number())
@@ -62,18 +100,13 @@
     GPSADDBITS(4, ura)
     GPSADDBITS(2,eph._L2Codes)
-    GPSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
     GPSADDBITS(8, eph._IODE)
     GPSADDBITS(16, static_cast<int>(eph._TOC.gpssec())>>4)
-    GPSADDBITSFLOAT(8, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)
-    /static_cast<double>(1<<25))
-    GPSADDBITSFLOAT(16, eph._clock_drift, 1.0/static_cast<double>(1<<30)
-    /static_cast<double>(1<<13))
-    GPSADDBITSFLOAT(22, eph._clock_bias, 1.0/static_cast<double>(1<<30)
-    /static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(8, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<25))
+    GPSADDBITSFLOAT(16, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(22, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITS(10, eph._IODC)
     GPSADDBITSFLOAT(16, eph._Crs, 1.0/static_cast<double>(1<<5))
-    GPSADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
     GPSADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITSFLOAT(16, eph._Cuc, 1.0/static_cast<double>(1<<29))
@@ -83,13 +116,10 @@
     GPSADDBITS(16, static_cast<int>(eph._TOEsec)>>4)
     GPSADDBITSFLOAT(16, eph._Cic, 1.0/static_cast<double>(1<<29))
-    GPSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITSFLOAT(16, eph._Cis, 1.0/static_cast<double>(1<<29))
     GPSADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITSFLOAT(16, eph._Crc, 1.0/static_cast<double>(1<<5))
-    GPSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<1))
-    GPSADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)
-    /static_cast<double>(1<<13))
+    GPSADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+    GPSADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
     GPSADDBITSFLOAT(8, eph._TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
     GPSADDBITS(6, eph._health)
@@ -190,16 +220,11 @@
   GALILEOADDBITS(10, eph._IODnav)
   GALILEOADDBITS(8, SISA)
-  GALILEOADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)
-  /static_cast<double>(1<<13))
+  GALILEOADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
   GALILEOADDBITS(14, eph._TOC.gpssec()/60)
-  GALILEOADDBITSFLOAT(6, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)
-  /static_cast<double>(1<<29))
-  GALILEOADDBITSFLOAT(21, eph._clock_drift, 1.0/static_cast<double>(1<<30)
-  /static_cast<double>(1<<16))
-  GALILEOADDBITSFLOAT(31, eph._clock_bias, 1.0/static_cast<double>(1<<30)
-  /static_cast<double>(1<<4))
+  GALILEOADDBITSFLOAT(6, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<29))
+  GALILEOADDBITSFLOAT(21, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<16))
+  GALILEOADDBITSFLOAT(31, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<4))
   GALILEOADDBITSFLOAT(16, eph._Crs, 1.0/static_cast<double>(1<<5))
-  GALILEOADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)
-  /static_cast<double>(1<<13))
+  GALILEOADDBITSFLOAT(16, eph._Delta_n, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
   GALILEOADDBITSFLOAT(32, eph._M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
   GALILEOADDBITSFLOAT(16, eph._Cuc, 1.0/static_cast<double>(1<<29))
@@ -209,26 +234,18 @@
   GALILEOADDBITS(14, eph._TOEsec/60)
   GALILEOADDBITSFLOAT(16, eph._Cic, 1.0/static_cast<double>(1<<29))
-  GALILEOADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)
-  /static_cast<double>(1<<1))
+  GALILEOADDBITSFLOAT(32, eph._OMEGA0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
   GALILEOADDBITSFLOAT(16, eph._Cis, 1.0/static_cast<double>(1<<29))
   GALILEOADDBITSFLOAT(32, eph._i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
   GALILEOADDBITSFLOAT(16, eph._Crc, 1.0/static_cast<double>(1<<5))
-  GALILEOADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)
-  /static_cast<double>(1<<1))
-  GALILEOADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)
-  /static_cast<double>(1<<13))
-  GALILEOADDBITSFLOAT(10, eph._BGD_1_5A, 1.0/static_cast<double>(1<<30)
-  /static_cast<double>(1<<2))
-  if(eph._inav)
-  {
-    GALILEOADDBITSFLOAT(10, eph._BGD_1_5B, 1.0/static_cast<double>(1<<30)
-    /static_cast<double>(1<<2))
+  GALILEOADDBITSFLOAT(32, eph._omega, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
+  GALILEOADDBITSFLOAT(24, eph._OMEGADOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
+  GALILEOADDBITSFLOAT(10, eph._BGD_1_5A, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<2))
+  if(eph._inav) {
+    GALILEOADDBITSFLOAT(10, eph._BGD_1_5B, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<2))
     GALILEOADDBITS(2, static_cast<int>(eph._E5bHS))
     GALILEOADDBITS(1, eph._e5bDataInValid ? 1 : 0)
     GALILEOADDBITS(2, static_cast<int>(eph._E1_bHS))
     GALILEOADDBITS(1, eph._e1DataInValid ? 1 : 0)
-  }
-  else
-  {
+  } else {
     GALILEOADDBITS(2, static_cast<int>(eph._E5aHS))
     GALILEOADDBITS(1,  eph._e5aDataInValid ? 1 : 0)
@@ -304,6 +321,5 @@
   BDSADDBITS(5, eph._AODE)
   BDSADDBITS(17, static_cast<int>(eph._TOC.bdssec())>>3)
-  BDSADDBITSFLOAT(11, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)
-      /static_cast<double>(1<<30)/static_cast<double>(1<<6))
+  BDSADDBITSFLOAT(11, eph._clock_driftrate, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<30)/static_cast<double>(1<<6))
   BDSADDBITSFLOAT(22, eph._clock_drift, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<20))
   BDSADDBITSFLOAT(24, eph._clock_bias, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
