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