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