[3528] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: GPSDecoder
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Decoder Base Class
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 16-Dec-2011
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iomanip>
|
---|
| 42 | #include <cmath>
|
---|
| 43 |
|
---|
| 44 | #include "GPSDecoder.h"
|
---|
| 45 | #include "bncsettings.h"
|
---|
| 46 |
|
---|
[4439] | 47 | extern "C" {
|
---|
[4440] | 48 | #include "rtcm3torinex.h"
|
---|
[4439] | 49 | }
|
---|
[4422] | 50 |
|
---|
[3528] | 51 | using namespace std;
|
---|
| 52 |
|
---|
| 53 | // Constructor
|
---|
| 54 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 55 | GPSDecoder::GPSDecoder() {
|
---|
[3529] | 56 | _rnx = 0;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | // Initialize RINEX Writer
|
---|
| 60 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 61 | void GPSDecoder::initRinex(const QByteArray& staID, const QUrl& mountPoint,
|
---|
| 62 | const QByteArray& latitude,
|
---|
| 63 | const QByteArray& longitude, const QByteArray& nmea,
|
---|
| 64 | const QByteArray& ntripVersion) {
|
---|
| 65 | if (_rnx) {
|
---|
| 66 | return;
|
---|
| 67 | }
|
---|
[3528] | 68 | bncSettings settings;
|
---|
[3529] | 69 | if ( !settings.value("rnxPath").toString().isEmpty() ) {
|
---|
| 70 | _rnx = new bncRinex(staID, mountPoint, latitude, longitude,
|
---|
| 71 | nmea, ntripVersion);
|
---|
[3528] | 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | // Write RINEX Epoch
|
---|
| 76 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 77 | void GPSDecoder::dumpRinexEpoch(const t_obs& obs, const QByteArray& format) {
|
---|
| 78 | if (_rnx) {
|
---|
| 79 | long iSec = long(floor(obs.GPSWeeks+0.5));
|
---|
| 80 | long obsTime = obs.GPSWeek * 7*24*3600 + iSec;
|
---|
| 81 | if (_rnx->samplingRate() == 0 || iSec % _rnx->samplingRate() == 0) {
|
---|
| 82 | _rnx->deepCopy(obs);
|
---|
| 83 | }
|
---|
| 84 | _rnx->dumpEpoch(format, obsTime);
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | // Set RINEX Reconnect Flag
|
---|
| 89 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 90 | void GPSDecoder::setRinexReconnectFlag(bool flag) {
|
---|
| 91 | if (_rnx) {
|
---|
| 92 | _rnx->setReconnectFlag(flag);
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
[4392] | 95 |
|
---|
| 96 | //
|
---|
| 97 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5367] | 98 | void t_obs::setMeasdata(QString rnxStr, float rnxVers, double value) {
|
---|
| 99 |
|
---|
| 100 | if (rnxVers < 3.0) {
|
---|
| 101 | if (rnxStr == "C1") rnxStr = "C1C";
|
---|
| 102 | else if (rnxStr == "P1") rnxStr = "C1P";
|
---|
| 103 | else if (rnxStr == "C2") rnxStr = "C2C";
|
---|
| 104 | else if (rnxStr == "P2") rnxStr = "C2P";
|
---|
[4393] | 105 | }
|
---|
[5367] | 106 |
|
---|
[5368] | 107 | int ie = iEntry(rnxStr, rnxVers);
|
---|
| 108 |
|
---|
| 109 | if (ie != -1) {
|
---|
| 110 | _codetype[ie] = rnxStr.mid(1);
|
---|
| 111 | _measdata[ie] = value;
|
---|
[5367] | 112 | }
|
---|
[4393] | 113 | }
|
---|
[4392] | 114 |
|
---|
| 115 | //
|
---|
| 116 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4403] | 117 | double t_obs::measdata(const QString& rnxStr, float rnxVers) const {
|
---|
[4415] | 118 | int ie = iEntry(rnxStr, rnxVers);
|
---|
[4403] | 119 | if (ie != -1) {
|
---|
| 120 | return _measdata[ie];
|
---|
| 121 | }
|
---|
| 122 | else {
|
---|
| 123 | return 0.0;
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
[4392] | 126 |
|
---|
[4403] | 127 | //
|
---|
| 128 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5370] | 129 | QString t_obs::rnxStr(int iEntry) const {
|
---|
[5380] | 130 | QString str(1,' ');
|
---|
[5370] | 131 | switch(iEntry & 3) {
|
---|
| 132 | case GNSSENTRY_CODE: str[0] = 'C'; break;
|
---|
| 133 | case GNSSENTRY_PHASE: str[0] = 'L'; break;
|
---|
| 134 | case GNSSENTRY_DOPPLER: str[0] = 'D'; break;
|
---|
| 135 | case GNSSENTRY_SNR: str[0] = 'S'; break;
|
---|
| 136 | }
|
---|
| 137 | str += _codetype[iEntry];
|
---|
| 138 | return str.trimmed();
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | //
|
---|
| 142 | //////////////////////////////////////////////////////////////////////////////
|
---|
[4415] | 143 | int t_obs::iEntry(QString rnxStr, float rnxVers) const {
|
---|
[5370] | 144 |
|
---|
[4415] | 145 | if (rnxVers < 3.0) {
|
---|
| 146 | if (rnxStr == "C1") rnxStr = "C1C";
|
---|
| 147 | else if (rnxStr == "P1") rnxStr = "C1P";
|
---|
| 148 | else if (rnxStr == "C2") rnxStr = "C2C";
|
---|
| 149 | else if (rnxStr == "P2") rnxStr = "C2P";
|
---|
[4412] | 150 | }
|
---|
[5370] | 151 |
|
---|
[5368] | 152 | int res = 0;
|
---|
[5370] | 153 |
|
---|
| 154 | // Observation Type (Code, Phase, Doppler, SNR)
|
---|
| 155 | // --------------------------------------------
|
---|
| 156 | if (rnxStr[0] == 'C') {
|
---|
| 157 | res += GNSSENTRY_CODE;
|
---|
| 158 | }
|
---|
| 159 | else if (rnxStr[0] == 'L') {
|
---|
| 160 | res += GNSSENTRY_PHASE;
|
---|
| 161 | }
|
---|
| 162 | else if (rnxStr[0] == 'D') {
|
---|
| 163 | res += GNSSENTRY_DOPPLER;
|
---|
| 164 | }
|
---|
| 165 | else if (rnxStr[0] == 'S') {
|
---|
| 166 | res += GNSSENTRY_SNR;
|
---|
| 167 | }
|
---|
| 168 | else {
|
---|
[5368] | 169 | return -1;
|
---|
| 170 | }
|
---|
[5370] | 171 |
|
---|
| 172 | // Frequency
|
---|
| 173 | // ---------
|
---|
| 174 | if (rnxStr[1] == '1') {
|
---|
| 175 | if (rnxStr.length() < 3) {
|
---|
| 176 | res += GNSSENTRY_TYPEC1;
|
---|
[5355] | 177 | }
|
---|
[5374] | 178 | else if (QString("ABCIQ").indexOf(rnxStr[2]) != -1) {
|
---|
[5370] | 179 | res += GNSSENTRY_TYPEC1;
|
---|
| 180 | }
|
---|
[5374] | 181 | else if (QString("SL").indexOf(rnxStr[2]) != -1) {
|
---|
| 182 | res += GNSSENTRY_TYPEC1N;
|
---|
| 183 | }
|
---|
[5370] | 184 | else if (QString("PWY").indexOf(rnxStr[2]) != -1) {
|
---|
| 185 | res += GNSSENTRY_TYPEP1;
|
---|
| 186 | }
|
---|
| 187 | else if (rnxStr[2] == 'Z') {
|
---|
| 188 | res += GNSSENTRY_TYPECSAIF;
|
---|
| 189 | }
|
---|
[5374] | 190 | else if (rnxStr[2] == 'X') {
|
---|
[5375] | 191 | if (satSys == 'C' || satSys == 'E') {
|
---|
[5374] | 192 | res += GNSSENTRY_TYPEC1;
|
---|
| 193 | }
|
---|
| 194 | else {
|
---|
| 195 | res += GNSSENTRY_TYPEC1N;
|
---|
| 196 | }
|
---|
| 197 | }
|
---|
[5370] | 198 | else {
|
---|
| 199 | return -1;
|
---|
| 200 | }
|
---|
| 201 | }
|
---|
| 202 | else if (rnxStr[1] == '2') {
|
---|
| 203 | if (rnxStr.length() < 3) {
|
---|
| 204 | res += GNSSENTRY_TYPEP2;
|
---|
| 205 | }
|
---|
[5371] | 206 | else if (QString("PWY").indexOf(rnxStr[2]) != -1) {
|
---|
[5370] | 207 | res += GNSSENTRY_TYPEP2;
|
---|
| 208 | }
|
---|
[5371] | 209 | else if (QString("CSLX").indexOf(rnxStr[2]) != -1) {
|
---|
[5370] | 210 | res += GNSSENTRY_TYPEC2;
|
---|
| 211 | }
|
---|
[5375] | 212 | else if (rnxStr[2] == 'I') {
|
---|
| 213 | if (satSys == 'C') {
|
---|
| 214 | res += GNSSENTRY_TYPEC1; // Compass: RINEX 3.01 "2I" corresponds to "1I" RINEX 3.02
|
---|
| 215 | }
|
---|
| 216 | else {
|
---|
| 217 | res += GNSSENTRY_TYPEC2;
|
---|
| 218 | }
|
---|
| 219 | }
|
---|
| 220 | else if (rnxStr[2] == 'Q') {
|
---|
[5374] | 221 | res += GNSSENTRY_TYPEC2;
|
---|
[5368] | 222 | }
|
---|
[5370] | 223 | else {
|
---|
| 224 | return -1;
|
---|
| 225 | }
|
---|
| 226 | }
|
---|
| 227 | else if (rnxStr[1] == '5') {
|
---|
[5368] | 228 | res += GNSSENTRY_TYPEC5;
|
---|
[5370] | 229 | }
|
---|
| 230 | else if (rnxStr[1] == '6') {
|
---|
[5368] | 231 | res += GNSSENTRY_TYPEC6;
|
---|
[5370] | 232 | }
|
---|
| 233 | else if (rnxStr[1] == '7') {
|
---|
[5368] | 234 | res += GNSSENTRY_TYPEC5B;
|
---|
[5370] | 235 | }
|
---|
| 236 | else if (rnxStr[1] == '8') {
|
---|
[5368] | 237 | res += GNSSENTRY_TYPEC5AB;
|
---|
[5355] | 238 | }
|
---|
[5370] | 239 | else {
|
---|
| 240 | return -1;
|
---|
| 241 | }
|
---|
| 242 |
|
---|
[5368] | 243 | return res;
|
---|
[4392] | 244 | }
|
---|