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

Last change on this file since 9765 was 9760, checked in by stuerze, 2 years ago

initial changes to consider RINEX Version 4 in future

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