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

Last change on this file since 8110 was 7980, checked in by stuerze, 10 years ago

System and frequency specific signal priorities are added for RINEX3 to RINEX2 conversion and the default 'Signal priority' list is improved

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