Index: trunk/BNC/src/RTCM/RTCM2.cpp
===================================================================
--- trunk/BNC/src/RTCM/RTCM2.cpp	(revision 7628)
+++ trunk/BNC/src/RTCM/RTCM2.cpp	(revision 7629)
@@ -2,6 +2,6 @@
 //
 // RTCM2.cpp
-// 
-// Purpose: 
+//
+// Purpose:
 //
 //   Module for extraction of RTCM2 messages
@@ -11,5 +11,5 @@
 //   RTCM 10402.3 Recommended Standards for Differential GNSS (Global
 //     Navigation Satellite Systems) Service; RTCM Paper 136-2001/SC104-STD,
-//     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime 
+//     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime
 //     Services, Alexandria, Virgina (2001).
 //   ICD-GPS-200; Navstar GPS Space Segment / Navigation User Interfaces;
@@ -22,5 +22,5 @@
 //     last accessed 17 Sep. 2006
 //
-// Notes: 
+// Notes:
 //
 // - The host computer is assumed to use little endian (Intel) byte order
@@ -36,14 +36,14 @@
 //   2006/10/14  LMV  Exception handling
 //   2006/10/17  OMO  Removed obsolete check of multiple message indicator
-//   2006/10/17  OMO  Fixed parity handling 
+//   2006/10/17  OMO  Fixed parity handling
 //   2006/10/18  OMO  Improved screening of bad data in RTCM2_Obs::extract
 //   2006/11/25  OMO  Revised check for presence of GLONASS data
 //   2007/05/25  GW   Round time tag to 100 ms
-//   2007/12/11  AHA  Changed handling of C/A- and P-Code on L1 
-//   2007/12/13  AHA  Changed epoch comparison in packet extraction 
+//   2007/12/11  AHA  Changed handling of C/A- and P-Code on L1
+//   2007/12/13  AHA  Changed epoch comparison in packet extraction
 //   2008/03/01  OMO  Compilation flag for epoch rounding
 //   2008/03/04  AHA  Fixed problems with PRN 32
 //   2008/03/05  AHA  Implemeted fix for Trimble 4000SSI receivers
-//   2008/03/07  AHA  Major revision of input buffer handling 
+//   2008/03/07  AHA  Major revision of input buffer handling
 //   2008/03/07  AHA  Removed unnecessary failure flag
 //   2008/03/10  AHA  Corrected extraction of antenna serial number
@@ -76,7 +76,7 @@
 // Note: A need to round the measurement epoch to integer tenths of a second was
 // noted by BKG in the processing of RTCM2 data from various receivers in NTRIP
-// real-time networks. It is unclear at present, whether this is due to an 
+// real-time networks. It is unclear at present, whether this is due to an
 // improper implementation of the RTCM2 standard in the respective receivers
-// or an unclear formulation of the standard. 
+// or an unclear formulation of the standard.
 
 #define ROUND_EPOCH  1
@@ -84,5 +84,5 @@
 // Fix for data streams originating from TRIMBLE_4000SSI receivers.
 // GPS PRN32 is erroneously flagged as GLONASS satellite in the C/A
-// pseudorange messages. We therefore use a majority voting to 
+// pseudorange messages. We therefore use a majority voting to
 // determine the true constellation for this message.
 // This fix is only required for Trimble4000SSI receivers but can also
@@ -101,5 +101,5 @@
 
 const double lambda_L1 = c_light/f_L1;  // L1 wavelength [m] (0.1903m)
-const double lambda_L2 = c_light/f_L2;  // L2 wavelength [m] 
+const double lambda_L2 = c_light/f_L2;  // L2 wavelength [m]
 
 //
@@ -107,12 +107,12 @@
 //
 
-const int bit_L1rngGPS =  0; 
-const int bit_L2rngGPS =  1; 
-const int bit_L1cphGPS =  2; 
-const int bit_L2cphGPS =  3; 
-const int bit_L1rngGLO =  4; 
-const int bit_L2rngGLO =  5; 
-const int bit_L1cphGLO =  6; 
-const int bit_L2cphGLO =  7; 
+const int bit_L1rngGPS =  0;
+const int bit_L2rngGPS =  1;
+const int bit_L1cphGPS =  2;
+const int bit_L2cphGPS =  3;
+const int bit_L1rngGLO =  4;
+const int bit_L2rngGLO =  5;
+const int bit_L1cphGLO =  6;
+const int bit_L2cphGLO =  7;
 
 
@@ -122,5 +122,5 @@
 
 namespace rtcm2 {
-  
+
 //------------------------------------------------------------------------------
 //
@@ -128,5 +128,5 @@
 //
 // Purpose:
-//  
+//
 //   Handling of RTCM2 30bit words
 //
@@ -148,5 +148,5 @@
 bool ThirtyBitWord::validParity() const {
 
-  // Parity stuff 
+  // Parity stuff
 
   static const unsigned int  PARITY_25 = 0xBB1F3480;
@@ -173,10 +173,10 @@
 
   unsigned int t, w, p;
-  
-  // The sign of the data is determined by the D30* parity bit 
-  // of the previous data word. If  D30* is set, invert the data 
+
+  // The sign of the data is determined by the D30* parity bit
+  // of the previous data word. If  D30* is set, invert the data
   // bits D01..D24 to obtain the d01..d24 (but leave all other
   // bits untouched).
-  
+
   w = W;
   if ( w & 0x40000000 )  w ^= 0x3FFFFFC0;
@@ -188,27 +188,27 @@
   p = ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
         byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
-  
+
   t = w & PARITY_26;
-  p = (p<<1) | 
+  p = (p<<1) |
       ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
         byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
-  
+
   t = w & PARITY_27;
-  p = (p<<1) | 
+  p = (p<<1) |
       ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
         byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
-  
+
   t = w & PARITY_28;
-  p = (p<<1) | 
+  p = (p<<1) |
       ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
         byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
-  
+
   t = w & PARITY_29;
-  p = (p<<1) | 
+  p = (p<<1) |
       ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
         byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
-  
+
   t = w & PARITY_30;
-  p = (p<<1) | 
+  p = (p<<1) |
       ( byteParity[t      &0xff] ^ byteParity[(t>> 8)&0xff] ^
         byteParity[(t>>16)&0xff] ^ byteParity[(t>>24)     ]   );
@@ -224,7 +224,7 @@
 
   const unsigned char Preamble = 0x66;
- 
+
   unsigned char b = (value()>>22) & 0xFF;
-  
+
   return ( b==Preamble );
 
@@ -244,7 +244,7 @@
 
   unsigned int w = W;
-   
+
   if (validParity()) {
-    // Return data and current parity bits. Invert data bits if D30* 
+    // Return data and current parity bits. Invert data bits if D30*
     // is set and discard old parity bits.
     if ( w & 0x40000000 )  w ^= 0x3FFFFFC0;
@@ -255,5 +255,5 @@
     return 0;
   };
-  
+
 };
 
@@ -262,29 +262,29 @@
 
 void ThirtyBitWord::append(unsigned char b) {
-  
+
   // Look up table for swap (left-right) of 6 data bits
-  static const unsigned char 
-    swap[] = {                                
-      0,32,16,48, 8,40,24,56, 4,36,20,52,12,44,28,60,                         
-      2,34,18,50,10,42,26,58, 6,38,22,54,14,46,30,62,                         
-      1,33,17,49, 9,41,25,57, 5,37,21,53,13,45,29,61,                         
-      3,35,19,51,11,43,27,59, 7,39,23,55,15,47,31,63                          
+  static const unsigned char
+    swap[] = {
+      0,32,16,48, 8,40,24,56, 4,36,20,52,12,44,28,60,
+      2,34,18,50,10,42,26,58, 6,38,22,54,14,46,30,62,
+      1,33,17,49, 9,41,25,57, 5,37,21,53,13,45,29,61,
+      3,35,19,51,11,43,27,59, 7,39,23,55,15,47,31,63
     };
-    
+
   // Bits 7 and 6 (of 0..7) must be "01" for valid data bytes
   if ( (b & 0x40) != 0x40 ) {
     // We simply skip the invalid input byte and leave the word unchanged
-#if (DEBUG>0) 
+#if (DEBUG>0)
     cerr << "Error in append()" << bitset<32>(all()) << endl;
 #endif
     return;
   };
-  
+
   // Swap bits 0..5 to restore proper bit order for 30bit words
   b = swap[ b & 0x3f];
 
   // Fill word
-  W = ( (W <<6) | (b & 0x3f) ) ; 
-  
+  W = ( (W <<6) | (b & 0x3f) ) ;
+
 };
 
@@ -295,22 +295,22 @@
 
   // Check if string is long enough
-   
+
   if (buf.size()<5) {
     // Ignore; users should avoid this case prior to calling get()
-    
-#if ( DEBUG > 0 )    
+
+#if ( DEBUG > 0 )
     cerr << "Error in get(): packet too short (" << buf.size() <<")" << endl;
 #endif
-        
+
     return;
   };
-  
+
   // Process 5 bytes
-  
+
   for (int i=0; i<5; i++) append(buf[i]);
 
-#if (DEBUG>0) 
+#if (DEBUG>0)
   if (!validParity()) {
-    cerr << "Parity error in get()" 
+    cerr << "Parity error in get()"
          << bitset<32>(all()) << endl;
   };
@@ -326,12 +326,12 @@
 
   for (int i=0; i<5; i++) {
-    inp >> b; 
+    inp >> b;
     if (inp.fail()) { clear(); return; };
     append(b);
   };
 
-#if (DEBUG>0) 
+#if (DEBUG>0)
   if (!validParity()) {
-    cerr << "Parity error in get()" 
+    cerr << "Parity error in get()"
          << bitset<32>(all()) << endl;
   };
@@ -346,9 +346,9 @@
   const unsigned int wordLen = 5; // Number of bytes representing a 30-bit word
   const unsigned int spare   = 1; // Number of spare words for resync of parity
-                                  // (same value as inRTCM2packet::getPacket()) 
+                                  // (same value as inRTCM2packet::getPacket())
   unsigned int i;
-  
+
   i=0;
-  // append spare word (to get correct parity) and first consecutive word  
+  // append spare word (to get correct parity) and first consecutive word
   while (i<(spare+1)*wordLen) {
     // Process byte
@@ -357,5 +357,5 @@
     i++;
   };
-  
+
   // start searching for preamble in first word after spare word
   while (!isHeader() && i<buf.size() ) {
@@ -370,11 +370,11 @@
   if (i>=(1+spare)*wordLen) buf.erase(0,i-(1+spare)*wordLen);
 
-#if (DEBUG>0) 
+#if (DEBUG>0)
   if (!validParity()) {
-    cerr << "Parity error in getHeader()" 
+    cerr << "Parity error in getHeader()"
          << bitset<32>(all()) << endl;
   };
 #endif
-  
+
 };
 
@@ -388,12 +388,12 @@
   i=0;
   while ( !isHeader() || i<5 ) {
-    inp >> b; 
+    inp >> b;
     if (inp.fail()) { clear(); return; };
     append(b); i++;
   };
 
-#if (DEBUG>0) 
+#if (DEBUG>0)
   if (!validParity()) {
-    cerr << "Parity error in getHeader()" 
+    cerr << "Parity error in getHeader()"
          << bitset<32>(all()) << endl;
   };
@@ -422,12 +422,12 @@
 
 void RTCM2packet::clear()  {
-  
+
   W.clear();
-  
+
   H1=0;
   H2=0;
-  
+
   DW.resize(0,0);
-  
+
 };
 
@@ -435,12 +435,12 @@
 
 bool RTCM2packet::valid() const {
-  
+
   // The methods for creating a packet (get,">>") ensure
-  // that a packet has a consistent number of data words 
-  // and a valid parity in all header and data words. 
+  // that a packet has a consistent number of data words
+  // and a valid parity in all header and data words.
   // Therefore a packet is either empty or valid.
-  
+
   return (H1!=0);
-    
+
 };
 
@@ -456,106 +456,106 @@
                          // (same value as used in ThirtyBitWord::getHeader)
   unsigned int n;
-  
+
   // Does the package content at least spare bytes and first header byte?
-  if (buf.size()<(spare+1)*wordLen) { 
-      clear();       
+  if (buf.size()<(spare+1)*wordLen) {
+      clear();
       return;
   };
-    
-  // Try to read a full packet. Processed bytes are removed from the input 
-  // buffer except for the latest spare*wordLen bytes to restore the parity 
+
+  // Try to read a full packet. Processed bytes are removed from the input
+  // buffer except for the latest spare*wordLen bytes to restore the parity
   // bytes upon subseqeunt calls of getPacket().
-  
+
   // Locate and read the first header word
   W.getHeader(buf);
-  if (!W.isHeader()) { 
+  if (!W.isHeader()) {
     // No header found; try again next time. buf retains only the spare
     // words. The packet contents is cleared to indicate an unsuccessful
     // termination of getPacket().
     clear();
-    
+
 #if ( DEBUG > 0 )
     cerr << "Error in getPacket(): W.isHeader() = false  for H1" << endl;
 #endif
-    
-    return; 
+
+    return;
   };
   H1 = W.value();
 
-  // Do we have enough bytes to read the next word? If not, the packet 
+  // Do we have enough bytes to read the next word? If not, the packet
   // contents is cleared to indicate an unsuccessful termination. The
   // previously read spare and header bytes are retained in the buffer
   // for use in the next call of getPacket().
-  if (buf.size()<(spare+2)*wordLen) { 
-    clear(); 
-    
-#if ( DEBUG > 0 )    
+  if (buf.size()<(spare+2)*wordLen) {
+    clear();
+
+#if ( DEBUG > 0 )
     cerr << "Error in getPacket(): buffer too short for complete H2" << endl;
 #endif
-    
+
     return;
   };
-  
+
   // Read the second header word
-  W.get(buf.substr((spare+1)*wordLen,buf.size()-(spare+1)*wordLen));  
+  W.get(buf.substr((spare+1)*wordLen,buf.size()-(spare+1)*wordLen));
   H2 = W.value();
-  if (!W.validParity()) { 
+  if (!W.validParity()) {
     // Invalid H2 word; delete first buffer byte and try to resynch next time.
     // The packet contents is cleared to indicate an unsuccessful termination.
-    clear(); 
-    buf.erase(0,1); 
-    
-#if ( DEBUG > 0 )    
+    clear();
+    buf.erase(0,1);
+
+#if ( DEBUG > 0 )
     cerr << "Error in getPacket(): W.validParity() = false for H2" << endl;
 #endif
-        
-    return; 
+
+    return;
   };
 
   n = nDataWords();
-  
-  // Do we have enough bytes to read the next word? If not, the packet 
+
+  // Do we have enough bytes to read the next word? If not, the packet
   // contents is cleared to indicate an unsuccessful termination. The
   // previously read spare and header bytes are retained in the buffer
   // for use in the next call of getPacket().
-  if (buf.size()<(spare+2+n)*wordLen) { 
-    clear(); 
-    
-#if ( DEBUG > 0 )    
+  if (buf.size()<(spare+2+n)*wordLen) {
+    clear();
+
+#if ( DEBUG > 0 )
     cerr << "Error in getPacket(): buffer too short for complete " << n
          << " DWs" << endl;
 #endif
-    
-    return; 
-  };
-  
+
+    return;
+  };
+
   DW.resize(n);
   for (unsigned int i=0; i<n; i++) {
-    W.get(buf.substr((spare+2+i)*wordLen,buf.size()-(spare+2+i)*wordLen)); 
+    W.get(buf.substr((spare+2+i)*wordLen,buf.size()-(spare+2+i)*wordLen));
     DW[i] = W.value();
-    if (!W.validParity()) { 
+    if (!W.validParity()) {
       // Invalid data word; delete first byte and try to resynch next time.
       // The packet contents is cleared to indicate an unsuccessful termination.
-      clear(); 
-      buf.erase(0,1); 
-      
-#if ( DEBUG > 0 )    
+      clear();
+      buf.erase(0,1);
+
+#if ( DEBUG > 0 )
     cerr << "Error in getPacket(): W.validParity() = false for DW"
          << i << endl;
 #endif
-        
-      return; 
+
+      return;
     };
   };
 
-  // Successful packet extraction; delete total number of message bytes 
-  // from buffer. 
+  // Successful packet extraction; delete total number of message bytes
+  // from buffer.
   // Note: a total of "spare" words remain in the buffer to enable a
   // parity resynchronization when searching the next header.
-  
+
   buf.erase(0,(n+2)*wordLen);
-    
+
   return;
-  
+
 };
 
@@ -568,11 +568,11 @@
 
   int n;
-  
-  W.getHeader(inp); 
-  H1 = W.value(); 
+
+  W.getHeader(inp);
+  H1 = W.value();
   if (inp.fail() || !W.isHeader()) { clear(); return; }
-  
-  W.get(inp);       
-  H2 = W.value(); 
+
+  W.get(inp);
+  H2 = W.value();
   if (inp.fail() || !W.validParity()) { clear(); return; }
 
@@ -580,11 +580,11 @@
   DW.resize(n);
   for (int i=0; i<n; i++) {
-    W.get(inp); 
-    DW[i] = W.value(); 
+    W.get(inp);
+    DW[i] = W.value();
     if (inp.fail() || !W.validParity()) { clear(); return; }
   };
 
   return;
-  
+
 };
 
@@ -592,5 +592,5 @@
 // Input operator
 //
-// Reads an RTCM2 packet from the input stream. 
+// Reads an RTCM2 packet from the input stream.
 //
 
@@ -598,7 +598,7 @@
 
   p.getPacket(is);
-  
+
   return is;
-  
+
 };
 
@@ -653,18 +653,18 @@
 //
 
-unsigned int RTCM2packet::getUnsignedBits ( unsigned int start, 
+unsigned int RTCM2packet::getUnsignedBits ( unsigned int start,
                                             unsigned int n      ) const {
-                                    
+
   unsigned int  iFirst = start/24;       // Index of first data word
   unsigned int  iLast  = (start+n-1)/24; // Index of last  data word
   unsigned int  bitField = 0;
   unsigned int  tmp;
-  
+
   // Checks
-  
+
   if (n>32) {
     throw("Error: can't handle >32 bits in RTCM2packet::getUnsignedBits");
   };
-  
+
   if ( 24*DW.size() < start+n-1 ) {
 #if (DEBUG>0)
@@ -683,30 +683,30 @@
 
   // Handle initial data word
-  // Get all data bits. Strip parity and unwanted leading bits. 
-  // Store result in 24 lsb bits of tmp. 
-  
-  tmp = (DW[iFirst]>>6) & 0xFFFFFF; 
+  // Get all data bits. Strip parity and unwanted leading bits.
+  // Store result in 24 lsb bits of tmp.
+
+  tmp = (DW[iFirst]>>6) & 0xFFFFFF;
   tmp = ( ( tmp << start%24) & 0xFFFFFF ) >> start%24 ;
 
   // Handle central data word
-  
-  if ( iFirst<iLast ) { 
+
+  if ( iFirst<iLast ) {
     bitField = tmp;
     for (unsigned int iWord=iFirst+1; iWord<iLast; iWord++) {
-      tmp = (DW[iWord]>>6) & 0xFFFFFF;     
+      tmp = (DW[iWord]>>6) & 0xFFFFFF;
       bitField = (bitField << 24) | tmp;
     };
-    tmp = (DW[iLast]>>6) & 0xFFFFFF;     
+    tmp = (DW[iLast]>>6) & 0xFFFFFF;
   };
 
   // Handle last data word
-  
+
   tmp = tmp >> (23-(start+n-1)%24);
   bitField = (bitField << ((start+n-1)%24+1)) | tmp;
 
   // Done
-  
+
   return bitField;
-  
+
 };
 
@@ -717,14 +717,14 @@
 //
 
-int RTCM2packet::getBits ( unsigned int start, 
+int RTCM2packet::getBits ( unsigned int start,
                            unsigned int n      ) const {
 
 
   // Checks
-  
+
   if (n>32) {
     throw("Error: can't handle >32 bits in RTCM2packet::getBits");
   };
-  
+
   if ( 24*DW.size() < start+n-1 ) {
 #if (DEBUG>0)
@@ -743,5 +743,5 @@
 
   return ((int)(getUnsignedBits(start,n)<<(32-n))>>(32-n));
-  
+
 };
 
@@ -757,27 +757,20 @@
 //------------------------------------------------------------------------------
 
-// Constructor
-RTCM2_03::RTCM2_03(){
-  validMsg = false;
-  x = 0.0; 
-  y = 0.0; 
-  z=0.0;
-};
 
 void RTCM2_03::extract(const RTCM2packet& P) {
 
   // Check validity, packet type and number of data words
-  
-  validMsg = (P.valid()); 
+
+  validMsg = (P.valid());
   if (!validMsg) return;
 
-  validMsg = (P.ID()==03);  
+  validMsg = (P.ID()==03);
   if (!validMsg) return;
-  
-  validMsg = (P.nDataWords()==4);  
+
+  validMsg = (P.nDataWords()==4);
   if (!validMsg) return;
-  
+
   // Antenna reference point coordinates
-  
+
   x  = P.getBits( 0,32)*0.01;    // X [m]
   y  = P.getBits(32,32)*0.01;    // Y [m]
@@ -799,20 +792,20 @@
 
   unsigned int       nad, nas;
-  
+
   const unsigned int nF1  = 8; // bits in first field (R,AF,SF,NAD)
   const unsigned int nF2  =16; // bits in second field (SETUP ID,R,NAS)
   const unsigned int nBits=24; // data bits in  30bit word
-  
+
   // Check validity, packet type and number of data words
-  
-  validMsg = (P.valid()); 
+
+  validMsg = (P.valid());
   if (!validMsg) return;
 
-  validMsg = (P.ID()==23);  
+  validMsg = (P.ID()==23);
   if (!validMsg) return;
 
   // Check number of data words (can nad be read in?)
-  
-  validMsg = (P.nDataWords()>=1);  
+
+  validMsg = (P.nDataWords()>=1);
   if (!validMsg){
     cerr << "RTCM2_23::extract: P.nDataWords()>=1" << endl;
@@ -820,15 +813,15 @@
   }
 
-  // Antenna descriptor 
+  // Antenna descriptor
   antType = "";
   nad = P.getUnsignedBits(3,5);
-  
-  // Check number of data words (can antenna description be read in?) 
-  validMsg = ( P.nDataWords() >= 
+
+  // Check number of data words (can antenna description be read in?)
+  validMsg = ( P.nDataWords() >=
                (unsigned int)ceil((nF1+nad*8)/(double)nBits) );
 
   if (!validMsg) return;
-  
-  for (unsigned int i=0;i<nad;i++) 
+
+  for (unsigned int i=0;i<nad;i++)
     antType += (char)P.getUnsignedBits(nF1+i*8,8);
 
@@ -837,13 +830,13 @@
 
     // Check number of data words (can nas be read in?)
-    
+
     validMsg = ( P.nDataWords() >=
                  (unsigned int)ceil((nF1+nad*8+nF2)/(double)nBits) );
     if (!validMsg) return;
-    
+
     nas = P.getUnsignedBits(19+8*nad,5);
 
     // Check number of data words (can antenna serial number be read in?)
-    
+
     validMsg = ( P.nDataWords() >=
                  (unsigned int)ceil((nF1+nad*8+nF2+nas*8)/(double)nBits) );
@@ -851,5 +844,5 @@
 
     antSN = "";
-    for (unsigned int i=0;i<nas;i++) 
+    for (unsigned int i=0;i<nas;i++)
       antSN += (char)P.getUnsignedBits(nF1+8*nad+nF2+i*8,8);
   };
@@ -864,5 +857,5 @@
 // Purpose:
 //
-//   A class for handling RTCM 2 Reference Station Antenna 
+//   A class for handling RTCM 2 Reference Station Antenna
 //   Reference Point Parameter messages
 //
@@ -874,19 +867,19 @@
 
   // Check validity, packet type and number of data words
-  
-  validMsg = (P.valid()); 
+
+  validMsg = (P.valid());
   if (!validMsg) return;
 
-  validMsg = (P.ID()==24);  
+  validMsg = (P.ID()==24);
   if (!validMsg) return;
-  
-  validMsg = (P.nDataWords()==6);  
+
+  validMsg = (P.nDataWords()==6);
   if (!validMsg) return;
-  
+
   // System indicator
-  
+
   isGPS     = (P.getUnsignedBits(118,1)==0);
   isGLONASS = (P.getUnsignedBits(118,1)==1);
-  
+
   // Antenna reference point coordinates
 
@@ -902,5 +895,5 @@
 
   // Antenna Height
-   
+
   if (P.getUnsignedBits(119,1)==1) {
     h= P.getUnsignedBits(120,18)*0.0001;
@@ -917,5 +910,5 @@
 // Purpose:
 //
-//   A class for handling blocks of RTCM2 18 & 19 packets that need to be 
+//   A class for handling blocks of RTCM2 18 & 19 packets that need to be
 //   combined to get a complete set of measurements
 //
@@ -923,9 +916,9 @@
 //
 //   The class collects L1/L2 code and phase measurements for GPS and GLONASS.
-//   Since the Multiple Message Indicator is inconsistently handled by various 
+//   Since the Multiple Message Indicator is inconsistently handled by various
 //   receivers we simply require code and phase on L1 and L2 for a complete
-//   set ob observations at a given epoch. GLONASS observations are optional, 
-//   but all four types (code+phase,L1+L2) must be provided, if at least one 
-//   is given. Also, the GLONASS message must follow the corresponding GPS 
+//   set ob observations at a given epoch. GLONASS observations are optional,
+//   but all four types (code+phase,L1+L2) must be provided, if at least one
+//   is given. Also, the GLONASS message must follow the corresponding GPS
 //   message.
 //
@@ -940,10 +933,10 @@
 };
 
-// Reset entire block 
+// Reset entire block
 
 void RTCM2_Obs::clear() {
-  
+
   GPSonly = true;
-  
+
   secs=0.0;                // Seconds of hour (GPS time)
   nSat=0;                  // Number of space vehicles
@@ -956,7 +949,7 @@
   slip_L1.resize(0);       // Slip counter
   slip_L2.resize(0);       // Slip counter
-  
+
   availability.reset();    // Message status flags
-  
+
 };
 
@@ -969,5 +962,5 @@
           availability.test(bit_L1cphGPS) ||
           availability.test(bit_L2cphGPS);
-    
+
 };
 
@@ -978,5 +971,5 @@
           availability.test(bit_L1cphGLO) ||
           availability.test(bit_L2cphGLO);
-    
+
 };
 
@@ -987,5 +980,5 @@
           availability.test(bit_L1cphGPS) &&
           availability.test(bit_L2cphGPS);
-    
+
 };
 
@@ -996,5 +989,5 @@
           availability.test(bit_L1cphGLO) &&
           availability.test(bit_L2cphGLO);
-    
+
 };
 
@@ -1004,5 +997,5 @@
 
   return ( allGPS() && ( GPSonly || allGLONASS() ) );
-  
+
 };
 
@@ -1020,12 +1013,12 @@
 
   // Check validity and packet type
-  
-  if ( ! ( P.valid() && 
+
+  if ( ! ( P.valid() &&
            (P.ID()==18 || P.ID()==19) ) ) return;
 
-  // Check number of data words, message starts with 1 DW for epoch, then each 
-  // satellite brings 2 DW, 
+  // Check number of data words, message starts with 1 DW for epoch, then each
+  // satellite brings 2 DW,
   // Do not start decoding if less than 3 DW are in package
-  
+
   if ( P.nDataWords()<3 ) {
 #if ( DEBUG > 0 )
@@ -1033,10 +1026,10 @@
          << P.nDataWords() << ") detected" << endl;
 #endif
-    
+
     return;
   };
-  
+
   // Check if number of data words is odd number
-  
+
   if ( P.nDataWords()%2==0 ){
 #if ( DEBUG > 0 )
@@ -1044,23 +1037,23 @@
          << P.nDataWords() << ") detected" << endl;
 #endif
-    
+
     return;
   };
-  
+
   // Clear previous data if block was already complete
 
   if (valid()) clear();
-  
-  // Process carrier phase message       
-  
-  if ( P.ID()==18 ) {   
-    
+
+  // Process carrier phase message
+
+  if ( P.ID()==18 ) {
+
     // Number of satellites in current message
-    NSat = (P.nDataWords()-1)/2;  
-
-    // Current epoch (mod 3600 sec) 
-    t = 0.6*P.modZCount() 
+    NSat = (P.nDataWords()-1)/2;
+
+    // Current epoch (mod 3600 sec)
+    t = 0.6*P.modZCount()
         + P.getUnsignedBits(4,20)*1.0e-6;
-    
+
 #if (ROUND_EPOCH==1)
     // SC-104 V2.3 4-42 Note 1 4. Assume measurements at hard edges
@@ -1075,55 +1068,55 @@
     isOth = ( P.getUnsignedBits(1,1)==1 );
     if (isOth) return;
-     
+
     // Constellation (for first satellite in message)
     isGPS = ( P.getUnsignedBits(26,1)==0 );
     GPSonly = GPSonly && isGPS;
-    
+
     // Multiple Message Indicator (only checked for first satellite)
     // pendingMsg = ( P.getUnsignedBits(24,1)==1 );
-    
-    // Handle epoch: store epoch of first GPS message and 
+
+    // Handle epoch: store epoch of first GPS message and
     // check consistency of subsequent messages. GLONASS time tags
     // are different and have to be ignored
     if (isGPS) {
       if ( nSat==0 ) {
-        secs = t; // Store epoch 
+        secs = t; // Store epoch
       }
 //    else if (t!=secs) {
       else if (abs(t-secs)>1e-6) {
-        clear(); secs = t; // Clear all data, then store epoch 
+        clear(); secs = t; // Clear all data, then store epoch
       };
     };
 
-    // Discard GLONASS observations if no prior GPS observations 
-    // are available 
+    // Discard GLONASS observations if no prior GPS observations
+    // are available
     if (!isGPS && !anyGPS() ) return;
-        
+
     // Set availability flags
-    
+
     if ( isL1 &&  isGPS) availability.set(bit_L1cphGPS);
     if (!isL1 &&  isGPS) availability.set(bit_L2cphGPS);
     if ( isL1 && !isGPS) availability.set(bit_L1cphGLO);
     if (!isL1 && !isGPS) availability.set(bit_L2cphGLO);
-    
+
 #if ( DEBUG > 0 )
-    cerr << "RTCM2_Obs::extract(): availability " 
-         << bitset<8>(availability) << endl;  
-#endif
-    
-    
+    cerr << "RTCM2_Obs::extract(): availability "
+         << bitset<8>(availability) << endl;
+#endif
+
+
     // Process all satellites
-    
+
     for (int iSat=0;iSat<NSat;iSat++){
 
       // Code type
       isCAcode = ( P.getUnsignedBits(iSat*48+25,1)==0 );
-      
-      // Satellite 
+
+      // Satellite
       sid = P.getUnsignedBits(iSat*48+27,5);
       if (sid==0) sid=32;
-      
+
       prn = (isGPS? sid : sid+200 );
-      
+
       // Carrier phase measurement (mod 2^23 [cy]; sign matched to range)
       cph = -P.getBits(iSat*48+40,32)/256.0;
@@ -1149,5 +1142,5 @@
         slip_L2.push_back(-1);
       };
-      
+
       // Store measurement
       if (isL1) {
@@ -1159,21 +1152,21 @@
         slip_L2[idx] = slip_cnt;
       };
-           
+
     };
-  
-  };
-
-
-  // Process pseudorange message       
-  
-  if ( P.ID()==19 ) {   
-  
+
+  };
+
+
+  // Process pseudorange message
+
+  if ( P.ID()==19 ) {
+
     // Number of satellites in current message
-    NSat = (P.nDataWords()-1)/2;  
-
-    // Current epoch (mod 3600 sec) 
-    t = 0.6*P.modZCount() 
+    NSat = (P.nDataWords()-1)/2;
+
+    // Current epoch (mod 3600 sec)
+    t = 0.6*P.modZCount()
         + P.getUnsignedBits(4,20)*1.0e-6;
-    
+
 #if (ROUND_EPOCH==1)
     // SC-104 V2.3 4-42 Note 1 4. Assume measurements at hard edges
@@ -1188,9 +1181,9 @@
     isOth = ( P.getUnsignedBits(1,1)==1 );
     if (isOth) return;
-     
+
 #if (FIX_TRIMBLE_4000SSI==1)
     // Fix for data streams originating from TRIMBLE_4000SSI receivers.
     // GPS PRN32 is erroneously flagged as GLONASS satellite in the C/A
-    // pseudorange messages. We therefore use a majority voting to 
+    // pseudorange messages. We therefore use a majority voting to
     // determine the true constellation for this message.
     // This fix is only required for Trimble4000SSI receivers but can also
@@ -1202,5 +1195,5 @@
       if(isGPS) nGPS++;
     };
-    isGPS = (2*nGPS>NSat);  
+    isGPS = (2*nGPS>NSat);
 #else
     // Constellation (for first satellite in message)
@@ -1211,22 +1204,22 @@
     // Multiple Message Indicator (only checked for first satellite)
     // pendingMsg = ( P.getUnsignedBits(24,1)==1 );
-    
-    // Handle epoch: store epoch of first GPS message and 
+
+    // Handle epoch: store epoch of first GPS message and
     // check consistency of subsequent messages. GLONASS time tags
     // are different and have to be ignored
     if (isGPS) {
       if ( nSat==0 ) {
-        secs = t; // Store epoch 
+        secs = t; // Store epoch
       }
 //    else if (t!=secs) {
       else if (abs(t-secs)>1e-6) {
-        clear(); secs = t; // Clear all data, then store epoch 
+        clear(); secs = t; // Clear all data, then store epoch
       };
     };
 
-    // Discard GLONASS observations if no prior GPS observations 
-    // are available 
+    // Discard GLONASS observations if no prior GPS observations
+    // are available
     if (!isGPS && !anyGPS() ) return;
-        
+
     // Set availability flags
     if ( isL1 &&  isGPS) availability.set(bit_L1rngGPS);
@@ -1236,20 +1229,20 @@
 
 #if ( DEBUG > 0 )
-    cerr << "RTCM2_Obs::extract(): availability " 
-         << bitset<8>(availability) << endl;  
+    cerr << "RTCM2_Obs::extract(): availability "
+         << bitset<8>(availability) << endl;
 #endif
 
     // Process all satellites
-    
+
     for (int iSat=0;iSat<NSat;iSat++){
 
       // Code type
       isCAcode = ( P.getUnsignedBits(iSat*48+25,1)==0 );
-      
-      // Satellite 
+
+      // Satellite
       sid = P.getUnsignedBits(iSat*48+27,5);
       if (sid==0) sid=32;
       prn = (isGPS? sid : sid+200 );
-      
+
       // Pseudorange measurement [m]
       rng = P.getUnsignedBits(iSat*48+40,32)*0.02;
@@ -1272,5 +1265,5 @@
 	      slip_L2.push_back(-1);
       };
-      
+
       // Store measurement
       if (isL1) {
@@ -1279,5 +1272,5 @@
         }
         else {
-          rng_P1[idx] = rng; 
+          rng_P1[idx] = rng;
         }
       }
@@ -1285,15 +1278,15 @@
         rng_P2[idx] = rng;
       };
-           
+
     };
-  
-  };
-
-};
-
-//
-//  Resolution of 2^24 cy carrier phase ambiguity 
+
+  };
+
+};
+
+//
+//  Resolution of 2^24 cy carrier phase ambiguity
 //  caused by 32-bit data field restrictions
-//  
+//
 //  Note: the RTCM standard specifies an ambiguity of +/-2^23 cy.
 //  However, numerous receivers generate data in the +/-2^22 cy range.
@@ -1304,56 +1297,56 @@
 
 //const double  ambig = pow(2.0,24);   // as per RTCM2 spec
-  const double  ambig = pow(2.0,23);   // used by many receivers 
+  const double  ambig = pow(2.0,23);   // used by many receivers
 
   double        rng;
   double        n;
- 
+
   if (!valid() || i<0 || i>nSat-1) return 0.0;
 
-  rng = rng_C1[i]; 
+  rng = rng_C1[i];
   if (rng==0.0) rng = rng_P1[i];
   if (rng==0.0) return 0.0;
-  
+
   n = floor( (rng/lambda_L1-cph_L1[i]) / ambig + 0.5 );
-  
+
   return cph_L1[i] + n*ambig;
-  
-}; 
+
+};
 
 double RTCM2_Obs::resolvedPhase_L2(int i) const {
 
 //const double  ambig = pow(2.0,24);   // as per RTCM2 spec
-  const double  ambig = pow(2.0,23);   // used by many receivers 
+  const double  ambig = pow(2.0,23);   // used by many receivers
 
   double        rng;
   double        n;
-  
+
   if (!valid() || i<0 || i>nSat-1) return 0.0;
-  
-  rng = rng_C1[i]; 
+
+  rng = rng_C1[i];
   if (rng==0.0) rng = rng_P1[i];
   if (rng==0.0) return 0.0;
-  
+
   n = floor( (rng/lambda_L2-cph_L2[i]) / ambig + 0.5 );
-  
+
   return cph_L2[i] + n*ambig;
-  
-}; 
+
+};
 
 //
 //  Resolution of epoch using reference date (GPS week and secs)
-//  
-
-void RTCM2_Obs::resolveEpoch (int  refWeek,   double  refSecs,  
+//
+
+void RTCM2_Obs::resolveEpoch (int  refWeek,   double  refSecs,
                               int& epochWeek, double& epochSecs   ) const {
 
-  const double secsPerWeek = 604800.0;                            
+  const double secsPerWeek = 604800.0;
 
   epochWeek = refWeek;
   epochSecs = secs + 3600.0*(floor((refSecs-secs)/3600.0+0.5));
-  
+
   if (epochSecs<0          ) { epochWeek--; epochSecs+=secsPerWeek; };
   if (epochSecs>secsPerWeek) { epochWeek++; epochSecs-=secsPerWeek; };
-                              
+
 };
 
Index: trunk/BNC/src/RTCM/RTCM2.h
===================================================================
--- trunk/BNC/src/RTCM/RTCM2.h	(revision 7628)
+++ trunk/BNC/src/RTCM/RTCM2.h	(revision 7629)
@@ -2,6 +2,6 @@
 //
 // RTCM2.h
-// 
-// Purpose: 
+//
+// Purpose:
 //
 //   Module for extraction of RTCM2 messages
@@ -11,5 +11,5 @@
 //   RTCM 10402.3 Recommended Standards for Differential GNSS (Global
 //     Navigation Satellite Systems) Service; RTCM Paper 136-2001/SC104-STD,
-//     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime 
+//     Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime
 //     Services, Alexandria, Virgina (2001).
 //   ICD-GPS-200; Navstar GPS Space Segment / Navigation User Interfaces;
@@ -38,5 +38,5 @@
 #define INC_RTCM2_H
 
-#include <bitset> 
+#include <bitset>
 #include <fstream>
 #include <string>
@@ -55,5 +55,5 @@
 //
 // Purpose:
-//  
+//
 //   Handling of RTCM2 30bit words
 //
@@ -63,13 +63,13 @@
 
   public:
-  
+
     // Constructor and initialization
-    
+
     ThirtyBitWord();
-    
+
     void         clear();
 
     // Status queries
-    
+
     bool         fail() const;
     bool         validParity() const;
@@ -77,17 +77,17 @@
 
     // Access methods
-    
+
     unsigned int all() const;
     unsigned int value() const;
-    
+
     // Input
-    
+
     void         get(const std::string& buf);
     void         get(std::istream& inp);
     void         getHeader(std::string& buf);
     void         getHeader(std::istream& inp);
-  
-  private:
-     
+
+  private:
+
     // Input
 
@@ -102,5 +102,5 @@
     // parity bits retained from the previous word
     //
-    // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of 
+    // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of
     //             the previous 30-bit word
     // Bits 29..06 (from left to right) hold the current data bits D01..D24
@@ -108,6 +108,6 @@
     //
 
-    unsigned int W;         
-     
+    unsigned int W;
+
 };
 
@@ -125,35 +125,35 @@
 
 class RTCM2packet {
-  
-  public:
-  
+
+  public:
+
     // Constructor and initialization
-    
+
     RTCM2packet();
-   
+
     void clear();
-    
+
     // Status queries
 
-    bool valid() const;  
-    
-    // Input 
+    bool valid() const;
+
+    // Input
 
     void                 getPacket(std::string&  buf);
     void                 getPacket(std::istream& inp);
     friend std::istream& operator >> (std::istream& is, RTCM2packet& p);
-    
+
     //
     // Access methods
-    //    
-    
+    //
+
     // Header and data words contents (parity corrected)
-    
+
     unsigned int  header1() const;
     unsigned int  header2() const;
     unsigned int  dataWord(int i) const;
-    
+
     // Header information
-    
+
     unsigned int  msgType()    const;
     unsigned int  ID()         const { return msgType(); };
@@ -174,11 +174,11 @@
 
     // All input of RTCM data uses a single instance, W, of a 30-bit word
-    // to maintain parity bits between consecutive inputs. 
-    
+    // to maintain parity bits between consecutive inputs.
+
     ThirtyBitWord  W;
 
     // Two 30-bit words make up the header of an RTCM2 message
-    // (parity corrected) 
-    
+    // (parity corrected)
+
     unsigned int  H1;
     unsigned int  H2;
@@ -187,6 +187,6 @@
 
     std::vector<unsigned int> DW;
-    
-}; 
+
+};
 
 
@@ -202,13 +202,14 @@
 
 class RTCM2_03 {
-  
+
   public:
     // Constructor
-    RTCM2_03();
-
+    RTCM2_03() {
+      validMsg = false;
+      x = 0.0;
+      y = 0.0;
+      z = 0.0;
+    }
     void extract(const RTCM2packet& P);
-
-  public:
-
     bool    validMsg;          // Validity flag
     double  x,y,z;             // Station coordinates
@@ -230,9 +231,8 @@
 
   public:
-
+    RTCM2_23 () {
+      validMsg = false;
+    }
     void extract(const RTCM2packet& P);
-
-  public:
-
     bool         validMsg;        // Validity flag
     std::string  antType;         // Antenna descriptor
@@ -248,5 +248,5 @@
 // Purpose:
 //
-//   A class for handling RTCM 2 Reference Station Antenna 
+//   A class for handling RTCM 2 Reference Station Antenna
 //   Reference Point Parameter messages
 //
@@ -256,9 +256,14 @@
 
   public:
-
+    RTCM2_24 () {
+      validMsg  = false;
+      isGPS     = false;
+      isGLONASS = false;
+      x         = 0.0;
+      y         = 0.0;
+      z         = 0.0;
+      h         = 0.0;
+    }
     void extract(const RTCM2packet& P);
-
-  public:
-
     bool    validMsg;          // Validity flag
     bool    isGPS;             // Flag for GPS supporting station
@@ -277,5 +282,5 @@
 // Purpose:
 //
-//   A class for handling blocks of RTCM2 18 & 19 packets that need to be 
+//   A class for handling blocks of RTCM2 18 & 19 packets that need to be
 //   combined to get a complete set of measurements
 //
@@ -284,14 +289,14 @@
 class RTCM2_Obs {
 
-  public: 
+  public:
 
     RTCM2_Obs();                           // Constructor
-    
+
     void   extract(const RTCM2packet& P);  // Packet handler
     void   clear();                        // Initialization
-    bool   valid() const;                  // Check for complete obs block 
+    bool   valid() const;                  // Check for complete obs block
 
     double resolvedPhase_L1(int i) const;  // L1 & L2 carrier phase of i-th sat
-    double resolvedPhase_L2(int i) const;  // with resolved 2^24 cy ambiguity 
+    double resolvedPhase_L2(int i) const;  // with resolved 2^24 cy ambiguity
                                            // (based on rng_C1)
 
@@ -300,7 +305,7 @@
                          int&    epochWeek,
                          double& epochSecs  ) const;
-    
-                                               
-  public: 
+
+
+  public:
 
     double               secs;             // Seconds of hour (GPS time)
@@ -325,9 +330,9 @@
 
     typedef std::bitset<8> msgflags;
-    
+
     msgflags             availability;      // Msg availability flags
     bool                 GPSonly;           // Flag for GPS-only station
 
-}; 
+};
 
 
Index: trunk/BNC/src/RTCM/RTCM2_2021.cpp
===================================================================
--- trunk/BNC/src/RTCM/RTCM2_2021.cpp	(revision 7628)
+++ trunk/BNC/src/RTCM/RTCM2_2021.cpp	(revision 7629)
@@ -10,6 +10,4 @@
 const double ZEROVALUE = 1e-100;
 
-RTCM2_2021::RTCM2_2021() { }
-
 
 void RTCM2_2021::extract(const RTCM2packet& P) {
@@ -18,5 +16,5 @@
   }
 
-  // Error: at least 4 data words 
+  // Error: at least 4 data words
   if ( P.nDataWords()<5 ) {
 #if ( DEBUG > 0 )
@@ -26,5 +24,5 @@
     return;
   };
-  
+
   // Error: number of data words has to be odd number
   if ( P.nDataWords()%2==0 ){
@@ -36,6 +34,6 @@
   };
 
-  // Current epoch (mod 3600 sec) 
-  double tt = 0.6*P.modZCount() 
+  // Current epoch (mod 3600 sec)
+  double tt = 0.6*P.modZCount()
             + P.getUnsignedBits(4,20)*1.0e-6;
 
@@ -59,5 +57,5 @@
   double multipleMsgInd = true;
   for (unsigned iSat = 0; iSat < nSat; iSat++) {
-    bool     multInd   =   P.getBits        (iSat*48 + 24, 1); 
+    bool     multInd   =   P.getBits        (iSat*48 + 24, 1);
     bool     isGPS     = ( P.getUnsignedBits(iSat*48 + 26, 1)==0 );
     unsigned PRN       =   P.getUnsignedBits(iSat*48 + 27, 5);
@@ -71,5 +69,5 @@
       PRN = 32;
     }
-    
+
     HiResCorr* corr = 0;
     if ( !(corr = find_i(PRN)) ) {
@@ -80,5 +78,5 @@
       data[PRN] = corr;
     }
-    
+
     corr->PRN = PRN;
     corr->tt  = tt_;
@@ -106,5 +104,5 @@
     // Message number 21
     else if ( P.ID() == 21 ) {
-      bool   P_CA_Ind  =   P.getBits        (iSat*48 + 25, 1); 
+      bool   P_CA_Ind  =   P.getBits        (iSat*48 + 25, 1);
       double dcorrUnit = ( P.getUnsignedBits(iSat*48 + 32, 1) ? 0.032 : 0.002);
       double  corrUnit = ( P.getUnsignedBits(iSat*48 + 36, 1) ? 0.320 : 0.020);
@@ -127,5 +125,5 @@
     }
   }
-  
+
   valid_ = !multipleMsgInd;
 }
@@ -146,5 +144,5 @@
   tt_    = 0;
   valid_ = false;
-  for (map<unsigned, HiResCorr>::iterator 
+  for (map<unsigned, HiResCorr>::iterator
 	 ii = data_i_.begin(); ii != data_i_.end(); ii++) {
     ii->second.reset();
@@ -155,5 +153,5 @@
 
 RTCM2_2021::HiResCorr::HiResCorr() :
-  PRN(0), tt(0), 
+  PRN(0), tt(0),
   phase1 (0),     phase2 (2),
   lock1  (0),     lock2  (0),
@@ -163,5 +161,5 @@
   drange1(0),     drange2(0),
   Pind1  (false), Pind2  (false),
-  IODr1  (0),     IODr2  (0) { 
+  IODr1  (0),     IODr2  (0) {
 }
 
Index: trunk/BNC/src/RTCM/RTCM2_2021.h
===================================================================
--- trunk/BNC/src/RTCM/RTCM2_2021.h	(revision 7628)
+++ trunk/BNC/src/RTCM/RTCM2_2021.h	(revision 7629)
@@ -8,6 +8,8 @@
 
   public:
-
-    RTCM2_2021();                           // Constructor
+    RTCM2_2021() {// Constructor
+      tt_    = 0.0;
+      valid_ = false;
+    }
 
     void   extract(const RTCM2packet& P);  // Packet handler
@@ -18,6 +20,4 @@
     double resolvedPhase_L2(int i) const;  // with resolved 2^24 cy ambiguity
                                            // (based on rng_C1)
-
-  public:
 
     struct HiResCorr {
