source: ntrip/trunk/BNC/RTCM3/RTCM3Decoder.cpp@ 454

Last change on this file since 454 was 454, checked in by mervart, 17 years ago

* empty log message *

File size: 5.2 KB
RevLine 
[297]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.
[296]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
48using namespace std;
49
50#ifndef isinf
51# define isinf(x) 0
52#endif
53
[320]54// Error Handling
55////////////////////////////////////////////////////////////////////////////
56void RTCM3Error(const char *fmt, ...) {
57
58}
59
[296]60// Constructor
61////////////////////////////////////////////////////////////////////////////
62RTCM3Decoder::RTCM3Decoder() : GPSDecoder() {
63 memset(&_Parser, 0, sizeof(_Parser));
64 time_t tim;
65 tim = time(0) - ((10*365+2+5)*24*60*60 + LEAPSECONDS);
66 _Parser.GPSWeek = tim/(7*24*60*60);
67 _Parser.GPSTOW = tim%(7*24*60*60);
68}
69
70// Destructor
71////////////////////////////////////////////////////////////////////////////
72RTCM3Decoder::~RTCM3Decoder() {
73}
74
75//
76////////////////////////////////////////////////////////////////////////////
77void RTCM3Decoder::Decode(char* buffer, int bufLen) {
78 for (int ii = 0; ii < bufLen; ii++) {
79
80 _Parser.Message[_Parser.MessageSize++] = buffer[ii];
81 if (_Parser.MessageSize >= _Parser.NeedBytes) {
82
83 while(int rr = RTCM3Parser(&_Parser)) {
84
85 if (!_Parser.init) {
86 HandleHeader(&_Parser);
87 _Parser.init = 1;
88 }
89
90 if (rr == 2) {
91 std::cerr << "No valid RINEX! All values are modulo 299792.458!\n";
92 }
93
94 for (int ii = 0; ii < _Parser.Data.numsats; ii++) {
95 Observation* obs = new Observation();
[341]96 if (_Parser.Data.satellites[ii] <= PRN_GPS_END) {
97 obs->satSys = 'G';
98 obs->satNum = _Parser.Data.satellites[ii];
99 }
100 else {
101 obs->satSys = 'R';
102 obs->satNum = _Parser.Data.satellites[ii] - PRN_GLONASS_START + 1;
103 }
[296]104 obs->GPSWeek = _Parser.Data.week;
105 obs->GPSWeeks = _Parser.Data.timeofweek / 1000.0;
106
107 for (int jj = 0; jj < _Parser.numdatatypes; jj++) {
[366]108 int v = 0;
109 int df = _Parser.dataflag[jj];
110 int pos = _Parser.datapos[jj];
111 if ( (_Parser.Data.dataflags[ii] & df)
112 && !isnan(_Parser.Data.measdata[ii][pos])
113 && !isinf(_Parser.Data.measdata[ii][pos])) {
114 v = 1;
[296]115 }
[366]116 else {
117 df = _Parser.dataflag2[jj];
118 pos = _Parser.datapos2[jj];
119 if ( (_Parser.Data.dataflags[ii] & df)
120 && !isnan(_Parser.Data.measdata[ii][pos])
121 && !isinf(_Parser.Data.measdata[ii][pos])) {
122 v = 1;
123 }
124 }
125 if(!v)
126 { continue; }
127 else
128 {
[296]129 if (_Parser.dataflag[jj] & GNSSDF_C1DATA) {
130 obs->C1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
131 }
[366]132 else if (_Parser.dataflag[jj] & GNSSDF_C2DATA) {
133 obs->C2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
134 }
[296]135 else if (_Parser.dataflag[jj] & GNSSDF_P1DATA) {
136 obs->P1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
137 }
138 else if (_Parser.dataflag[jj] & GNSSDF_P2DATA) {
139 obs->P2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]];
140 }
[366]141 else if (df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) {
142 obs->L1 = _Parser.Data.measdata[ii][pos];
[296]143 obs->SNR1 = _Parser.Data.snrL1[ii];
144 }
[366]145 else if (df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) {
146 obs->L2 = _Parser.Data.measdata[ii][pos];
[296]147 obs->SNR2 = _Parser.Data.snrL2[ii];
148 }
[367]149 else if (df & (GNSSDF_S1CDATA|GNSSDF_S1PDATA)) {
150 obs->S1 = _Parser.Data.measdata[ii][pos];
151 }
152 else if (df & (GNSSDF_S2CDATA|GNSSDF_S2PDATA)) {
153 obs->S2 = _Parser.Data.measdata[ii][pos];
154 }
[296]155 }
[366]156 }
[296]157 _obsList.push_back(obs);
158 }
159 }
160 }
161 }
162}
Note: See TracBrowser for help on using the repository browser.