Changeset 1807 in ntrip for trunk/BNC/RTCM3/RTCM3Decoder.cpp


Ignore:
Timestamp:
Apr 23, 2009, 7:11:25 PM (15 years ago)
Author:
zdenek
Message:

ZL: FEATURE: changes for decoding of message 1003 from RTCM 3.0 streams

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/RTCM3/RTCM3Decoder.cpp

    r1580 r1807  
    4040
    4141#include <iostream>
     42#include <iomanip>
     43#include <sstream>
    4244#include <math.h>
    4345#include <string.h>
    4446
    4547#include "RTCM3Decoder.h"
     48#include "../RTCM/rtcm_utils.h"
    4649#include "bncconst.h"
    4750#include "bncapp.h"
     
    8992  // ----------------------------------------------
    9093  _mode = unknown;
     94
     95  // Antenna position (used for decoding of message 1003)
     96  // ----------------------------------------------------
     97  _antXYZ[0] = _antXYZ[1] = _antXYZ[2] = 0;
     98
    9199}
    92100
     
    148156            _antList.back().zz       = _Parser.antZ * 1e-4;
    149157            _antList.back().message  = rr;
     158
     159            // Remember station position for 1003 message decoding
     160            _antXYZ[0] = _Parser.antX * 1e-4;
     161            _antXYZ[1] = _Parser.antY * 1e-4;
     162            _antXYZ[2] = _Parser.antZ * 1e-4;
    150163          }
    151164
     
    162175            _antList.back().height_f = true;
    163176            _antList.back().message  = rr;
     177
     178            // Remember station position for 1003 message decoding
     179            _antXYZ[0] = _Parser.antX * 1e-4;
     180            _antXYZ[1] = _Parser.antY * 1e-4;
     181            _antXYZ[2] = _Parser.antZ * 1e-4;
    164182          }
    165183
     
    174192            }
    175193           
     194            // apply "GPS Integer L1 Pseudorange Modulus Ambiguity"
     195            bool applyModulusAmb = false;
     196            ///if (rr == 2) {
     197            ///  applyModulusAmb = true;
     198            ///}
     199
    176200            if (rr == 2) {
    177201              emit(newMessage( (_staID + ": No valid RINEX! All values are modulo 299792.458!").toAscii(), true));
     
    195219              obs->_o.GPSWeek  = _Parser.Data.week;
    196220              obs->_o.GPSWeeks = _Parser.Data.timeofweek / 1000.0;
     221
     222              // Estimate "GPS Integer L1 Pseudorange Modulus Ambiguity"
     223              // -------------------------------------------------------
     224              double modulusAmb = 0;
     225              if (applyModulusAmb) {
     226                // Missing antenna coordinates: skip all data
     227                if ( !_antXYZ[0] && !_antXYZ[1] && !_antXYZ[2] ) {
     228                  continue;
     229                }
     230               
     231                ostringstream prns;
     232                prns << obs->_o.satSys << setfill('0') << setw(2) << obs->_o.satNum;
     233
     234                string prn = prns.str();
     235
     236                // Missing ephemerides, skip satellite
     237                if (_ephList.find(prn) == _ephList.end()) {
     238                  continue;
     239                }
     240               
     241                const t_eph* eph = &(_ephList.find(prn)->second);
     242                 
     243                double rho, xSat, ySat, zSat, clkSat, GPSWeeks_tot;
     244                int    GPSWeek_tot;
     245                cmpRho(eph, _antXYZ[0], _antXYZ[1], _antXYZ[2],
     246                       obs->_o.GPSWeek, obs->_o.GPSWeeks,
     247                       rho, GPSWeek_tot, GPSWeeks_tot,
     248                       xSat, ySat, zSat, clkSat);
     249
     250                const double CC = 299792458.0;
     251
     252                int nn = static_cast<int>(rho / (CC * 0.001));
     253
     254                modulusAmb = nn * CC * 0.001;
     255              }
    197256           
     257              // Loop over all data types
     258              // ------------------------
    198259              for (int jj = 0; jj < _Parser.numdatatypesGPS; jj++) {
    199260                int v = 0;
     
    228289                  // variables df and pos are used consequently. Perlt
    229290                  if      (df & GNSSDF_C1DATA) {
    230                     obs->_o.C1 = _Parser.Data.measdata[ii][pos];
     291                    obs->_o.C1 = _Parser.Data.measdata[ii][pos] + modulusAmb;
    231292                  }
    232293                  else if (df & GNSSDF_C2DATA) {
    233                     obs->_o.C2 = _Parser.Data.measdata[ii][pos];
     294                    obs->_o.C2 = _Parser.Data.measdata[ii][pos] + modulusAmb;
    234295                  }
    235296                  else if (df & GNSSDF_P1DATA) {
    236                     obs->_o.P1 = _Parser.Data.measdata[ii][pos];
     297                    obs->_o.P1 = _Parser.Data.measdata[ii][pos] + modulusAmb;
    237298                  }
    238299                  else if (df & GNSSDF_P2DATA) {
    239                     obs->_o.P2 = _Parser.Data.measdata[ii][pos];
     300                    obs->_o.P2 = _Parser.Data.measdata[ii][pos] + modulusAmb;
    240301                  }
    241302                  else if (df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
    242                     obs->_o.L1            = _Parser.Data.measdata[ii][pos];
     303                    obs->_o.L1            = _Parser.Data.measdata[ii][pos] + modulusAmb;
    243304                    obs->_o.SNR1          = _Parser.Data.snrL1[ii];
    244305                    obs->_o.lock_timei_L1 = _Parser.lastlockl1[isat];
    245306                  }
    246307                  else if (df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
    247                     obs->_o.L2            = _Parser.Data.measdata[ii][pos];
     308                    obs->_o.L2            = _Parser.Data.measdata[ii][pos] + modulusAmb;
    248309                    obs->_o.SNR2          = _Parser.Data.snrL2[ii];
    249310                    obs->_o.lock_timei_L2 = _Parser.lastlockl2[isat];
     
    290351  }
    291352}
     353
     354// Store ephemerides
     355////////////////////////////////////////////////////////////////////////////////////////
     356bool RTCM3Decoder::storeEph(const gpsephemeris& gpseph) {
     357  t_ephGPS eph; eph.set(&gpseph);
     358
     359  return storeEph(eph);
     360}
     361
     362
     363bool RTCM3Decoder::storeEph(const t_ephGPS& gpseph) {
     364  double weekold = 0.0;
     365  double weeknew = gpseph.GPSweek() + gpseph.GPSweeks() / 86400.0;
     366  if ( _ephList.find(gpseph.prn()) != _ephList.end() ) {
     367    weekold = _ephList.find(gpseph.prn())->second.GPSweek()
     368            + _ephList.find(gpseph.prn())->second.GPSweeks() / 86400.0;
     369  }
     370
     371  if ( weeknew - weekold > 1/86400.0 ) {
     372    _ephList[gpseph.prn()] = gpseph;
     373
     374    return true;
     375  }
     376
     377  return false;
     378}
Note: See TracChangeset for help on using the changeset viewer.