source: ntrip/trunk/BNC/RTCM3/rtcm3.cpp@ 222

Last change on this file since 222 was 222, checked in by mervart, 18 years ago

* empty log message *

File size: 3.0 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Client
4 * -------------------------------------------------------------------------
5 *
6 * Class: rtcm3
7 *
8 * Purpose: RTCM3 Decoder
9 *
10 * Author: L. Mervart
11 *
12 * Created: 24-Aug-2006
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19#include <math.h>
20
21#include "rtcm3.h"
22
23using namespace std;
24
25#ifndef isinf
26# define isinf(x) 0
27#endif
28
29// Constructor
30////////////////////////////////////////////////////////////////////////////
31rtcm3::rtcm3() : GPSDecoder() {
32 memset(&_Parser, 0, sizeof(_Parser));
33 time_t tim;
34 tim = time(0) - ((10*365+2+5)*24*60*60 + LEAPSECONDS);
35 _Parser.GPSWeek = tim/(7*24*60*60);
36 _Parser.GPSTOW = tim%(7*24*60*60);
37}
38
39// Destructor
40////////////////////////////////////////////////////////////////////////////
41rtcm3::~rtcm3() {
42}
43
44//
45////////////////////////////////////////////////////////////////////////////
46void rtcm3::Decode(char* buffer, int bufLen) {
47 for (int ii = 0; ii < bufLen; ii++) {
48
49 _Parser.Message[_Parser.MessageSize++] = buffer[ii];
50 if (_Parser.MessageSize >= _Parser.NeedBytes) {
51
52 while(int rr = RTCM3Parser(&_Parser)) {
53
54 if (!_Parser.init) {
55 HandleHeader(&_Parser);
56 _Parser.init = 1;
57 }
58
59 if (rr == 2) {
60 std::cerr << "No valid RINEX! All values are modulo 299792.458!\n";
61 exit(1);
62 }
63
64 for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
65 Observation* obs = new Observation();
66 obs->SVPRN = _Parser.Data.satellites[ii];
67 obs->GPSWeek = _Parser.Data.week;
68 obs->GPSWeeks = _Parser.Data.timeofweek / 1000.0;
69
70 for (int jj = 0; jj < _Parser.numdatatypes; jj++) {
71
72 if ( !(_Parser.Data.dataflags[ii] & _Parser.dataflag[jj])
73 || isnan(_Parser.Data.measdata[ii][_Parser.datapos[jj]])
74 || isinf(_Parser.Data.measdata[ii][_Parser.datapos[jj]]) ) {
75 continue;
76 }
77
78 if (_Parser.dataflag[jj] & GNSSDF_C1DATA) {
79 obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
80 }
81 else if (_Parser.dataflag[jj] & GNSSDF_P1DATA) {
82 obs->P1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
83 }
84 else if (_Parser.dataflag[jj] & GNSSDF_P2DATA) {
85 obs->P2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
86 }
87 else if (_Parser.dataflag[jj] & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
88 obs->L1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
89 obs->SNR1 = _Parser.Data.snrL1[ii];
90 }
91 else if (_Parser.dataflag[jj] & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
92 obs->L2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
93 obs->SNR2 = _Parser.Data.snrL2[ii];
94 }
95 }
96 _obsList.push_back(obs);
97 }
98 }
99 }
100 }
101}
Note: See TracBrowser for help on using the repository browser.