Index: trunk/BNS/RTCM/clock_orbit_rtcm.c
===================================================================
--- trunk/BNS/RTCM/clock_orbit_rtcm.c	(revision 2424)
+++ trunk/BNS/RTCM/clock_orbit_rtcm.c	(revision 2427)
@@ -3,10 +3,9 @@
         Name:           clock_orbit_rtcm.c
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.c,v 1.10 2010/04/14 11:09:18 stoecker Exp $
+        Version:        $Id: clock_orbit_rtcm.c,v 1.19 2010/02/23 07:41:07 mervart Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
 */
 
-#include <math.h>
 #include <stdio.h>
 #include <string.h>
@@ -94,5 +93,4 @@
 /* standard values */
 #define T_MESSAGE_NUMBER(a)              ADDBITS(12, a) /* DF002 */
-#define T_RESERVED4                      ADDBITS(1, 0)  /* DF001 */
 #define T_RESERVED5                      ADDBITS(5, 0)  /* DF001 */
 #define T_GPS_SATELLITE_ID(a)            ADDBITS(6, a)  /* DF068 */
@@ -107,4 +105,8 @@
 #define T_DELTA_DOT_ALONG_TRACK(a)       SCALEADDBITS(19,   250000.0, a)
 #define T_DELTA_DOT_CROSS_TRACK(a)       SCALEADDBITS(19,   250000.0, a)
+#define T_DELTA_DOT_DOT_RADIAL(a)        SCALEADDBITS(27, 50000000.0, a)
+#define T_DELTA_DOT_DOT_ALONG_TRACK(a)   SCALEADDBITS(25, 12500000.0, a)
+#define T_DELTA_DOT_DOT_CROSS_TRACK(a)   SCALEADDBITS(25, 12500000.0, a)
+#define T_SATELLITE_REFERENCE_POINT(a)   ADDBITS(1, a)
 
 #define T_SATELLITE_REFERENCE_DATUM(a)   ADDBITS(1, a)
@@ -115,4 +117,5 @@
 #define T_GPS_SIGNAL_IDENTIFIER(a)       ADDBITS(5, a)
 #define T_GLONASS_SIGNAL_IDENTIFIER(a)   ADDBITS(5, a)
+#define T_GALILEO_SIGNAL_IDENTIFIER(a)   ADDBITS(5, a)
 #define T_CODE_BIAS(a)                   SCALEADDBITS(14,      100.0, a)
 #define T_GLONASS_SATELLITE_ID(a)        ADDBITS(5, a)
@@ -122,31 +125,7 @@
 #define T_NO_OF_SATELLITES(a)            ADDBITS(6, a)
 #define T_MULTIPLE_MESSAGE_INDICATOR(a)  ADDBITS(1, a)
-#define T_SSR_URA(a)                     ADDBITS(6, a)
+#define T_SSR_URA(a)                     ADDBITS(4, a)
 #define T_HR_CLOCK_CORRECTION(a)         SCALEADDBITS(22,    10000.0, a)
 #define T_SSR_UPDATE_INTERVAL(a)         ADDBITS(4, a)
-
-static double URAToValue(int ura)
-{
-  int urac, urav;
-  urac = ura >> 3;
-  urav = ura & 7;
-  if(!ura)
-    return 0;
-  else if(ura == 63)
-    return SSR_MAXURA;
-  return (pow(3,urac)*(1.0+urav/4.0)-1.0)/1000.0;
-}
-
-static int ValueToURA(double val)
-{
-  int ura;
-  if(!val)
-    return 0;
-  else if(val > 5.4665)
-    return 63;
-  for(ura = 1; ura < 63 && val > URAToValue(ura); ++ura)
-    ;
-  return ura;
-}
 
 size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type,
@@ -205,6 +184,5 @@
     T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)
     --mmi;
-    T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-    T_RESERVED4
+    T_RESERVED5
     T_NO_OF_SATELLITES(co->NumberOfGPSSat)
     for(i = 0; i < co->NumberOfGPSSat; ++i)
@@ -218,4 +196,9 @@
       T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
       T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
+      T_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
+      T_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
+      T_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
+      T_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
+      T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
     }
     ENDBLOCK
@@ -261,6 +244,5 @@
       T_MULTIPLE_MESSAGE_INDICATOR(/*mmi || */ left ? 1 : 0)
       --mmi;
-      T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-      T_RESERVED4
+      T_RESERVED5
       T_NO_OF_SATELLITES(nums)
       for(i = start; i < start+nums; ++i)
@@ -274,4 +256,9 @@
         T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
         T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
+        T_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
+        T_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
+        T_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
+        T_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
+        T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
         T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
         T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
@@ -313,5 +300,5 @@
     {
       T_GPS_SATELLITE_ID(co->Sat[i].ID)
-      T_SSR_URA(ValueToURA(co->Sat[i].UserRangeAccuracy))
+      T_SSR_URA(co->Sat[i].URA)
     }
     ENDBLOCK
@@ -325,6 +312,5 @@
     T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)
     --mmi;
-    T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-    T_RESERVED4
+    T_RESERVED5
     T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
     for(i = CLOCKORBIT_NUMGPS;
@@ -339,4 +325,9 @@
       T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
       T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
+      T_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
+      T_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
+      T_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
+      T_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
+      T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
     }
     ENDBLOCK
@@ -371,6 +362,5 @@
     T_MULTIPLE_MESSAGE_INDICATOR(/*mmi ? 1 :*/0)
     --mmi;
-    T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-    T_RESERVED4
+    T_RESERVED5
     T_NO_OF_SATELLITES(co->NumberOfGLONASSSat)
     for(i = CLOCKORBIT_NUMGPS;
@@ -385,4 +375,9 @@
       T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
       T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
+      T_DELTA_DOT_DOT_RADIAL(co->Sat[i].Orbit.DotDotDeltaRadial)
+      T_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDotDeltaAlongTrack)
+      T_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDotDeltaCrossTrack)
+      T_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
+      T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
       T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
       T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
@@ -422,5 +417,5 @@
     {
       T_GPS_SATELLITE_ID(co->Sat[i].ID)
-      T_SSR_URA(ValueToURA(co->Sat[i].UserRangeAccuracy))
+      T_SSR_URA(co->Sat[i].URA)
     }
     ENDBLOCK
@@ -537,5 +532,4 @@
 #define G_SIZE(a)                        GETBITS(a, 10)
 #define G_MESSAGE_NUMBER(a)              GETBITS(a, 12) /* DF002 */
-#define G_RESERVED4                      SKIPBITS(4)    /* DF001 */
 #define G_RESERVED5                      SKIPBITS(5)    /* DF001 */
 #define G_GPS_SATELLITE_ID(a)            GETBITS(a, 6)  /* DF068 */
@@ -550,4 +544,8 @@
 #define G_DELTA_DOT_ALONG_TRACK(a)       GETFLOATSIGN(a, 19, 1/250000.0)
 #define G_DELTA_DOT_CROSS_TRACK(a)       GETFLOATSIGN(a, 19, 1/250000.0)
+#define G_DELTA_DOT_DOT_RADIAL(a)        GETFLOATSIGN(a, 27, 1/50000000.0)
+#define G_DELTA_DOT_DOT_ALONG_TRACK(a)   GETFLOATSIGN(a, 25, 1/12500000.0)
+#define G_DELTA_DOT_DOT_CROSS_TRACK(a)   GETFLOATSIGN(a, 25, 1/12500000.0)
+#define G_SATELLITE_REFERENCE_POINT(a)   GETBITS(a, 1)
 
 #define G_SATELLITE_REFERENCE_DATUM(a)   GETBITS(a, 1)
@@ -558,4 +556,5 @@
 #define G_GPS_SIGNAL_IDENTIFIER(a)       GETBITS(a, 5)
 #define G_GLONASS_SIGNAL_IDENTIFIER(a)   GETBITS(a, 5)
+#define G_GALILEO_SIGNAL_IDENTIFIER(a)   GETBITS(a, 5)
 #define G_CODE_BIAS(a)                   GETFLOATSIGN(a, 14, 1/100.0)
 #define G_GLONASS_SATELLITE_ID(a)        GETBITS(a, 5)
@@ -567,6 +566,5 @@
 #define G_NO_OF_SATELLITES(a)            GETBITS(a, 6)
 #define G_MULTIPLE_MESSAGE_INDICATOR(a)  GETBITS(a, 1)
-#define G_SSR_URA(a)                     {int temp; GETBITS(temp, 6) \
- (a) = URAToValue(temp);}
+#define G_SSR_URA(a)                     GETBITS(a, 4)
 #define G_HR_CLOCK_CORRECTION(a)         GETFLOATSIGN(a, 22, 1/10000.0)
 #define G_SSR_UPDATE_INTERVAL(a)         GETBITS(a, 4)
@@ -616,11 +614,10 @@
     G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
     G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-    G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-    G_RESERVED4
+    G_RESERVED5
     G_NO_OF_SATELLITES(nums)
     co->OrbitDataSupplied |= 1;
 #ifdef DEBUG
-fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d rd %d\n",co->GPSEpochTime,
-co->UpdateInterval,mmi,co->NumberOfGPSSat,nums, co->SatRefDatum);
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GPSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGPSSat,nums);
 #endif
     for(i = 0; i < nums; ++i)
@@ -640,11 +637,21 @@
       G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
       G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
-#ifdef DEBUG
-fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f\n",
+      G_DELTA_DOT_DOT_RADIAL(co->Sat[pos].Orbit.DotDotDeltaRadial)
+      G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDotDeltaAlongTrack)
+      G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDotDeltaCrossTrack)
+      G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
+      G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
+#ifdef DEBUG
+fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f rp %d rd %d\n",
 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,
 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,
 co->Sat[pos].Orbit.DotDeltaRadial,
 co->Sat[pos].Orbit.DotDeltaAlongTrack,
-co->Sat[pos].Orbit.DotDeltaCrossTrack);
+co->Sat[pos].Orbit.DotDeltaCrossTrack,
+co->Sat[pos].Orbit.DotDotDeltaRadial,
+co->Sat[pos].Orbit.DotDotDeltaAlongTrack,
+co->Sat[pos].Orbit.DotDotDeltaCrossTrack,
+co->SatRefPoint,
+co->SatRefDatum);
 #endif
     }
@@ -692,6 +699,5 @@
     G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
     G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-    G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-    G_RESERVED4
+    G_RESERVED5
     G_NO_OF_SATELLITES(nums)
     co->OrbitDataSupplied |= 1;
@@ -713,4 +719,9 @@
       G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
       G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
+      G_DELTA_DOT_DOT_RADIAL(co->Sat[pos].Orbit.DotDotDeltaRadial)
+      G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDotDeltaAlongTrack)
+      G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDotDeltaCrossTrack)
+      G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
+      G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
       G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)
       G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
@@ -737,5 +748,5 @@
       co->Sat[pos].ID = id;
 
-      G_SSR_URA(co->Sat[pos].UserRangeAccuracy)
+      G_SSR_URA(co->Sat[pos].URA)
     }
     break;
@@ -769,11 +780,10 @@
     G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
     G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-    G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-    G_RESERVED4
+    G_RESERVED5
     G_NO_OF_SATELLITES(nums)
     co->OrbitDataSupplied |= 2;
 #ifdef DEBUG
-fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d rd %d\n",co->GLONASSEpochTime,
-co->UpdateInterval,mmi,co->NumberOfGLONASSSat,nums, co->SatRefDatum);
+fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->GLONASSEpochTime,
+co->UpdateInterval,mmi,co->NumberOfGLONASSSat,nums);
 #endif
     for(i = 0; i < nums; ++i)
@@ -793,11 +803,21 @@
       G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
       G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
-#ifdef DEBUG
-fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f\n",
+      G_DELTA_DOT_DOT_RADIAL(co->Sat[pos].Orbit.DotDotDeltaRadial)
+      G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDotDeltaAlongTrack)
+      G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDotDeltaCrossTrack)
+      G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
+      G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
+#ifdef DEBUG
+fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f rp %d rd %d\n",
 co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,
 co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,
 co->Sat[pos].Orbit.DotDeltaRadial,
 co->Sat[pos].Orbit.DotDeltaAlongTrack,
-co->Sat[pos].Orbit.DotDeltaCrossTrack);
+co->Sat[pos].Orbit.DotDeltaCrossTrack,
+co->Sat[pos].Orbit.DotDotDeltaRadial,
+co->Sat[pos].Orbit.DotDotDeltaAlongTrack,
+co->Sat[pos].Orbit.DotDotDeltaCrossTrack,
+co->SatRefPoint,
+co->SatRefDatum);
 #endif
     }
@@ -841,6 +861,5 @@
     G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
     G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-    G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-    G_RESERVED4
+    G_RESERVED5
     G_NO_OF_SATELLITES(nums)
     co->OrbitDataSupplied |= 2;
@@ -862,4 +881,9 @@
       G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
       G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
+      G_DELTA_DOT_DOT_RADIAL(co->Sat[pos].Orbit.DotDotDeltaRadial)
+      G_DELTA_DOT_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDotDeltaAlongTrack)
+      G_DELTA_DOT_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDotDeltaCrossTrack)
+      G_SATELLITE_REFERENCE_POINT(co->SatRefPoint)
+      G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
       G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)
       G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
@@ -884,5 +908,5 @@
       co->Sat[pos].ID = id;
 
-      G_SSR_URA(co->Sat[pos].UserRangeAccuracy)
+      G_SSR_URA(co->Sat[pos].URA)
     }
     break;
Index: trunk/BNS/RTCM/clock_orbit_rtcm.h
===================================================================
--- trunk/BNS/RTCM/clock_orbit_rtcm.h	(revision 2424)
+++ trunk/BNS/RTCM/clock_orbit_rtcm.h	(revision 2427)
@@ -6,5 +6,5 @@
         Name:           clock_orbit_rtcm.h
         Project:        RTCM3
-        Version:        $Id: clock_orbit_rtcm.h,v 1.8 2010/04/14 11:09:18 stoecker Exp $
+        Version:        $Id: clock_orbit_rtcm.h,v 1.14 2010/03/11 10:50:05 mervart Exp $
         Authors:        Dirk Stöcker
         Description:    state space approach for RTCM3
@@ -14,4 +14,5 @@
 
 enum SatelliteReferenceDatum { DATUM_ITRF=0, DATUM_LOCAL=1 };
+enum SatelliteReferencePoint { POINT_IONOFREE=0, POINT_CENTER=1 };
 enum ClockOrbitType {
      COTYPE_GPSORBIT=1057, COTYPE_GPSCLOCK=1058,
@@ -45,6 +46,4 @@
 };
 
-#define SSR_MAXURA 5.5 /* > 5466.5mm in meter */
-
 /* GLONASS data is stored with offset CLOCKORBIT_NUMGPS in the data structures.
 So first GLONASS satellite is at xxx->Sat[CLOCKORBIT_NUMGPS], first
@@ -65,9 +64,10 @@
   int epochSize;                    /* Weber, for latency */
   int UpdateInterval;
+  enum SatelliteReferencePoint SatRefPoint;
   enum SatelliteReferenceDatum SatRefDatum;
   struct SatData {
     int ID; /* GPS or GLONASS */
     int IOD; /* GPS or GLONASS */
-    double UserRangeAccuracy; /* accuracy values in [m] */
+    int URA;
     double hrclock;
     struct OrbitPart
@@ -79,4 +79,7 @@
       double DotDeltaAlongTrack;    /* m/s */
       double DotDeltaCrossTrack;    /* m/s */
+      double DotDotDeltaRadial;     /* m/ss */
+      double DotDotDeltaAlongTrack; /* m/ss */
+      double DotDotDeltaCrossTrack; /* m/ss */
     } Orbit;
     struct ClockPart
Index: trunk/BNS/bns.cpp
===================================================================
--- trunk/BNS/bns.cpp	(revision 2424)
+++ trunk/BNS/bns.cpp	(revision 2427)
@@ -476,8 +476,8 @@
               ++bias.NumberOfGPSSat;
             }
-//            else if (prn[0] == 'R') {
-//              biasSat = bias.Sat + CLOCKORBIT_NUMGPS + bias.NumberOfGLONASSSat;
-//              ++bias.NumberOfGLONASSSat;
-//            }
+            else if (prn[0] == 'R') {
+              biasSat = bias.Sat + CLOCKORBIT_NUMGPS + bias.NumberOfGLONASSSat;
+              ++bias.NumberOfGLONASSSat;
+            }
 
             // Coefficient of Ionosphere-Free LC
