[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 |
|
---|
[4480] | 40 | class t_rnxObsHeader {
|
---|
[6119] | 41 |
|
---|
| 42 | friend class t_rnxObsFile;
|
---|
| 43 |
|
---|
[4480] | 44 | public:
|
---|
[8280] | 45 | static constexpr double defaultRnxObsVersion2 = 2.11;
|
---|
| 46 | static constexpr double defaultRnxObsVersion3 = 3.03;
|
---|
[5375] | 47 |
|
---|
[4480] | 48 | t_rnxObsHeader();
|
---|
| 49 | ~t_rnxObsHeader();
|
---|
| 50 |
|
---|
[6225] | 51 | double version() const {return _version;}
|
---|
[6119] | 52 | t_irc read(QTextStream* stream, int maxLines = 0);
|
---|
[6222] | 53 | void setDefault(const QString& markerName, int version);
|
---|
[6841] | 54 | void set(const t_rnxObsHeader& header, int version,
|
---|
| 55 | const QStringList* useObsTypes = 0, const QStringList* phaseShifts = 0,
|
---|
| 56 | const QStringList* gloBiases = 0, const QStringList* gloSlots = 0);
|
---|
[6119] | 57 | int numSys() const;
|
---|
[6130] | 58 | char system(int iSys) const;
|
---|
[6119] | 59 | int nTypes(char sys) const;
|
---|
[6841] | 60 | int numGloBiases() const;
|
---|
| 61 | int numGloSlots() const;
|
---|
[6126] | 62 | QString obsType(char sys, int index, double version = 0.0) const;
|
---|
[7474] | 63 | QString usedSystems() const;
|
---|
| 64 | QStringList obsTypes(char sys) const;
|
---|
[6841] | 65 | QStringList phaseShifts() const;
|
---|
| 66 | QStringList gloBiases() const;
|
---|
| 67 | QStringList gloSlots() const;
|
---|
[6119] | 68 | void write(QTextStream* stream, const QMap<QString, QString>* txtMap = 0) const;
|
---|
[6225] | 69 | bncTime startTime() const {return _startTime;}
|
---|
| 70 | void setStartTime(const bncTime& startTime) {_startTime = startTime;}
|
---|
[4480] | 71 |
|
---|
[6119] | 72 | private:
|
---|
[6225] | 73 | QStringList obsTypesStrings() const;
|
---|
[6719] | 74 | QString _usedSystems;
|
---|
| 75 | double _version;
|
---|
| 76 | double _interval;
|
---|
| 77 | QString _antennaNumber;
|
---|
| 78 | QString _antennaName;
|
---|
| 79 | QString _markerName;
|
---|
| 80 | QString _markerNumber;
|
---|
[6941] | 81 | QString _markerType;
|
---|
[6719] | 82 | QString _observer;
|
---|
| 83 | QString _agency;
|
---|
| 84 | QString _receiverNumber;
|
---|
| 85 | QString _receiverType;
|
---|
| 86 | QString _receiverVersion;
|
---|
| 87 | QStringList _comments;
|
---|
| 88 | ColumnVector _antNEU;
|
---|
| 89 | ColumnVector _antXYZ;
|
---|
| 90 | ColumnVector _antBSG;
|
---|
| 91 | ColumnVector _xyz;
|
---|
[6230] | 92 | QMap<char, QStringList> _obsTypes;
|
---|
[6719] | 93 | QMap<t_prn, int> _gloSlots;
|
---|
[6841] | 94 | QMap<QString, double> _gloBiases;
|
---|
[6230] | 95 | int _wlFactorsL1[t_prn::MAXPRN_GPS+1];
|
---|
| 96 | int _wlFactorsL2[t_prn::MAXPRN_GPS+1];
|
---|
| 97 | bncTime _startTime;
|
---|
[7665] | 98 | bool _writeRinexOnlyWithSklObsTypes;
|
---|
| 99 |
|
---|
[6815] | 100 | QMap<QString, QPair<double, QStringList> > _phaseShifts;
|
---|
[4480] | 101 | };
|
---|
| 102 |
|
---|
[3716] | 103 | class t_rnxObsFile {
|
---|
| 104 | public:
|
---|
| 105 |
|
---|
[3840] | 106 | static bool earlierStartTime(const t_rnxObsFile* file1, const t_rnxObsFile* file2) {
|
---|
| 107 | return file1->startTime() < file2->startTime();
|
---|
| 108 | }
|
---|
| 109 |
|
---|
[6119] | 110 | class t_rnxObs {
|
---|
| 111 | public:
|
---|
[6226] | 112 | t_rnxObs() {
|
---|
| 113 | value = 0.0; lli = 0; snr = 0;
|
---|
| 114 | }
|
---|
[6119] | 115 | double value;
|
---|
| 116 | int lli;
|
---|
| 117 | int snr;
|
---|
| 118 | };
|
---|
| 119 |
|
---|
[3716] | 120 | class t_rnxSat {
|
---|
| 121 | public:
|
---|
[6119] | 122 | t_prn prn;
|
---|
| 123 | QMap<QString, t_rnxObs> obs;
|
---|
[3716] | 124 | };
|
---|
| 125 |
|
---|
| 126 | class t_rnxEpo {
|
---|
| 127 | public:
|
---|
[6126] | 128 | t_rnxEpo() {clear();}
|
---|
[3716] | 129 | void clear() {
|
---|
[6119] | 130 | tt.reset();
|
---|
[3716] | 131 | rnxSat.clear();
|
---|
| 132 | }
|
---|
| 133 | bncTime tt;
|
---|
| 134 | std::vector<t_rnxSat> rnxSat;
|
---|
| 135 | };
|
---|
| 136 |
|
---|
[3843] | 137 | enum e_inpOut {input, output};
|
---|
| 138 |
|
---|
| 139 | t_rnxObsFile(const QString& fileName, e_inpOut inpOut);
|
---|
[3716] | 140 | ~t_rnxObsFile();
|
---|
[7474] | 141 |
|
---|
[6225] | 142 | double version() const {return _header._version;}
|
---|
[6119] | 143 | double interval() const {return _header._interval;}
|
---|
| 144 | int numSys() const {return _header.numSys();}
|
---|
[6130] | 145 | char system(int iSys) const {return _header.system(iSys);}
|
---|
[6119] | 146 | int nTypes(char sys) const {return _header.nTypes(sys);}
|
---|
[6841] | 147 | int numGloBiases() const {return _header.numGloBiases();}
|
---|
| 148 | int numGloSlots() const {return _header.numGloSlots();}
|
---|
[6119] | 149 | const QString& fileName() const {return _fileName;}
|
---|
[6126] | 150 | QString obsType(char sys, int index, double version = 0.0) const {
|
---|
| 151 | return _header.obsType(sys, index, version);
|
---|
| 152 | }
|
---|
[6841] | 153 | QStringList phaseShifts() const {return _header.phaseShifts();}
|
---|
| 154 | QStringList gloBiases() const {return _header.gloBiases();}
|
---|
| 155 | QStringList gloSlots() const {return _header.gloSlots();}
|
---|
[6119] | 156 | const QString& antennaName() const {return _header._antennaName;}
|
---|
[6795] | 157 | const QString& antennaNumber() const {return _header._antennaNumber;}
|
---|
[6119] | 158 | const QString& markerName() const {return _header._markerName;}
|
---|
[6302] | 159 | const QString& markerNumber() const {return _header._markerNumber;}
|
---|
[6119] | 160 | const QString& receiverType() const {return _header._receiverType;}
|
---|
[6795] | 161 | const QString& receiverNumber() const {return _header._receiverNumber;}
|
---|
[3984] | 162 |
|
---|
[4112] | 163 | void setInterval(double interval) {_header._interval = interval;}
|
---|
[3984] | 164 | void setAntennaName(const QString& antennaName) {_header._antennaName = antennaName;}
|
---|
[6795] | 165 | void setAntennaNumber(const QString& antennaNumber) {_header._antennaNumber = antennaNumber;}
|
---|
| 166 | void setAntennaN(double antN) {_header._antNEU(1) = antN;}
|
---|
| 167 | void setAntennaE(double antE) {_header._antNEU(2) = antE;}
|
---|
| 168 | void setAntennaU(double antU) {_header._antNEU(3) = antU;}
|
---|
| 169 |
|
---|
[3984] | 170 | void setMarkerName(const QString& markerName) {_header._markerName = markerName;}
|
---|
| 171 | void setReceiverType(const QString& receiverType) {_header._receiverType = receiverType;}
|
---|
[6795] | 172 | void setReceiverNumber(const QString& receiverNumber) {_header._receiverNumber = receiverNumber;}
|
---|
[3984] | 173 |
|
---|
[3716] | 174 | const ColumnVector& xyz() const {return _header._xyz;}
|
---|
| 175 | const ColumnVector& antNEU() const {return _header._antNEU;}
|
---|
| 176 | const ColumnVector& antXYZ() const {return _header._antXYZ;}
|
---|
| 177 | const ColumnVector& antBSG() const {return _header._antBSG;}
|
---|
[3991] | 178 |
|
---|
[3838] | 179 | const bncTime& startTime() const {return _header._startTime;}
|
---|
[3991] | 180 | void setStartTime(const bncTime& startTime) {_header._startTime = startTime;}
|
---|
| 181 |
|
---|
[7474] | 182 | t_rnxEpo* nextEpoch();
|
---|
[6222] | 183 |
|
---|
[3716] | 184 | int wlFactorL1(unsigned iPrn) {
|
---|
[5742] | 185 | return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL1[iPrn] : 1;
|
---|
[3716] | 186 | }
|
---|
| 187 | int wlFactorL2(unsigned iPrn) {
|
---|
[5742] | 188 | return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL2[iPrn] : 1;
|
---|
[3716] | 189 | }
|
---|
| 190 |
|
---|
[3844] | 191 | const t_rnxObsHeader& header() const {return _header;}
|
---|
[6222] | 192 |
|
---|
[6841] | 193 | void setHeader(const t_rnxObsHeader& header, int version,
|
---|
| 194 | const QStringList* useObsTypes = 0, const QStringList* phaseShifts = 0,
|
---|
| 195 | const QStringList* gloBiases = 0, const QStringList* gloSlots = 0) {
|
---|
| 196 | _header.set(header, version, useObsTypes, phaseShifts, gloBiases, gloSlots);
|
---|
[6222] | 197 | }
|
---|
| 198 |
|
---|
[3845] | 199 | void writeEpoch(const t_rnxEpo* epo);
|
---|
[3844] | 200 |
|
---|
[4481] | 201 | QTextStream* stream() {return _stream;}
|
---|
| 202 |
|
---|
[7474] | 203 | static void setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo,
|
---|
[6222] | 204 | const t_rnxObsFile::t_rnxSat& rnxSat, t_satObs& obs);
|
---|
[5883] | 205 |
|
---|
[6192] | 206 | static QString type2to3(char sys, const QString& typeV2);
|
---|
| 207 | static QString type3to2(char sys, const QString& typeV3);
|
---|
[7983] | 208 | static QStringList signalPriorities(char sys);
|
---|
[5932] | 209 |
|
---|
[6225] | 210 | static void writeEpoch(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo) {
|
---|
[7817] | 211 | if (epo == 0) {
|
---|
| 212 | return;
|
---|
| 213 | }
|
---|
| 214 | t_rnxEpo epoLocal;
|
---|
| 215 | epoLocal.tt = epo->tt;
|
---|
| 216 | for (unsigned ii = 0; ii < epo->rnxSat.size(); ii++) {
|
---|
| 217 | const t_rnxSat& rnxSat = epo->rnxSat[ii];
|
---|
| 218 | if (header._obsTypes[rnxSat.prn.system()].size() > 0) {
|
---|
| 219 | epoLocal.rnxSat.push_back(rnxSat);
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
[6225] | 222 | if (header.version() >= 3.0) {
|
---|
[7817] | 223 | writeEpochV3(stream, header, &epoLocal);
|
---|
[6225] | 224 | }
|
---|
| 225 | else {
|
---|
[7817] | 226 | writeEpochV2(stream, header, &epoLocal);
|
---|
[6225] | 227 | }
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | private:
|
---|
[6222] | 231 | static void writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
|
---|
| 232 | static void writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
|
---|
[4480] | 233 | t_rnxObsFile() {};
|
---|
| 234 | void openRead(const QString& fileName);
|
---|
| 235 | void openWrite(const QString& fileName);
|
---|
| 236 | void close();
|
---|
[3994] | 237 | t_rnxEpo* nextEpochV2();
|
---|
| 238 | t_rnxEpo* nextEpochV3();
|
---|
[4540] | 239 | void handleEpochFlag(int flag, const QString& line, bool& headerReRead);
|
---|
[3960] | 240 |
|
---|
[3843] | 241 | e_inpOut _inpOut;
|
---|
[3718] | 242 | QFile* _file;
|
---|
[3717] | 243 | QString _fileName;
|
---|
[3718] | 244 | QTextStream* _stream;
|
---|
[3716] | 245 | t_rnxObsHeader _header;
|
---|
| 246 | t_rnxEpo _currEpo;
|
---|
| 247 | bool _flgPowerFail;
|
---|
| 248 | };
|
---|
| 249 |
|
---|
| 250 | #endif
|
---|