[3716] | 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 | #ifndef RNXOBSFILE_H
|
---|
| 26 | #define RNXOBSFILE_H
|
---|
| 27 |
|
---|
[3718] | 28 | #include <QtCore>
|
---|
[3717] | 29 |
|
---|
[3716] | 30 | #include <fstream>
|
---|
| 31 | #include <vector>
|
---|
| 32 | #include <map>
|
---|
| 33 |
|
---|
| 34 | #include "newmat.h"
|
---|
| 35 | #include "bncconst.h"
|
---|
| 36 | #include "bnctime.h"
|
---|
[5742] | 37 | #include "t_prn.h"
|
---|
[6137] | 38 | #include "satObs.h"
|
---|
[3716] | 39 |
|
---|
[8127] | 40 | #define defaultRnxObsVersion2 2.11
|
---|
[9396] | 41 | #define defaultRnxObsVersion3 3.05
|
---|
[10587] | 42 | #define defaultRnxObsVersion4 4.02
|
---|
[8127] | 43 |
|
---|
[4480] | 44 | class t_rnxObsHeader {
|
---|
[6119] | 45 |
|
---|
| 46 | friend class t_rnxObsFile;
|
---|
| 47 |
|
---|
[4480] | 48 | public:
|
---|
[5375] | 49 |
|
---|
[4480] | 50 | t_rnxObsHeader();
|
---|
| 51 | ~t_rnxObsHeader();
|
---|
| 52 |
|
---|
[6225] | 53 | double version() const {return _version;}
|
---|
[9770] | 54 | double versionFromInt(int version);
|
---|
[6119] | 55 | t_irc read(QTextStream* stream, int maxLines = 0);
|
---|
[6222] | 56 | void setDefault(const QString& markerName, int version);
|
---|
[6841] | 57 | void set(const t_rnxObsHeader& header, int version,
|
---|
| 58 | const QStringList* useObsTypes = 0, const QStringList* phaseShifts = 0,
|
---|
[9945] | 59 | const QStringList* gloBiases = 0, const QStringList* gloSlots = 0,
|
---|
| 60 | const QStringList* runByDate = 0);
|
---|
[6119] | 61 | int numSys() const;
|
---|
[6130] | 62 | char system(int iSys) const;
|
---|
[6119] | 63 | int nTypes(char sys) const;
|
---|
[6841] | 64 | int numGloBiases() const;
|
---|
| 65 | int numGloSlots() const;
|
---|
[6126] | 66 | QString obsType(char sys, int index, double version = 0.0) const;
|
---|
[7474] | 67 | QString usedSystems() const;
|
---|
| 68 | QStringList obsTypes(char sys) const;
|
---|
[6841] | 69 | QStringList phaseShifts() const;
|
---|
| 70 | QStringList gloBiases() const;
|
---|
| 71 | QStringList gloSlots() const;
|
---|
[9945] | 72 | QStringList runByDate() const {return _runByDate;}
|
---|
[6119] | 73 | void write(QTextStream* stream, const QMap<QString, QString>* txtMap = 0) const;
|
---|
[6225] | 74 | bncTime startTime() const {return _startTime;}
|
---|
| 75 | void setStartTime(const bncTime& startTime) {_startTime = startTime;}
|
---|
[4480] | 76 |
|
---|
[6119] | 77 | private:
|
---|
[6225] | 78 | QStringList obsTypesStrings() const;
|
---|
[6719] | 79 | QString _usedSystems;
|
---|
| 80 | double _version;
|
---|
[10532] | 81 | int _configuredVersion;
|
---|
[6719] | 82 | double _interval;
|
---|
| 83 | QString _antennaNumber;
|
---|
| 84 | QString _antennaName;
|
---|
| 85 | QString _markerName;
|
---|
| 86 | QString _markerNumber;
|
---|
[9760] | 87 |
|
---|
[6941] | 88 | QString _markerType;
|
---|
[6719] | 89 | QString _observer;
|
---|
| 90 | QString _agency;
|
---|
| 91 | QString _receiverNumber;
|
---|
| 92 | QString _receiverType;
|
---|
| 93 | QString _receiverVersion;
|
---|
[9760] | 94 | QString _digitalObjectId;
|
---|
| 95 | QStringList _licenseOfUse;
|
---|
| 96 | QStringList _stationInformation;
|
---|
[6719] | 97 | QStringList _comments;
|
---|
[9945] | 98 | QStringList _runByDate;
|
---|
[6719] | 99 | ColumnVector _antNEU;
|
---|
| 100 | ColumnVector _antXYZ;
|
---|
| 101 | ColumnVector _antBSG;
|
---|
| 102 | ColumnVector _xyz;
|
---|
[6230] | 103 | QMap<char, QStringList> _obsTypes;
|
---|
[6719] | 104 | QMap<t_prn, int> _gloSlots;
|
---|
[6841] | 105 | QMap<QString, double> _gloBiases;
|
---|
[6230] | 106 | int _wlFactorsL1[t_prn::MAXPRN_GPS+1];
|
---|
| 107 | int _wlFactorsL2[t_prn::MAXPRN_GPS+1];
|
---|
| 108 | bncTime _startTime;
|
---|
[7665] | 109 | bool _writeRinexOnlyWithSklObsTypes;
|
---|
| 110 |
|
---|
[6815] | 111 | QMap<QString, QPair<double, QStringList> > _phaseShifts;
|
---|
[4480] | 112 | };
|
---|
| 113 |
|
---|
[3716] | 114 | class t_rnxObsFile {
|
---|
| 115 | public:
|
---|
| 116 |
|
---|
[3840] | 117 | static bool earlierStartTime(const t_rnxObsFile* file1, const t_rnxObsFile* file2) {
|
---|
| 118 | return file1->startTime() < file2->startTime();
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[6119] | 121 | class t_rnxObs {
|
---|
| 122 | public:
|
---|
[6226] | 123 | t_rnxObs() {
|
---|
| 124 | value = 0.0; lli = 0; snr = 0;
|
---|
| 125 | }
|
---|
[6119] | 126 | double value;
|
---|
| 127 | int lli;
|
---|
| 128 | int snr;
|
---|
| 129 | };
|
---|
| 130 |
|
---|
[3716] | 131 | class t_rnxSat {
|
---|
| 132 | public:
|
---|
[6119] | 133 | t_prn prn;
|
---|
| 134 | QMap<QString, t_rnxObs> obs;
|
---|
[8798] | 135 | static bool prnSort(const t_rnxSat rnxSat1, const t_rnxSat rnxSat2) {return rnxSat1.prn < rnxSat2.prn;}
|
---|
[3716] | 136 | };
|
---|
| 137 |
|
---|
| 138 | class t_rnxEpo {
|
---|
| 139 | public:
|
---|
[6126] | 140 | t_rnxEpo() {clear();}
|
---|
[3716] | 141 | void clear() {
|
---|
[6119] | 142 | tt.reset();
|
---|
[3716] | 143 | rnxSat.clear();
|
---|
| 144 | }
|
---|
| 145 | bncTime tt;
|
---|
| 146 | std::vector<t_rnxSat> rnxSat;
|
---|
| 147 | };
|
---|
| 148 |
|
---|
[3843] | 149 | enum e_inpOut {input, output};
|
---|
| 150 |
|
---|
| 151 | t_rnxObsFile(const QString& fileName, e_inpOut inpOut);
|
---|
[3716] | 152 | ~t_rnxObsFile();
|
---|
[7474] | 153 |
|
---|
[6225] | 154 | double version() const {return _header._version;}
|
---|
[6119] | 155 | double interval() const {return _header._interval;}
|
---|
| 156 | int numSys() const {return _header.numSys();}
|
---|
[6130] | 157 | char system(int iSys) const {return _header.system(iSys);}
|
---|
[6119] | 158 | int nTypes(char sys) const {return _header.nTypes(sys);}
|
---|
[6841] | 159 | int numGloBiases() const {return _header.numGloBiases();}
|
---|
| 160 | int numGloSlots() const {return _header.numGloSlots();}
|
---|
[6119] | 161 | const QString& fileName() const {return _fileName;}
|
---|
[6126] | 162 | QString obsType(char sys, int index, double version = 0.0) const {
|
---|
| 163 | return _header.obsType(sys, index, version);
|
---|
| 164 | }
|
---|
[6841] | 165 | QStringList phaseShifts() const {return _header.phaseShifts();}
|
---|
| 166 | QStringList gloBiases() const {return _header.gloBiases();}
|
---|
| 167 | QStringList gloSlots() const {return _header.gloSlots();}
|
---|
[9945] | 168 | QStringList runByDate() const {return _header.runByDate();}
|
---|
[6119] | 169 | const QString& antennaName() const {return _header._antennaName;}
|
---|
[6795] | 170 | const QString& antennaNumber() const {return _header._antennaNumber;}
|
---|
[6119] | 171 | const QString& markerName() const {return _header._markerName;}
|
---|
[6302] | 172 | const QString& markerNumber() const {return _header._markerNumber;}
|
---|
[6119] | 173 | const QString& receiverType() const {return _header._receiverType;}
|
---|
[6795] | 174 | const QString& receiverNumber() const {return _header._receiverNumber;}
|
---|
[9760] | 175 | const QString& digitalObjectId() const {return _header._digitalObjectId;}
|
---|
| 176 | const QStringList licenseOfUse() const {return _header._licenseOfUse;}
|
---|
| 177 | const QStringList stationInformation() const {return _header._stationInformation;}
|
---|
[3984] | 178 |
|
---|
[4112] | 179 | void setInterval(double interval) {_header._interval = interval;}
|
---|
[3984] | 180 | void setAntennaName(const QString& antennaName) {_header._antennaName = antennaName;}
|
---|
[6795] | 181 | void setAntennaNumber(const QString& antennaNumber) {_header._antennaNumber = antennaNumber;}
|
---|
| 182 | void setAntennaN(double antN) {_header._antNEU(1) = antN;}
|
---|
| 183 | void setAntennaE(double antE) {_header._antNEU(2) = antE;}
|
---|
| 184 | void setAntennaU(double antU) {_header._antNEU(3) = antU;}
|
---|
| 185 |
|
---|
[3984] | 186 | void setMarkerName(const QString& markerName) {_header._markerName = markerName;}
|
---|
| 187 | void setReceiverType(const QString& receiverType) {_header._receiverType = receiverType;}
|
---|
[6795] | 188 | void setReceiverNumber(const QString& receiverNumber) {_header._receiverNumber = receiverNumber;}
|
---|
[3984] | 189 |
|
---|
[9760] | 190 | void setDigitalObjectId(const QString& digitalObjectId) {_header._digitalObjectId = digitalObjectId;}
|
---|
| 191 | void setLicenseOfUse(const QString& licenseOfUse) {_header._licenseOfUse.append(licenseOfUse);}
|
---|
| 192 | void setStationInformation(const QString& stationInformation) {_header._stationInformation.append(stationInformation);}
|
---|
| 193 |
|
---|
[3716] | 194 | const ColumnVector& xyz() const {return _header._xyz;}
|
---|
| 195 | const ColumnVector& antNEU() const {return _header._antNEU;}
|
---|
| 196 | const ColumnVector& antXYZ() const {return _header._antXYZ;}
|
---|
| 197 | const ColumnVector& antBSG() const {return _header._antBSG;}
|
---|
[3991] | 198 |
|
---|
[9945] | 199 | const bncTime& startTime() const {return _header._startTime;}
|
---|
[3991] | 200 | void setStartTime(const bncTime& startTime) {_header._startTime = startTime;}
|
---|
| 201 |
|
---|
[7474] | 202 | t_rnxEpo* nextEpoch();
|
---|
[6222] | 203 |
|
---|
[3716] | 204 | int wlFactorL1(unsigned iPrn) {
|
---|
[5742] | 205 | return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL1[iPrn] : 1;
|
---|
[3716] | 206 | }
|
---|
| 207 | int wlFactorL2(unsigned iPrn) {
|
---|
[5742] | 208 | return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL2[iPrn] : 1;
|
---|
[3716] | 209 | }
|
---|
| 210 |
|
---|
[3844] | 211 | const t_rnxObsHeader& header() const {return _header;}
|
---|
[6222] | 212 |
|
---|
[6841] | 213 | void setHeader(const t_rnxObsHeader& header, int version,
|
---|
| 214 | const QStringList* useObsTypes = 0, const QStringList* phaseShifts = 0,
|
---|
[9945] | 215 | const QStringList* gloBiases = 0, const QStringList* gloSlots = 0, const QStringList* runByDate = 0) {
|
---|
| 216 | _header.set(header, version, useObsTypes, phaseShifts, gloBiases, gloSlots, runByDate);
|
---|
[6222] | 217 | }
|
---|
| 218 |
|
---|
[3845] | 219 | void writeEpoch(const t_rnxEpo* epo);
|
---|
[3844] | 220 |
|
---|
[4481] | 221 | QTextStream* stream() {return _stream;}
|
---|
| 222 |
|
---|
[7474] | 223 | static void setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo,
|
---|
[6222] | 224 | const t_rnxObsFile::t_rnxSat& rnxSat, t_satObs& obs);
|
---|
[5883] | 225 |
|
---|
[6192] | 226 | static QString type2to3(char sys, const QString& typeV2);
|
---|
| 227 | static QString type3to2(char sys, const QString& typeV3);
|
---|
[7980] | 228 | static QStringList signalPriorities(char sys);
|
---|
[5932] | 229 |
|
---|
[6225] | 230 | static void writeEpoch(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo) {
|
---|
[7817] | 231 | if (epo == 0) {
|
---|
| 232 | return;
|
---|
| 233 | }
|
---|
| 234 | t_rnxEpo epoLocal;
|
---|
| 235 | epoLocal.tt = epo->tt;
|
---|
| 236 | for (unsigned ii = 0; ii < epo->rnxSat.size(); ii++) {
|
---|
| 237 | const t_rnxSat& rnxSat = epo->rnxSat[ii];
|
---|
| 238 | if (header._obsTypes[rnxSat.prn.system()].size() > 0) {
|
---|
[8294] | 239 | if (header.version() < 3.0) { // exclude new GNSS such as BDS, QZSS, IRNSS, etc.
|
---|
| 240 | if (rnxSat.prn.system() != 'G' && rnxSat.prn.system() != 'R' &&
|
---|
[10085] | 241 | rnxSat.prn.system() != 'E' && rnxSat.prn.system() != 'S' ) {
|
---|
[8294] | 242 | continue;
|
---|
| 243 | }
|
---|
| 244 | }
|
---|
[7817] | 245 | epoLocal.rnxSat.push_back(rnxSat);
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
[8798] | 248 | std::stable_sort(epoLocal.rnxSat.begin(), epoLocal.rnxSat.end(), t_rnxSat::prnSort);
|
---|
| 249 |
|
---|
[6225] | 250 | if (header.version() >= 3.0) {
|
---|
[7817] | 251 | writeEpochV3(stream, header, &epoLocal);
|
---|
[6225] | 252 | }
|
---|
| 253 | else {
|
---|
[7817] | 254 | writeEpochV2(stream, header, &epoLocal);
|
---|
[6225] | 255 | }
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | private:
|
---|
[6222] | 259 | static void writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
|
---|
| 260 | static void writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
|
---|
[4480] | 261 | t_rnxObsFile() {};
|
---|
| 262 | void openRead(const QString& fileName);
|
---|
| 263 | void openWrite(const QString& fileName);
|
---|
| 264 | void close();
|
---|
[3994] | 265 | t_rnxEpo* nextEpochV2();
|
---|
| 266 | t_rnxEpo* nextEpochV3();
|
---|
[4540] | 267 | void handleEpochFlag(int flag, const QString& line, bool& headerReRead);
|
---|
[3960] | 268 |
|
---|
[3843] | 269 | e_inpOut _inpOut;
|
---|
[3718] | 270 | QFile* _file;
|
---|
[3717] | 271 | QString _fileName;
|
---|
[3718] | 272 | QTextStream* _stream;
|
---|
[3716] | 273 | t_rnxObsHeader _header;
|
---|
| 274 | t_rnxEpo _currEpo;
|
---|
| 275 | bool _flgPowerFail;
|
---|
| 276 | };
|
---|
| 277 |
|
---|
| 278 | #endif
|
---|