Index: trunk/BNC/src/RTCM3/ephEncoder.cpp
===================================================================
--- trunk/BNC/src/RTCM3/ephEncoder.cpp	(revision 6798)
+++ trunk/BNC/src/RTCM3/ephEncoder.cpp	(revision 6799)
@@ -45,53 +45,5 @@
   int numbits = 0;
   unsigned long long bitbuffer = 0;
-  if (eph._ura <= 2.40){
-    eph._ura = 0;
-  }
-  else if (eph._ura <= 3.40){
-    eph._ura = 1;
-  }
-  else if (eph._ura <= 6.85){
-    eph._ura = 2;
-  }
-  else if (eph._ura <= 9.65){
-    eph._ura = 3;
-  }
-  else if (eph._ura <= 13.65){
-    eph._ura = 4;
-  }
-  else if (eph._ura <= 24.00){
-    eph._ura = 5;
-  }
-  else if (eph._ura <= 48.00){
-    eph._ura = 6;
-  }
-  else if (eph._ura <= 96.00){
-    eph._ura = 7;
-  }
-  else if (eph._ura <= 192.00){
-    eph._ura = 8;
-  }
-  else if (eph._ura <= 384.00){
-    eph._ura = 9;
-  }
-  else if (eph._ura <= 768.00){
-    eph._ura = 10;
-  }
-  else if (eph._ura <= 1536.00){
-    eph._ura = 11;
-  }
-  else if (eph._ura <= 1536.00){
-    eph._ura = 12;
-  }
-  else if (eph._ura <= 2072.00){
-    eph._ura = 13;
-  }
-  else if (eph._ura <= 6144.00){
-    eph._ura = 14;
-  }
-  else{
-    eph._ura = 15;
-  }
-
+  eph._ura = indexFromAccuracy(eph._ura, eph.type());
   GPSADDBITS(12, 1019)
   if (eph._prn.system() == 'J') {
@@ -256,6 +208,7 @@
   buffer= buffer+3;
 
+  eph._SISA = indexFromAccuracy(eph._SISA, eph.type());
+
   bool inav = ( (eph._flags & GALEPHF_INAV) == GALEPHF_INAV );
-
   GALILEOADDBITS(12, inav ? 1046 : 1045)
   GALILEOADDBITS(6, eph._prn.number())
@@ -340,4 +293,5 @@
   buffer= buffer+3;
 
+  eph._ura = indexFromAccuracy(eph._ura, eph.type());
   SBASADDBITS(12, 1043)
   SBASADDBITS(6, eph._prn.number()-20)
@@ -388,8 +342,9 @@
   buffer= buffer+3;
 
+  eph._URA = indexFromAccuracy(eph._URA, eph.type());
   BDSADDBITS(12, RTCM3ID_BDS)
   BDSADDBITS(6, eph._prn.number())
   BDSADDBITS(13, eph._TOC_bdt.gpsw() - 1356.0)
-  BDSADDBITS(4, eph._URAI);
+  BDSADDBITS(4, eph._URA);
   BDSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
   BDSADDBITS(5, eph._AODE)
Index: trunk/BNC/src/RTCM3/ephEncoder.h
===================================================================
--- trunk/BNC/src/RTCM3/ephEncoder.h	(revision 6798)
+++ trunk/BNC/src/RTCM3/ephEncoder.h	(revision 6799)
@@ -3,4 +3,5 @@
 
 #include "ephemeris.h"
+#include "bncutils.h"
 
 class t_ephEncoder {
Index: trunk/BNC/src/bncutils.cpp
===================================================================
--- trunk/BNC/src/bncutils.cpp	(revision 6798)
+++ trunk/BNC/src/bncutils.cpp	(revision 6799)
@@ -644,2 +644,106 @@
 }
 
+double accuracyFromIndex(int index, t_eph::e_type type) {
+
+  if (type == t_eph::GPS || type == t_eph::BDS || type == t_eph::SBAS
+      || type == t_eph::QZSS) {
+
+    if ((index >= 0) && (index <= 6)) {
+      if (index == 3) {
+        return ceil(10.0 * pow(2.0, (double(index) / 2.0) + 1.0)) / 10.0;
+      }
+      else {
+        return floor(10.0 * pow(2.0, (double(index) / 2.0) + 1.0)) / 10.0;
+      }
+    }
+    else if ((index > 6) && (index <= 15)) {
+      return (10.0 * pow(2.0, (double(index) - 2.0))) / 10.0;
+    }
+    else {
+      return 8192.0;
+    }
+  }
+
+  if (type == t_eph::Galileo) {
+
+    if ((index >= 0) && (index <= 49)) {
+      return (double(index) / 100.0);
+    }
+    else if ((index > 49) && (index <= 74)) {
+      return (50.0 + (double(index) - 50.0) * 2.0) / 100.0;
+    }
+    else if ((index > 74) && (index <= 99)) {
+      return 1.0 + (double(index) - 75.0) * 0.04;
+    }
+    else if ((index > 99) && (index <= 125)) {
+      return 2.0 + (double(index) - 100.0) * 0.16;
+    }
+    else {
+      return -1.0;
+    }
+  }
+
+  return double(index);
+}
+
+int indexFromAccuracy(double accuracy, t_eph::e_type type) {
+
+  if (type == t_eph::GPS || type == t_eph::BDS || type == t_eph::SBAS
+      || type == t_eph::QZSS) {
+
+    if (accuracy <= 2.40) {
+      return 0;
+    }
+    else if (accuracy <= 3.40) {
+      return 1;
+    }
+    else if (accuracy <= 4.85) {
+      return 2;
+    }
+    else if (accuracy <= 6.85) {
+      return 3;
+    }
+    else if (accuracy <= 9.65) {
+      return 4;
+    }
+    else if (accuracy <= 13.65) {
+      return 5;
+    }
+    else if (accuracy <= 24.00) {
+      return 6;
+    }
+    else if (accuracy <= 48.00) {
+      return 7;
+    }
+    else if (accuracy <= 96.00) {
+      return 8;
+    }
+    else if (accuracy <= 192.00) {
+      return 9;
+    }
+    else if (accuracy <= 384.00) {
+      return 10;
+    }
+    else if (accuracy <= 768.00) {
+      return 11;
+    }
+    else if (accuracy <= 1536.00) {
+      return 12;
+    }
+    else if (accuracy <= 3072.00) {
+      return 13;
+    }
+    else if (accuracy <= 6144.00) {
+      return 14;
+    }
+    else {
+      return 15;
+    }
+  }
+
+  if (type == t_eph::Galileo) {
+    //TODO: implement conversion
+  }
+
+  return (type == t_eph::Galileo) ? 255 : 15;
+}
Index: trunk/BNC/src/bncutils.h
===================================================================
--- trunk/BNC/src/bncutils.h	(revision 6798)
+++ trunk/BNC/src/bncutils.h	(revision 6799)
@@ -33,4 +33,5 @@
 #include <newmat.h>
 #include <bncconst.h>
+#include <ephemeris.h>
 
 void         expandEnvVar(QString& str);
@@ -109,3 +110,7 @@
 void         stripWhiteSpace(std::string& str);
 
+double       accuracyFromIndex(int index, t_eph::e_type type);
+
+int          indexFromAccuracy(double accuracy, t_eph::e_type type);
+
 #endif
Index: trunk/BNC/src/ephemeris.cpp
===================================================================
--- trunk/BNC/src/ephemeris.cpp	(revision 6798)
+++ trunk/BNC/src/ephemeris.cpp	(revision 6799)
@@ -135,10 +135,6 @@
   _L2PFlag  = 0.0;
 
-  if (ee->URAindex <= 6) {
-    _ura = ceil(10.0*pow(2.0, 1.0+((double)ee->URAindex)/2.0))/10.0;
-  }
-  else {
-    _ura = ceil(10.0*pow(2.0, ((double)ee->URAindex)/2.0))/10.0;
-  }
+  _ura = accuracyFromIndex(ee->URAindex, type());
+
   _health   = ee->SVhealth;
   _TGD      = ee->TGD;
@@ -461,19 +457,5 @@
   _TOEweek  = ee->Week;
   
-  if ((ee->SISA >= 0) && (ee->SISA <= 49)) {
-    _SISA = ee->SISA / 100.0;
-  }
-  else if((ee->SISA >= 50) && (ee->SISA <= 74)) {
-    _SISA = (50 + (ee->SISA - 50.0) * 2.0) / 100.0;
-  }
-  else if((ee->SISA >= 75) && (ee->SISA <= 99)) {
-    _SISA = 1.0 + (ee->SISA - 75.0) * 0.04;
-  }
-  else if((ee->SISA >= 100) && (ee->SISA <= 125)) {
-    _SISA = 2.0 + (ee->SISA - 100.0) * 0.16;
-  }
-  else if (ee->SISA >= 126 ) {
-    _SISA = -1.0;
-  }
+  _SISA = accuracyFromIndex(ee->SISA, type());
   _E5aHS    = ee->E5aHS;
   _E5bHS    = ee->E5bHS;
@@ -1352,5 +1334,5 @@
   _z_acceleration = ee->z_acceleration; 
 
-  _ura            = ee->URA;
+  _ura            = accuracyFromIndex(ee->URA, type());
 
   _health = 0;
@@ -1608,16 +1590,12 @@
   _omega    = ee->omega;
   _OMEGADOT = ee->OMEGADOT;
+
   _IDOT     = ee->IDOT;
 
+  _URA      = accuracyFromIndex(ee->URAI, type());
+  _SatH1    = (ee->flags & BDSEPHF_SATH1) ? 1: 0;
   _TGD1     = ee->TGD_B1_B3;
   _TGD2     = ee->TGD_B2_B3;
 
-  if ((ee->URAI <  6) && (ee->URAI >= 0)) {
-    _URA = ceil(10.0 * pow(2.0, ((double)ee->URAI/2.0) + 1.0)) / 10.0;
-  }
-  if ((ee->URAI >= 6) && (ee->URAI < 15)) {
-    _URA = ceil(10.0 * pow(2.0, ((double)ee->URAI/2.0)      )) / 10.0;
-  }
-  _SatH1    = (ee->flags & BDSEPHF_SATH1) ? 1: 0;
 
 }
