source: ntrip/trunk/BNC/src/rinex/rnxobsfile.h@ 9945

Last change on this file since 9945 was 9945, checked in by stuerze, 17 months ago

multiple 'run by date' entries for rinex version 4 added

File size: 10.1 KB
RevLine 
[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
[9760]42#define defaultRnxObsVersion4 4.00
[8127]43
[4480]44class 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;
81 double _interval;
82 QString _antennaNumber;
83 QString _antennaName;
84 QString _markerName;
85 QString _markerNumber;
[9760]86
[6941]87 QString _markerType;
[6719]88 QString _observer;
89 QString _agency;
90 QString _receiverNumber;
91 QString _receiverType;
92 QString _receiverVersion;
[9760]93 QString _digitalObjectId;
94 QStringList _licenseOfUse;
95 QStringList _stationInformation;
[6719]96 QStringList _comments;
[9945]97 QStringList _runByDate;
[6719]98 ColumnVector _antNEU;
99 ColumnVector _antXYZ;
100 ColumnVector _antBSG;
101 ColumnVector _xyz;
[6230]102 QMap<char, QStringList> _obsTypes;
[6719]103 QMap<t_prn, int> _gloSlots;
[6841]104 QMap<QString, double> _gloBiases;
[6230]105 int _wlFactorsL1[t_prn::MAXPRN_GPS+1];
106 int _wlFactorsL2[t_prn::MAXPRN_GPS+1];
107 bncTime _startTime;
[7665]108 bool _writeRinexOnlyWithSklObsTypes;
109
[6815]110 QMap<QString, QPair<double, QStringList> > _phaseShifts;
[4480]111};
112
[3716]113class t_rnxObsFile {
114 public:
115
[3840]116 static bool earlierStartTime(const t_rnxObsFile* file1, const t_rnxObsFile* file2) {
117 return file1->startTime() < file2->startTime();
118 }
119
[6119]120 class t_rnxObs {
121 public:
[6226]122 t_rnxObs() {
123 value = 0.0; lli = 0; snr = 0;
124 }
[6119]125 double value;
126 int lli;
127 int snr;
128 };
129
[3716]130 class t_rnxSat {
131 public:
[6119]132 t_prn prn;
133 QMap<QString, t_rnxObs> obs;
[8798]134 static bool prnSort(const t_rnxSat rnxSat1, const t_rnxSat rnxSat2) {return rnxSat1.prn < rnxSat2.prn;}
[3716]135 };
136
137 class t_rnxEpo {
138 public:
[6126]139 t_rnxEpo() {clear();}
[3716]140 void clear() {
[6119]141 tt.reset();
[3716]142 rnxSat.clear();
143 }
144 bncTime tt;
145 std::vector<t_rnxSat> rnxSat;
146 };
147
[3843]148 enum e_inpOut {input, output};
149
150 t_rnxObsFile(const QString& fileName, e_inpOut inpOut);
[3716]151 ~t_rnxObsFile();
[7474]152
[6225]153 double version() const {return _header._version;}
[6119]154 double interval() const {return _header._interval;}
155 int numSys() const {return _header.numSys();}
[6130]156 char system(int iSys) const {return _header.system(iSys);}
[6119]157 int nTypes(char sys) const {return _header.nTypes(sys);}
[6841]158 int numGloBiases() const {return _header.numGloBiases();}
159 int numGloSlots() const {return _header.numGloSlots();}
[6119]160 const QString& fileName() const {return _fileName;}
[6126]161 QString obsType(char sys, int index, double version = 0.0) const {
162 return _header.obsType(sys, index, version);
163 }
[6841]164 QStringList phaseShifts() const {return _header.phaseShifts();}
165 QStringList gloBiases() const {return _header.gloBiases();}
166 QStringList gloSlots() const {return _header.gloSlots();}
[9945]167 QStringList runByDate() const {return _header.runByDate();}
[6119]168 const QString& antennaName() const {return _header._antennaName;}
[6795]169 const QString& antennaNumber() const {return _header._antennaNumber;}
[6119]170 const QString& markerName() const {return _header._markerName;}
[6302]171 const QString& markerNumber() const {return _header._markerNumber;}
[6119]172 const QString& receiverType() const {return _header._receiverType;}
[6795]173 const QString& receiverNumber() const {return _header._receiverNumber;}
[9760]174 const QString& digitalObjectId() const {return _header._digitalObjectId;}
175 const QStringList licenseOfUse() const {return _header._licenseOfUse;}
176 const QStringList stationInformation() const {return _header._stationInformation;}
[3984]177
[4112]178 void setInterval(double interval) {_header._interval = interval;}
[3984]179 void setAntennaName(const QString& antennaName) {_header._antennaName = antennaName;}
[6795]180 void setAntennaNumber(const QString& antennaNumber) {_header._antennaNumber = antennaNumber;}
181 void setAntennaN(double antN) {_header._antNEU(1) = antN;}
182 void setAntennaE(double antE) {_header._antNEU(2) = antE;}
183 void setAntennaU(double antU) {_header._antNEU(3) = antU;}
184
[3984]185 void setMarkerName(const QString& markerName) {_header._markerName = markerName;}
186 void setReceiverType(const QString& receiverType) {_header._receiverType = receiverType;}
[6795]187 void setReceiverNumber(const QString& receiverNumber) {_header._receiverNumber = receiverNumber;}
[3984]188
[9760]189 void setDigitalObjectId(const QString& digitalObjectId) {_header._digitalObjectId = digitalObjectId;}
190 void setLicenseOfUse(const QString& licenseOfUse) {_header._licenseOfUse.append(licenseOfUse);}
191 void setStationInformation(const QString& stationInformation) {_header._stationInformation.append(stationInformation);}
192
[3716]193 const ColumnVector& xyz() const {return _header._xyz;}
194 const ColumnVector& antNEU() const {return _header._antNEU;}
195 const ColumnVector& antXYZ() const {return _header._antXYZ;}
196 const ColumnVector& antBSG() const {return _header._antBSG;}
[3991]197
[9945]198 const bncTime& startTime() const {return _header._startTime;}
[3991]199 void setStartTime(const bncTime& startTime) {_header._startTime = startTime;}
200
[7474]201 t_rnxEpo* nextEpoch();
[6222]202
[3716]203 int wlFactorL1(unsigned iPrn) {
[5742]204 return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL1[iPrn] : 1;
[3716]205 }
206 int wlFactorL2(unsigned iPrn) {
[5742]207 return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL2[iPrn] : 1;
[3716]208 }
209
[3844]210 const t_rnxObsHeader& header() const {return _header;}
[6222]211
[6841]212 void setHeader(const t_rnxObsHeader& header, int version,
213 const QStringList* useObsTypes = 0, const QStringList* phaseShifts = 0,
[9945]214 const QStringList* gloBiases = 0, const QStringList* gloSlots = 0, const QStringList* runByDate = 0) {
215 _header.set(header, version, useObsTypes, phaseShifts, gloBiases, gloSlots, runByDate);
[6222]216 }
217
[3845]218 void writeEpoch(const t_rnxEpo* epo);
[3844]219
[4481]220 QTextStream* stream() {return _stream;}
221
[7474]222 static void setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo,
[6222]223 const t_rnxObsFile::t_rnxSat& rnxSat, t_satObs& obs);
[5883]224
[6192]225 static QString type2to3(char sys, const QString& typeV2);
226 static QString type3to2(char sys, const QString& typeV3);
[7980]227 static QStringList signalPriorities(char sys);
[5932]228
[6225]229 static void writeEpoch(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo) {
[7817]230 if (epo == 0) {
231 return;
232 }
233 t_rnxEpo epoLocal;
234 epoLocal.tt = epo->tt;
235 for (unsigned ii = 0; ii < epo->rnxSat.size(); ii++) {
236 const t_rnxSat& rnxSat = epo->rnxSat[ii];
237 if (header._obsTypes[rnxSat.prn.system()].size() > 0) {
[8294]238 if (header.version() < 3.0) { // exclude new GNSS such as BDS, QZSS, IRNSS, etc.
239 if (rnxSat.prn.system() != 'G' && rnxSat.prn.system() != 'R' &&
[8798]240 rnxSat.prn.system() != 'E' && rnxSat.prn.system() != 'S' &&
241 rnxSat.prn.system() != 'I') {
[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
Note: See TracBrowser for help on using the repository browser.