1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters,
|
---|
3 | // written by Leos Mervart.
|
---|
4 | //
|
---|
5 | // Copyright (C) 2006
|
---|
6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
7 | // http://www.bkg.bund.de
|
---|
8 | // Czech Technical University Prague, Department of Advanced Geodesy
|
---|
9 | // http://www.fsv.cvut.cz
|
---|
10 | //
|
---|
11 | // Email: euref-ip@bkg.bund.de
|
---|
12 | //
|
---|
13 | // This program is free software; you can redistribute it and/or
|
---|
14 | // modify it under the terms of the GNU General Public License
|
---|
15 | // as published by the Free Software Foundation, version 2.
|
---|
16 | //
|
---|
17 | // This program is distributed in the hope that it will be useful,
|
---|
18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | // GNU General Public License for more details.
|
---|
21 | //
|
---|
22 | // You should have received a copy of the GNU General Public License
|
---|
23 | // along with this program; if not, write to the Free Software
|
---|
24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
25 |
|
---|
26 | /* -------------------------------------------------------------------------
|
---|
27 | * BKG NTRIP Client
|
---|
28 | * -------------------------------------------------------------------------
|
---|
29 | *
|
---|
30 | * Class: RTCM3Decoder
|
---|
31 | *
|
---|
32 | * Purpose: RTCM3 Decoder
|
---|
33 | *
|
---|
34 | * Author: L. Mervart
|
---|
35 | *
|
---|
36 | * Created: 24-Aug-2006
|
---|
37 | *
|
---|
38 | * Changes:
|
---|
39 | *
|
---|
40 | * -----------------------------------------------------------------------*/
|
---|
41 |
|
---|
42 | #include <iostream>
|
---|
43 | #include <math.h>
|
---|
44 |
|
---|
45 | #include "RTCM3Decoder.h"
|
---|
46 | #include "bncconst.h"
|
---|
47 |
|
---|
48 | using namespace std;
|
---|
49 |
|
---|
50 | #ifndef isinf
|
---|
51 | # define isinf(x) 0
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | // Constructor
|
---|
55 | ////////////////////////////////////////////////////////////////////////////
|
---|
56 | RTCM3Decoder::RTCM3Decoder() : GPSDecoder() {
|
---|
57 | memset(&_Parser, 0, sizeof(_Parser));
|
---|
58 | time_t tim;
|
---|
59 | tim = time(0) - ((10*365+2+5)*24*60*60 + LEAPSECONDS);
|
---|
60 | _Parser.GPSWeek = tim/(7*24*60*60);
|
---|
61 | _Parser.GPSTOW = tim%(7*24*60*60);
|
---|
62 | }
|
---|
63 |
|
---|
64 | // Destructor
|
---|
65 | ////////////////////////////////////////////////////////////////////////////
|
---|
66 | RTCM3Decoder::~RTCM3Decoder() {
|
---|
67 | }
|
---|
68 |
|
---|
69 | //
|
---|
70 | ////////////////////////////////////////////////////////////////////////////
|
---|
71 | void RTCM3Decoder::Decode(char* buffer, int bufLen) {
|
---|
72 | for (int ii = 0; ii < bufLen; ii++) {
|
---|
73 |
|
---|
74 | _Parser.Message[_Parser.MessageSize++] = buffer[ii];
|
---|
75 | if (_Parser.MessageSize >= _Parser.NeedBytes) {
|
---|
76 |
|
---|
77 | while(int rr = RTCM3Parser(&_Parser)) {
|
---|
78 |
|
---|
79 | if (!_Parser.init) {
|
---|
80 | HandleHeader(&_Parser);
|
---|
81 | _Parser.init = 1;
|
---|
82 | }
|
---|
83 |
|
---|
84 | if (rr == 2) {
|
---|
85 | std::cerr << "No valid RINEX! All values are modulo 299792.458!\n";
|
---|
86 | exit(1);
|
---|
87 | }
|
---|
88 |
|
---|
89 | for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
|
---|
90 | Observation* obs = new Observation();
|
---|
91 | obs->SVPRN = _Parser.Data.satellites[ii];
|
---|
92 | obs->GPSWeek = _Parser.Data.week;
|
---|
93 | obs->GPSWeeks = _Parser.Data.timeofweek / 1000.0;
|
---|
94 |
|
---|
95 | for (int jj = 0; jj < _Parser.numdatatypes; jj++) {
|
---|
96 |
|
---|
97 | if ( !(_Parser.Data.dataflags[ii] & _Parser.dataflag[jj])
|
---|
98 | || isnan(_Parser.Data.measdata[ii][_Parser.datapos[jj]])
|
---|
99 | || isinf(_Parser.Data.measdata[ii][_Parser.datapos[jj]]) ) {
|
---|
100 | continue;
|
---|
101 | }
|
---|
102 |
|
---|
103 | if (_Parser.dataflag[jj] & GNSSDF_C1DATA) {
|
---|
104 | obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
|
---|
105 | }
|
---|
106 | else if (_Parser.dataflag[jj] & GNSSDF_P1DATA) {
|
---|
107 | obs->P1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
|
---|
108 | }
|
---|
109 | else if (_Parser.dataflag[jj] & GNSSDF_P2DATA) {
|
---|
110 | obs->P2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
|
---|
111 | }
|
---|
112 | else if (_Parser.dataflag[jj] & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
|
---|
113 | obs->L1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
|
---|
114 | obs->SNR1 = _Parser.Data.snrL1[ii];
|
---|
115 | }
|
---|
116 | else if (_Parser.dataflag[jj] & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
|
---|
117 | obs->L2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
|
---|
118 | obs->SNR2 = _Parser.Data.snrL2[ii];
|
---|
119 | }
|
---|
120 | }
|
---|
121 | _obsList.push_back(obs);
|
---|
122 | }
|
---|
123 | }
|
---|
124 | }
|
---|
125 | }
|
---|
126 | }
|
---|