[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 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: t_rnxObsFile
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Reads RINEX Observation File
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 24-Jan-2012
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
| 42 | #include <iomanip>
|
---|
| 43 | #include <sstream>
|
---|
[3722] | 44 | #include "rnxobsfile.h"
|
---|
[3716] | 45 | #include "bncutils.h"
|
---|
[5070] | 46 | #include "bnccore.h"
|
---|
[3716] | 47 |
|
---|
| 48 | using namespace std;
|
---|
| 49 |
|
---|
[4480] | 50 | const QString t_rnxObsHeader::_emptyStr;
|
---|
[3716] | 51 |
|
---|
| 52 | // Constructor
|
---|
| 53 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4480] | 54 | t_rnxObsHeader::t_rnxObsHeader() {
|
---|
[3716] | 55 | _antNEU.ReSize(3); _antNEU = 0.0;
|
---|
| 56 | _antXYZ.ReSize(3); _antXYZ = 0.0;
|
---|
| 57 | _antBSG.ReSize(3); _antBSG = 0.0;
|
---|
| 58 | _xyz.ReSize(3); _xyz = 0.0;
|
---|
| 59 | _version = 0.0;
|
---|
| 60 | _interval = 0.0;
|
---|
[5742] | 61 | for (unsigned iPrn = 1; iPrn <= t_prn::MAXPRN_GPS; iPrn++) {
|
---|
[3716] | 62 | _wlFactorsL1[iPrn] = 1;
|
---|
| 63 | _wlFactorsL2[iPrn] = 1;
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | // Destructor
|
---|
| 68 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4480] | 69 | t_rnxObsHeader::~t_rnxObsHeader() {
|
---|
[3716] | 70 | }
|
---|
| 71 |
|
---|
| 72 | // Read Header
|
---|
| 73 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4480] | 74 | t_irc t_rnxObsHeader::read(QTextStream* stream, int maxLines) {
|
---|
[4534] | 75 | _comments.clear();
|
---|
[3716] | 76 | int numLines = 0;
|
---|
[3718] | 77 | while ( stream->status() == QTextStream::Ok && !stream->atEnd() ) {
|
---|
| 78 | QString line = stream->readLine(); ++ numLines;
|
---|
| 79 | if (line.isEmpty()) {
|
---|
[3716] | 80 | continue;
|
---|
| 81 | }
|
---|
[3718] | 82 | if (line.indexOf("END OF FILE") != -1) {
|
---|
[3716] | 83 | break;
|
---|
| 84 | }
|
---|
[3718] | 85 | QString value = line.mid(0,60).trimmed();
|
---|
| 86 | QString key = line.mid(60).trimmed();
|
---|
[3716] | 87 | if (key == "END OF HEADER") {
|
---|
| 88 | break;
|
---|
| 89 | }
|
---|
| 90 | else if (key == "RINEX VERSION / TYPE") {
|
---|
[3718] | 91 | QTextStream in(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 92 | in >> _version;
|
---|
| 93 | }
|
---|
| 94 | else if (key == "MARKER NAME") {
|
---|
| 95 | _markerName = value;
|
---|
| 96 | }
|
---|
[3930] | 97 | else if (key == "MARKER NUMBER") {
|
---|
| 98 | _markerNumber = line.mid(0,20).trimmed();
|
---|
| 99 | }
|
---|
[3716] | 100 | else if (key == "ANT # / TYPE") {
|
---|
[3930] | 101 | _antennaNumber = line.mid( 0,20).trimmed();
|
---|
| 102 | _antennaName = line.mid(20,20).trimmed();
|
---|
[3716] | 103 | }
|
---|
[3930] | 104 | else if (key == "OBSERVER / AGENCY") {
|
---|
| 105 | _observer = line.mid( 0,20).trimmed();
|
---|
| 106 | _agency = line.mid(20,40).trimmed();
|
---|
| 107 | }
|
---|
| 108 | else if (key == "REC # / TYPE / VERS") {
|
---|
| 109 | _receiverNumber = line.mid( 0,20).trimmed();
|
---|
| 110 | _receiverType = line.mid(20,20).trimmed();
|
---|
| 111 | _receiverVersion = line.mid(40,20).trimmed();
|
---|
| 112 | }
|
---|
[3716] | 113 | else if (key == "INTERVAL") {
|
---|
[3718] | 114 | QTextStream in(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 115 | in >> _interval;
|
---|
| 116 | }
|
---|
[4494] | 117 | else if (key == "COMMENT") {
|
---|
| 118 | _comments << line.mid(0,60).trimmed();
|
---|
| 119 | }
|
---|
[3716] | 120 | else if (key == "WAVELENGTH FACT L1/2") {
|
---|
[3718] | 121 | QTextStream in(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 122 | int wlFactL1 = 0;
|
---|
| 123 | int wlFactL2 = 0;
|
---|
| 124 | int numSat = 0;
|
---|
| 125 | in >> wlFactL1 >> wlFactL2 >> numSat;
|
---|
| 126 | if (numSat == 0) {
|
---|
[5742] | 127 | for (unsigned iPrn = 1; iPrn <= t_prn::MAXPRN_GPS; iPrn++) {
|
---|
[3716] | 128 | _wlFactorsL1[iPrn] = wlFactL1;
|
---|
| 129 | _wlFactorsL2[iPrn] = wlFactL2;
|
---|
| 130 | }
|
---|
| 131 | }
|
---|
| 132 | else {
|
---|
| 133 | for (int ii = 0; ii < numSat; ii++) {
|
---|
[3718] | 134 | QString prn; in >> prn;
|
---|
[3716] | 135 | if (prn[0] == 'G') {
|
---|
| 136 | int iPrn;
|
---|
| 137 | readInt(prn, 1, 2, iPrn);
|
---|
| 138 | _wlFactorsL1[iPrn] = wlFactL1;
|
---|
| 139 | _wlFactorsL2[iPrn] = wlFactL2;
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 | }
|
---|
| 143 | }
|
---|
| 144 | else if (key == "APPROX POSITION XYZ") {
|
---|
[3718] | 145 | QTextStream in(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 146 | in >> _xyz[0] >> _xyz[1] >> _xyz[2];
|
---|
| 147 | }
|
---|
| 148 | else if (key == "ANTENNA: DELTA H/E/N") {
|
---|
[3718] | 149 | QTextStream in(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 150 | in >> _antNEU[2] >> _antNEU[1] >> _antNEU[0];
|
---|
| 151 | }
|
---|
| 152 | else if (key == "ANTENNA: DELTA X/Y/Z") {
|
---|
[3718] | 153 | QTextStream in(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 154 | in >> _antXYZ[0] >> _antXYZ[1] >> _antXYZ[2];
|
---|
| 155 | }
|
---|
| 156 | else if (key == "ANTENNA: B.SIGHT XYZ") {
|
---|
[3718] | 157 | QTextStream in(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 158 | in >> _antBSG[0] >> _antBSG[1] >> _antBSG[2];
|
---|
| 159 | }
|
---|
| 160 | else if (key == "# / TYPES OF OBSERV") {
|
---|
[3864] | 161 | QTextStream* in = new QTextStream(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 162 | int nTypes;
|
---|
[3864] | 163 | *in >> nTypes;
|
---|
[3716] | 164 | _obsTypesV2.clear();
|
---|
| 165 | for (int ii = 0; ii < nTypes; ii++) {
|
---|
[3864] | 166 | if (ii > 0 && ii % 9 == 0) {
|
---|
| 167 | line = stream->readLine(); ++numLines;
|
---|
| 168 | delete in;
|
---|
[4152] | 169 | in = new QTextStream(line.left(60).toAscii(), QIODevice::ReadOnly);
|
---|
[3864] | 170 | }
|
---|
[3718] | 171 | QString hlp;
|
---|
[3864] | 172 | *in >> hlp;
|
---|
[4053] | 173 | _obsTypesV2.append(hlp);
|
---|
[3716] | 174 | }
|
---|
| 175 | }
|
---|
| 176 | else if (key == "SYS / # / OBS TYPES") {
|
---|
[3718] | 177 | QTextStream* in = new QTextStream(value.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 178 | char sys;
|
---|
| 179 | int nTypes;
|
---|
| 180 | *in >> sys >> nTypes;
|
---|
| 181 | _obsTypesV3[sys].clear();
|
---|
| 182 | for (int ii = 0; ii < nTypes; ii++) {
|
---|
| 183 | if (ii > 0 && ii % 13 == 0) {
|
---|
[3718] | 184 | line = stream->readLine(); ++numLines;
|
---|
[3716] | 185 | delete in;
|
---|
[3718] | 186 | in = new QTextStream(line.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 187 | }
|
---|
[3718] | 188 | QString hlp;
|
---|
[3716] | 189 | *in >> hlp;
|
---|
| 190 | _obsTypesV3[sys].push_back(hlp);
|
---|
| 191 | }
|
---|
| 192 | delete in;
|
---|
| 193 | }
|
---|
[3837] | 194 | else if (key == "TIME OF FIRST OBS") {
|
---|
| 195 | QTextStream in(value.toAscii(), QIODevice::ReadOnly);
|
---|
| 196 | int year, month, day, hour, min;
|
---|
| 197 | double sec;
|
---|
| 198 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
| 199 | _startTime.set(year, month, day, hour, min, sec);
|
---|
| 200 | }
|
---|
[3716] | 201 | if (maxLines > 0 && numLines == maxLines) {
|
---|
| 202 | break;
|
---|
| 203 | }
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 | return success;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
[4481] | 209 | // Write Header
|
---|
| 210 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 211 | void t_rnxObsHeader::write(QTextStream* stream,
|
---|
| 212 | const QMap<QString, QString>* txtMap) const {
|
---|
| 213 |
|
---|
[4493] | 214 | QStringList newComments;
|
---|
[5068] | 215 | QString runBy = BNC_CORE->userName();
|
---|
[4481] | 216 |
|
---|
| 217 | if (txtMap) {
|
---|
| 218 | QMapIterator<QString, QString> it(*txtMap);
|
---|
| 219 | while (it.hasNext()) {
|
---|
| 220 | it.next();
|
---|
| 221 | if (it.key() == "RUN BY") {
|
---|
| 222 | runBy = it.value();
|
---|
| 223 | }
|
---|
| 224 | else if (it.key() == "COMMENT") {
|
---|
[4493] | 225 | newComments = it.value().split("\\n", QString::SkipEmptyParts);
|
---|
[4481] | 226 | }
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | *stream << QString("%1 Observation data Mixed")
|
---|
| 231 | .arg(_version, 9, 'f', 2)
|
---|
| 232 | .leftJustified(60)
|
---|
| 233 | << "RINEX VERSION / TYPE\n";
|
---|
| 234 |
|
---|
| 235 | const QString fmtDate = (_version < 3.0) ? "dd-MMM-yy hh:mm"
|
---|
| 236 | : "yyyyMMdd hhmmss UTC";
|
---|
| 237 | *stream << QString("%1%2%3")
|
---|
[5068] | 238 | .arg(BNC_CORE->pgmName(), -20)
|
---|
[4481] | 239 | .arg(runBy.trimmed().left(20), -20)
|
---|
| 240 | .arg(QDateTime::currentDateTime().toUTC().toString(fmtDate), -20)
|
---|
| 241 | .leftJustified(60)
|
---|
| 242 | << "PGM / RUN BY / DATE\n";
|
---|
| 243 |
|
---|
[4493] | 244 | QStringListIterator itCmnt(_comments + newComments);
|
---|
[4481] | 245 | while (itCmnt.hasNext()) {
|
---|
| 246 | *stream << itCmnt.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | *stream << QString("%1")
|
---|
| 250 | .arg(_markerName, -60)
|
---|
| 251 | .leftJustified(60)
|
---|
| 252 | << "MARKER NAME\n";
|
---|
| 253 |
|
---|
| 254 | if (!_markerNumber.isEmpty()) {
|
---|
| 255 | *stream << QString("%1")
|
---|
| 256 | .arg(_markerNumber, -20)
|
---|
| 257 | .leftJustified(60)
|
---|
| 258 | << "MARKER NUMBER\n";
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | *stream << QString("%1%2")
|
---|
[4529] | 262 | .arg(_observer, -20)
|
---|
| 263 | .arg(_agency, -40)
|
---|
[4481] | 264 | .leftJustified(60)
|
---|
| 265 | << "OBSERVER / AGENCY\n";
|
---|
| 266 |
|
---|
| 267 | *stream << QString("%1%2%3")
|
---|
[4529] | 268 | .arg(_receiverNumber, -20)
|
---|
| 269 | .arg(_receiverType, -20)
|
---|
| 270 | .arg(_receiverVersion, -20)
|
---|
[4481] | 271 | .leftJustified(60)
|
---|
| 272 | << "REC # / TYPE / VERS\n";
|
---|
| 273 |
|
---|
| 274 | *stream << QString("%1%2")
|
---|
[4529] | 275 | .arg(_antennaNumber, -20)
|
---|
| 276 | .arg(_antennaName, -20)
|
---|
[4481] | 277 | .leftJustified(60)
|
---|
| 278 | << "ANT # / TYPE\n";
|
---|
| 279 |
|
---|
| 280 | *stream << QString("%1%2%3")
|
---|
| 281 | .arg(_xyz(1), 14, 'f', 4)
|
---|
| 282 | .arg(_xyz(2), 14, 'f', 4)
|
---|
| 283 | .arg(_xyz(3), 14, 'f', 4)
|
---|
| 284 | .leftJustified(60)
|
---|
| 285 | << "APPROX POSITION XYZ\n";
|
---|
| 286 |
|
---|
| 287 | *stream << QString("%1%2%3")
|
---|
| 288 | .arg(_antNEU(3), 14, 'f', 4)
|
---|
| 289 | .arg(_antNEU(2), 14, 'f', 4)
|
---|
| 290 | .arg(_antNEU(1), 14, 'f', 4)
|
---|
| 291 | .leftJustified(60)
|
---|
| 292 | << "ANTENNA: DELTA H/E/N\n";
|
---|
| 293 |
|
---|
| 294 | if (_version < 3.0) {
|
---|
| 295 | int defaultWlFact1 = _wlFactorsL1[1];
|
---|
| 296 | int defaultWlFact2 = _wlFactorsL2[1]; // TODO check all prns
|
---|
| 297 | *stream << QString("%1%2")
|
---|
| 298 | .arg(defaultWlFact1, 6)
|
---|
| 299 | .arg(defaultWlFact2, 6)
|
---|
| 300 | .leftJustified(60)
|
---|
| 301 | << "WAVELENGTH FACT L1/2\n";
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | *stream << obsTypesStrings().join("");
|
---|
| 305 |
|
---|
[4484] | 306 | if (_interval > 0) {
|
---|
| 307 | *stream << QString("%1")
|
---|
| 308 | .arg(_interval, 10, 'f', 3)
|
---|
| 309 | .leftJustified(60)
|
---|
| 310 | << "INTERVAL\n";
|
---|
| 311 | }
|
---|
[4481] | 312 |
|
---|
| 313 | unsigned year, month, day, hour, min;
|
---|
| 314 | double sec;
|
---|
| 315 | _startTime.civil_date(year, month, day);
|
---|
| 316 | _startTime.civil_time(hour, min, sec);
|
---|
| 317 | *stream << QString("%1%2%3%4%5%6%7")
|
---|
| 318 | .arg(year, 6)
|
---|
| 319 | .arg(month, 6)
|
---|
| 320 | .arg(day, 6)
|
---|
| 321 | .arg(hour, 6)
|
---|
| 322 | .arg(min, 6)
|
---|
| 323 | .arg(sec, 13, 'f', 7)
|
---|
| 324 | .arg("GPS", 8)
|
---|
| 325 | .leftJustified(60)
|
---|
| 326 | << "TIME OF FIRST OBS\n";
|
---|
| 327 |
|
---|
| 328 | *stream << QString()
|
---|
| 329 | .leftJustified(60)
|
---|
| 330 | << "END OF HEADER\n";
|
---|
| 331 | }
|
---|
| 332 |
|
---|
[3716] | 333 | // Number of Observation Types (satellite-system specific)
|
---|
| 334 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4480] | 335 | int t_rnxObsHeader::nTypes(char sys) const {
|
---|
[3716] | 336 | if (_version < 3.0) {
|
---|
| 337 | return _obsTypesV2.size();
|
---|
| 338 | }
|
---|
| 339 | else {
|
---|
[4053] | 340 | if (_obsTypesV3.contains(sys)) {
|
---|
| 341 | return _obsTypesV3[sys].size();
|
---|
[3716] | 342 | }
|
---|
| 343 | else {
|
---|
| 344 | return 0;
|
---|
| 345 | }
|
---|
| 346 | }
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | // Observation Type (satellite-system specific)
|
---|
| 350 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4480] | 351 | const QString& t_rnxObsHeader::obsType(char sys, int index) const {
|
---|
[3716] | 352 | if (_version < 3.0) {
|
---|
| 353 | return _obsTypesV2.at(index);
|
---|
| 354 | }
|
---|
| 355 | else {
|
---|
[4053] | 356 | if (_obsTypesV3.contains(sys)) {
|
---|
| 357 | return _obsTypesV3[sys].at(index);
|
---|
[3716] | 358 | }
|
---|
| 359 | else {
|
---|
| 360 | return _emptyStr;
|
---|
| 361 | }
|
---|
| 362 | }
|
---|
| 363 | }
|
---|
| 364 |
|
---|
[4481] | 365 | // Write Observation Types
|
---|
| 366 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 367 | QStringList t_rnxObsHeader::obsTypesStrings() const {
|
---|
| 368 |
|
---|
| 369 | QStringList strList;
|
---|
| 370 |
|
---|
| 371 | if (_version < 3.0) {
|
---|
| 372 | QString hlp;
|
---|
| 373 | QTextStream(&hlp) << QString("%1").arg(_obsTypesV2.size(), 6);
|
---|
| 374 | for (int ii = 0; ii < _obsTypesV2.size(); ii++) {
|
---|
| 375 | QTextStream(&hlp) << QString("%1").arg(_obsTypesV2[ii], 6);
|
---|
| 376 | if ((ii+1) % 9 == 0 || ii == _obsTypesV2.size()-1) {
|
---|
| 377 | strList.append(hlp.leftJustified(60) + "# / TYPES OF OBSERV\n");
|
---|
| 378 | hlp = QString().leftJustified(6);
|
---|
| 379 | }
|
---|
| 380 | }
|
---|
| 381 | }
|
---|
| 382 | else {
|
---|
| 383 | QMapIterator<char, QVector<QString> > it(_obsTypesV3);
|
---|
| 384 | while (it.hasNext()) {
|
---|
| 385 | it.next();
|
---|
| 386 | char sys = it.key();
|
---|
| 387 | const QVector<QString>& types = it.value();
|
---|
| 388 | QString hlp;
|
---|
| 389 | QTextStream(&hlp) << QString("%1 %2").arg(sys).arg(types.size(), 3);
|
---|
| 390 | for (int ii = 0; ii < types.size(); ii++) {
|
---|
| 391 | QTextStream(&hlp) << QString(" %1").arg(types[ii], -3);
|
---|
| 392 | if ((ii+1) % 13 == 0 || ii == types.size()-1) {
|
---|
| 393 | strList.append(hlp.leftJustified(60) + "SYS / # / OBS TYPES\n");
|
---|
| 394 | hlp = QString().leftJustified(6);
|
---|
| 395 | }
|
---|
| 396 | }
|
---|
| 397 | }
|
---|
| 398 | }
|
---|
| 399 |
|
---|
| 400 | return strList;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
[3716] | 403 | // Constructor
|
---|
| 404 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3843] | 405 | t_rnxObsFile::t_rnxObsFile(const QString& fileName, e_inpOut inpOut) {
|
---|
| 406 | _inpOut = inpOut;
|
---|
[3716] | 407 | _stream = 0;
|
---|
| 408 | _flgPowerFail = false;
|
---|
[3956] | 409 | _trafo = trafoNone;
|
---|
[3843] | 410 | if (_inpOut == input) {
|
---|
| 411 | openRead(fileName);
|
---|
| 412 | }
|
---|
| 413 | else {
|
---|
[3845] | 414 | openWrite(fileName);
|
---|
[3843] | 415 | }
|
---|
[3716] | 416 | }
|
---|
| 417 |
|
---|
[3845] | 418 | // Open for input
|
---|
[3716] | 419 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3843] | 420 | void t_rnxObsFile::openRead(const QString& fileName) {
|
---|
[3718] | 421 |
|
---|
| 422 | _fileName = fileName; expandEnvVar(_fileName);
|
---|
| 423 | _file = new QFile(_fileName);
|
---|
| 424 | _file->open(QIODevice::ReadOnly | QIODevice::Text);
|
---|
| 425 | _stream = new QTextStream();
|
---|
| 426 | _stream->setDevice(_file);
|
---|
| 427 |
|
---|
[3716] | 428 | _header.read(_stream);
|
---|
| 429 |
|
---|
| 430 | // Guess Observation Interval
|
---|
| 431 | // --------------------------
|
---|
| 432 | if (_header._interval == 0.0) {
|
---|
| 433 | bncTime ttPrev;
|
---|
| 434 | for (int iEpo = 0; iEpo < 10; iEpo++) {
|
---|
| 435 | const t_rnxEpo* rnxEpo = nextEpoch();
|
---|
| 436 | if (!rnxEpo) {
|
---|
[3718] | 437 | throw QString("t_rnxObsFile: not enough epochs");
|
---|
[3716] | 438 | }
|
---|
| 439 | if (iEpo > 0) {
|
---|
| 440 | double dt = rnxEpo->tt - ttPrev;
|
---|
| 441 | if (_header._interval == 0.0 || dt < _header._interval) {
|
---|
| 442 | _header._interval = dt;
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 | ttPrev = rnxEpo->tt;
|
---|
| 446 | }
|
---|
[3719] | 447 | _stream->seek(0);
|
---|
[3716] | 448 | _header.read(_stream);
|
---|
| 449 | }
|
---|
[3837] | 450 |
|
---|
| 451 | // Time of first observation
|
---|
| 452 | // -------------------------
|
---|
| 453 | if (!_header._startTime.valid()) {
|
---|
| 454 | const t_rnxEpo* rnxEpo = nextEpoch();
|
---|
| 455 | if (!rnxEpo) {
|
---|
| 456 | throw QString("t_rnxObsFile: not enough epochs");
|
---|
| 457 | }
|
---|
| 458 | _header._startTime = rnxEpo->tt;
|
---|
| 459 | _stream->seek(0);
|
---|
| 460 | _header.read(_stream);
|
---|
| 461 | }
|
---|
[3716] | 462 | }
|
---|
| 463 |
|
---|
[3845] | 464 | // Open for output
|
---|
| 465 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 466 | void t_rnxObsFile::openWrite(const QString& fileName) {
|
---|
| 467 |
|
---|
| 468 | _fileName = fileName; expandEnvVar(_fileName);
|
---|
| 469 | _file = new QFile(_fileName);
|
---|
| 470 | _file->open(QIODevice::WriteOnly | QIODevice::Text);
|
---|
| 471 | _stream = new QTextStream();
|
---|
| 472 | _stream->setDevice(_file);
|
---|
| 473 | }
|
---|
| 474 |
|
---|
[3716] | 475 | // Destructor
|
---|
| 476 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 477 | t_rnxObsFile::~t_rnxObsFile() {
|
---|
| 478 | close();
|
---|
| 479 | }
|
---|
| 480 |
|
---|
| 481 | // Close
|
---|
| 482 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 483 | void t_rnxObsFile::close() {
|
---|
| 484 | delete _stream; _stream = 0;
|
---|
[3718] | 485 | delete _file; _file = 0;
|
---|
[3716] | 486 | }
|
---|
| 487 |
|
---|
| 488 | // Handle Special Epoch Flag
|
---|
| 489 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4540] | 490 | void t_rnxObsFile::handleEpochFlag(int flag, const QString& line,
|
---|
| 491 | bool& headerReRead) {
|
---|
[3716] | 492 |
|
---|
[4540] | 493 | headerReRead = false;
|
---|
| 494 |
|
---|
[3716] | 495 | // Power Failure
|
---|
| 496 | // -------------
|
---|
| 497 | if (flag == 1) {
|
---|
| 498 | _flgPowerFail = true;
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | // Start moving antenna
|
---|
| 502 | // --------------------
|
---|
| 503 | else if (flag == 2) {
|
---|
| 504 | // no action
|
---|
| 505 | }
|
---|
| 506 |
|
---|
| 507 | // Re-Read Header
|
---|
| 508 | // --------------
|
---|
[5468] | 509 | else if (flag == 3 || flag == 4 || flag == 5) {
|
---|
[3716] | 510 | int numLines = 0;
|
---|
| 511 | if (version() < 3.0) {
|
---|
| 512 | readInt(line, 29, 3, numLines);
|
---|
| 513 | }
|
---|
| 514 | else {
|
---|
| 515 | readInt(line, 32, 3, numLines);
|
---|
| 516 | }
|
---|
[5468] | 517 | if (flag == 3 || flag == 4) {
|
---|
| 518 | _header.read(_stream, numLines);
|
---|
| 519 | headerReRead = true;
|
---|
| 520 | }
|
---|
| 521 | else {
|
---|
| 522 | for (int ii = 0; ii < numLines; ii++) {
|
---|
| 523 | _stream->readLine();
|
---|
| 524 | }
|
---|
| 525 | }
|
---|
[3716] | 526 | }
|
---|
| 527 |
|
---|
| 528 | // Unhandled Flag
|
---|
| 529 | // --------------
|
---|
| 530 | else {
|
---|
[3718] | 531 | throw QString("t_rnxObsFile: unhandled flag\n" + line);
|
---|
[3716] | 532 | }
|
---|
| 533 | }
|
---|
| 534 |
|
---|
| 535 | // Retrieve single Epoch
|
---|
| 536 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3994] | 537 | t_rnxObsFile::t_rnxEpo* t_rnxObsFile::nextEpoch() {
|
---|
[3716] | 538 |
|
---|
| 539 | _currEpo.clear();
|
---|
| 540 |
|
---|
| 541 | if (version() < 3.0) {
|
---|
| 542 | return nextEpochV2();
|
---|
| 543 | }
|
---|
| 544 | else {
|
---|
| 545 | return nextEpochV3();
|
---|
| 546 | }
|
---|
| 547 | }
|
---|
| 548 |
|
---|
| 549 | // Retrieve single Epoch (RINEX Version 3)
|
---|
| 550 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3994] | 551 | t_rnxObsFile::t_rnxEpo* t_rnxObsFile::nextEpochV3() {
|
---|
[3716] | 552 |
|
---|
[3719] | 553 | while ( _stream->status() == QTextStream::Ok && !_stream->atEnd() ) {
|
---|
[3716] | 554 |
|
---|
[3718] | 555 | QString line = _stream->readLine();
|
---|
[3716] | 556 |
|
---|
[3718] | 557 | if (line.isEmpty()) {
|
---|
[3716] | 558 | continue;
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 | int flag = 0;
|
---|
| 562 | readInt(line, 31, 1, flag);
|
---|
| 563 | if (flag > 0) {
|
---|
[4540] | 564 | bool headerReRead = false;
|
---|
| 565 | handleEpochFlag(flag, line, headerReRead);
|
---|
| 566 | if (headerReRead) {
|
---|
| 567 | continue;
|
---|
| 568 | }
|
---|
[3716] | 569 | }
|
---|
| 570 |
|
---|
[3718] | 571 | QTextStream in(line.mid(1).toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 572 |
|
---|
| 573 | // Epoch Time
|
---|
| 574 | // ----------
|
---|
| 575 | int year, month, day, hour, min;
|
---|
| 576 | double sec;
|
---|
| 577 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
[3720] | 578 | _currEpo.tt.set(year, month, day, hour, min, sec);
|
---|
[3716] | 579 |
|
---|
| 580 | // Number of Satellites
|
---|
| 581 | // --------------------
|
---|
| 582 | int numSat;
|
---|
| 583 | readInt(line, 32, 3, numSat);
|
---|
| 584 |
|
---|
| 585 | _currEpo.rnxSat.resize(numSat);
|
---|
| 586 |
|
---|
| 587 | // Observations
|
---|
| 588 | // ------------
|
---|
| 589 | for (int iSat = 0; iSat < numSat; iSat++) {
|
---|
[3718] | 590 | line = _stream->readLine();
|
---|
[3719] | 591 | _currEpo.rnxSat[iSat].satSys = line.toAscii()[0];
|
---|
[3716] | 592 | readInt(line, 1, 2, _currEpo.rnxSat[iSat].satNum);
|
---|
[3719] | 593 | char sys = line.toAscii()[0];
|
---|
[3716] | 594 | for (int iType = 0; iType < _header.nTypes(sys); iType++) {
|
---|
| 595 | int pos = 3 + 16*iType;
|
---|
| 596 | double obsValue = 0.0;
|
---|
| 597 | int lli = 0;
|
---|
| 598 | int snr = 0;
|
---|
| 599 | readDbl(line, pos, 14, obsValue);
|
---|
| 600 | readInt(line, pos + 14, 1, lli);
|
---|
| 601 | readInt(line, pos + 15, 1, snr);
|
---|
| 602 |
|
---|
| 603 | if (_flgPowerFail) {
|
---|
| 604 | lli |= 1;
|
---|
| 605 | }
|
---|
| 606 |
|
---|
| 607 | _currEpo.rnxSat[iSat].obs.push_back(obsValue);
|
---|
| 608 | _currEpo.rnxSat[iSat].lli.push_back(lli);
|
---|
| 609 | _currEpo.rnxSat[iSat].snr.push_back(snr);
|
---|
| 610 | }
|
---|
| 611 | }
|
---|
| 612 |
|
---|
| 613 | _flgPowerFail = false;
|
---|
| 614 |
|
---|
| 615 | return &_currEpo;
|
---|
| 616 | }
|
---|
| 617 |
|
---|
| 618 | return 0;
|
---|
| 619 | }
|
---|
| 620 |
|
---|
| 621 | // Retrieve single Epoch (RINEX Version 2)
|
---|
| 622 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3994] | 623 | t_rnxObsFile::t_rnxEpo* t_rnxObsFile::nextEpochV2() {
|
---|
[3716] | 624 |
|
---|
[3719] | 625 | while ( _stream->status() == QTextStream::Ok && !_stream->atEnd() ) {
|
---|
[3716] | 626 |
|
---|
[3718] | 627 | QString line = _stream->readLine();
|
---|
[3716] | 628 |
|
---|
[3718] | 629 | if (line.isEmpty()) {
|
---|
[3716] | 630 | continue;
|
---|
| 631 | }
|
---|
| 632 |
|
---|
| 633 | int flag = 0;
|
---|
| 634 | readInt(line, 28, 1, flag);
|
---|
| 635 | if (flag > 0) {
|
---|
[4540] | 636 | bool headerReRead = false;
|
---|
| 637 | handleEpochFlag(flag, line, headerReRead);
|
---|
| 638 | if (headerReRead) {
|
---|
| 639 | continue;
|
---|
| 640 | }
|
---|
[3716] | 641 | }
|
---|
| 642 |
|
---|
[3718] | 643 | QTextStream in(line.toAscii(), QIODevice::ReadOnly);
|
---|
[3716] | 644 |
|
---|
| 645 | // Epoch Time
|
---|
| 646 | // ----------
|
---|
| 647 | int year, month, day, hour, min;
|
---|
| 648 | double sec;
|
---|
| 649 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
| 650 | if (year < 80) {
|
---|
| 651 | year += 2000;
|
---|
| 652 | }
|
---|
| 653 | else if (year < 100) {
|
---|
| 654 | year += 1900;
|
---|
| 655 | }
|
---|
[3720] | 656 | _currEpo.tt.set(year, month, day, hour, min, sec);
|
---|
[3716] | 657 |
|
---|
| 658 | // Number of Satellites
|
---|
| 659 | // --------------------
|
---|
| 660 | int numSat;
|
---|
| 661 | readInt(line, 29, 3, numSat);
|
---|
| 662 |
|
---|
| 663 | _currEpo.rnxSat.resize(numSat);
|
---|
| 664 |
|
---|
| 665 | // Read Satellite Numbers
|
---|
| 666 | // ----------------------
|
---|
| 667 | int pos = 32;
|
---|
| 668 | for (int iSat = 0; iSat < numSat; iSat++) {
|
---|
| 669 | if (iSat > 0 && iSat % 12 == 0) {
|
---|
[3718] | 670 | line = _stream->readLine();
|
---|
[3716] | 671 | pos = 32;
|
---|
| 672 | }
|
---|
| 673 |
|
---|
[3719] | 674 | _currEpo.rnxSat[iSat].satSys = line.toAscii()[pos];
|
---|
[4545] | 675 | if (_currEpo.rnxSat[iSat].satSys == ' ') {
|
---|
| 676 | _currEpo.rnxSat[iSat].satSys = 'G';
|
---|
| 677 | }
|
---|
[3716] | 678 | readInt(line, pos + 1, 2, _currEpo.rnxSat[iSat].satNum);
|
---|
| 679 |
|
---|
| 680 | pos += 3;
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | // Read Observation Records
|
---|
| 684 | // ------------------------
|
---|
| 685 | for (int iSat = 0; iSat < numSat; iSat++) {
|
---|
[3718] | 686 | line = _stream->readLine();
|
---|
[3716] | 687 | pos = 0;
|
---|
| 688 | for (int iType = 0; iType < _header.nTypes(_currEpo.rnxSat[iSat].satSys); iType++) {
|
---|
| 689 | if (iType > 0 && iType % 5 == 0) {
|
---|
[3718] | 690 | line = _stream->readLine();
|
---|
[3716] | 691 | pos = 0;
|
---|
| 692 | }
|
---|
| 693 | double obsValue = 0.0;
|
---|
| 694 | int lli = 0;
|
---|
| 695 | int snr = 0;
|
---|
| 696 | readDbl(line, pos, 14, obsValue);
|
---|
| 697 | readInt(line, pos + 14, 1, lli);
|
---|
| 698 | readInt(line, pos + 15, 1, snr);
|
---|
| 699 |
|
---|
| 700 | if (_flgPowerFail) {
|
---|
| 701 | lli |= 1;
|
---|
| 702 | }
|
---|
| 703 |
|
---|
| 704 | _currEpo.rnxSat[iSat].obs.push_back(obsValue);
|
---|
| 705 | _currEpo.rnxSat[iSat].lli.push_back(lli);
|
---|
| 706 | _currEpo.rnxSat[iSat].snr.push_back(snr);
|
---|
| 707 |
|
---|
| 708 | pos += 16;
|
---|
| 709 | }
|
---|
| 710 | }
|
---|
| 711 |
|
---|
| 712 | _flgPowerFail = false;
|
---|
| 713 |
|
---|
| 714 | return &_currEpo;
|
---|
| 715 | }
|
---|
| 716 |
|
---|
| 717 | return 0;
|
---|
| 718 | }
|
---|
| 719 |
|
---|
[3844] | 720 | // Set Header Information
|
---|
| 721 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3956] | 722 | void t_rnxObsFile::setHeader(const t_rnxObsHeader& header, double version) {
|
---|
| 723 |
|
---|
| 724 | if (int(header._version) == int(version)) {
|
---|
| 725 | _trafo = trafoNone;
|
---|
| 726 | _header._version = header._version;
|
---|
| 727 | }
|
---|
| 728 | else if (version >= 3.0) {
|
---|
| 729 | _trafo = trafo2to3;
|
---|
[5377] | 730 | _header._version = t_rnxObsHeader::defaultRnxObsVersion3;
|
---|
[3956] | 731 | }
|
---|
| 732 | else {
|
---|
| 733 | _trafo = trafo3to2;
|
---|
[5377] | 734 | _header._version = t_rnxObsHeader::defaultRnxObsVersion2;
|
---|
[3956] | 735 | }
|
---|
| 736 |
|
---|
[3930] | 737 | _header._interval = header._interval;
|
---|
| 738 | _header._antennaNumber = header._antennaNumber;
|
---|
| 739 | _header._antennaName = header._antennaName;
|
---|
| 740 | _header._markerName = header._markerName;
|
---|
| 741 | _header._markerNumber = header._markerNumber;
|
---|
| 742 | _header._antNEU = header._antNEU;
|
---|
| 743 | _header._antXYZ = header._antXYZ;
|
---|
| 744 | _header._antBSG = header._antBSG;
|
---|
| 745 | _header._xyz = header._xyz;
|
---|
| 746 | _header._observer = header._observer;
|
---|
| 747 | _header._agency = header._agency;
|
---|
| 748 | _header._receiverNumber = header._receiverNumber;
|
---|
| 749 | _header._receiverType = header._receiverType;
|
---|
| 750 | _header._receiverVersion = header._receiverVersion;
|
---|
| 751 |
|
---|
[5742] | 752 | for (unsigned iPrn = 1; iPrn <= t_prn::MAXPRN_GPS; iPrn++) {
|
---|
[3844] | 753 | _header._wlFactorsL1[iPrn] = header._wlFactorsL1[iPrn];
|
---|
| 754 | _header._wlFactorsL2[iPrn] = header._wlFactorsL2[iPrn];
|
---|
| 755 | }
|
---|
[3956] | 756 |
|
---|
[3844] | 757 | _header._startTime = header._startTime;
|
---|
[3956] | 758 |
|
---|
[3962] | 759 | static const string systems = "GRES";
|
---|
| 760 |
|
---|
[4053] | 761 | _header._obsTypesV2.clear();
|
---|
| 762 | _header._obsTypesV3.clear();
|
---|
| 763 |
|
---|
[3956] | 764 | // Copy Observation Types
|
---|
| 765 | // ----------------------
|
---|
[3962] | 766 | if (_trafo == trafoNone) {
|
---|
[4053] | 767 | for (int ii = 0; ii < header._obsTypesV2.size(); ii++) {
|
---|
| 768 | _header._obsTypesV2.append(header._obsTypesV2[ii]);
|
---|
[3844] | 769 | }
|
---|
[4053] | 770 | QMapIterator<char, QVector<QString> > it(header._obsTypesV3);
|
---|
| 771 | while (it.hasNext()) {
|
---|
| 772 | it.next();
|
---|
| 773 | char sys = it.key();
|
---|
| 774 | const QVector<QString>& typesV3 = it.value();
|
---|
| 775 | for (int ii = 0; ii < typesV3.size(); ii++) {
|
---|
[3962] | 776 | _header._obsTypesV3[sys].push_back(typesV3[ii]);
|
---|
| 777 | }
|
---|
| 778 | }
|
---|
[3844] | 779 | }
|
---|
[3956] | 780 |
|
---|
| 781 | // Translate Observation Types v2 --> v3
|
---|
| 782 | // -------------------------------------
|
---|
[3962] | 783 | else if (_trafo == trafo2to3) {
|
---|
[4053] | 784 | for (int i2 = 0; i2 < header._obsTypesV2.size(); i2++) {
|
---|
[3967] | 785 | const QString& typeV2 = header._obsTypesV2[i2];
|
---|
[3956] | 786 | for (unsigned iSys = 0; iSys < systems.length(); iSys++) {
|
---|
[3960] | 787 | char sys = systems[iSys];
|
---|
[3967] | 788 | QString typeV3 = type2to3(sys, typeV2);
|
---|
| 789 | if (!typeV3.isEmpty()) {
|
---|
[3960] | 790 | _header._obsTypesV3[sys].push_back(typeV3);
|
---|
[3967] | 791 | int i3 = _header._obsTypesV3[sys].size() - 1;
|
---|
| 792 | _indexMap3to2[sys][i3] = i2;
|
---|
[3960] | 793 | }
|
---|
[3956] | 794 | }
|
---|
| 795 | }
|
---|
| 796 | }
|
---|
| 797 |
|
---|
| 798 | // Translate Observation Types v3 --> v2
|
---|
| 799 | // -------------------------------------
|
---|
| 800 | else if (_trafo == trafo3to2) {
|
---|
[3965] | 801 | for (unsigned iSys = 0; iSys < systems.length(); iSys++) {
|
---|
| 802 | char sys = systems[iSys];
|
---|
[4053] | 803 | if (header._obsTypesV3.contains(sys)) {
|
---|
| 804 | const QVector<QString>& typesV3 = header._obsTypesV3[sys];
|
---|
| 805 | for (int i3 = 0; i3 < typesV3.size(); i3++) {
|
---|
[3967] | 806 | const QString& typeV3 = typesV3[i3];
|
---|
[3965] | 807 | QString typeV2 = type3to2(typeV3);
|
---|
[3969] | 808 | if (!typeV2.isEmpty()) {
|
---|
| 809 | bool found = false;
|
---|
[4053] | 810 | for (int i2 = 0; i2 < _header._obsTypesV2.size(); i2++) {
|
---|
[3969] | 811 | if (_header._obsTypesV2[i2] == typeV2) {
|
---|
| 812 | found = true;
|
---|
[3971] | 813 | if (_indexMap2to3[sys].find(i2) == _indexMap2to3[sys].end()) {
|
---|
[3970] | 814 | _indexMap2to3[sys][i2] = i3;
|
---|
| 815 | }
|
---|
[3969] | 816 | break;
|
---|
| 817 | }
|
---|
[3965] | 818 | }
|
---|
[3969] | 819 | if (!found) {
|
---|
[4053] | 820 | _header._obsTypesV2.append(typeV2);
|
---|
[3969] | 821 | int i2 = _header._obsTypesV2.size() - 1;
|
---|
| 822 | _indexMap2to3[sys][i2] = i3;
|
---|
| 823 | }
|
---|
[3965] | 824 | }
|
---|
| 825 | }
|
---|
| 826 | }
|
---|
| 827 | }
|
---|
[3956] | 828 | }
|
---|
[3844] | 829 | }
|
---|
[3845] | 830 |
|
---|
| 831 | // Write Data Epoch
|
---|
| 832 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 833 | void t_rnxObsFile::writeEpoch(const t_rnxEpo* epo) {
|
---|
[3866] | 834 | if (version() < 3.0) {
|
---|
| 835 | return writeEpochV2(epo);
|
---|
| 836 | }
|
---|
| 837 | else {
|
---|
| 838 | return writeEpochV3(epo);
|
---|
| 839 | }
|
---|
| 840 | }
|
---|
[3855] | 841 |
|
---|
[3866] | 842 | // Write Data Epoch (RINEX Version 2)
|
---|
| 843 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 844 | void t_rnxObsFile::writeEpochV2(const t_rnxEpo* epo) {
|
---|
| 845 |
|
---|
[3855] | 846 | unsigned year, month, day, hour, min;
|
---|
| 847 | double sec;
|
---|
| 848 | epo->tt.civil_date(year, month, day);
|
---|
| 849 | epo->tt.civil_time(hour, min, sec);
|
---|
| 850 |
|
---|
| 851 | QString dateStr;
|
---|
[3868] | 852 | QTextStream(&dateStr) << QString(" %1 %2 %3 %4 %5%6")
|
---|
[3856] | 853 | .arg(int(fmod(year, 100)), 2, 10, QChar('0'))
|
---|
[3868] | 854 | .arg(month, 2, 10, QChar('0'))
|
---|
| 855 | .arg(day, 2, 10, QChar('0'))
|
---|
| 856 | .arg(hour, 2, 10, QChar('0'))
|
---|
| 857 | .arg(min, 2, 10, QChar('0'))
|
---|
| 858 | .arg(sec, 11, 'f', 7);
|
---|
[3855] | 859 |
|
---|
[3857] | 860 | int flag = 0;
|
---|
| 861 | *_stream << dateStr
|
---|
| 862 | << QString("%1%2").arg(flag, 3).arg(epo->rnxSat.size(), 3);
|
---|
[3858] | 863 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
[3869] | 864 | const t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[3858] | 865 | if (iSat > 0 && iSat % 12 == 0) {
|
---|
[3857] | 866 | *_stream << endl << QString().leftJustified(32);
|
---|
| 867 | }
|
---|
[3869] | 868 | *_stream << rnxSat.satSys << QString("%1").arg(rnxSat.satNum, 2);
|
---|
[3857] | 869 | }
|
---|
| 870 | *_stream << endl;
|
---|
[3858] | 871 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
[3967] | 872 |
|
---|
[3858] | 873 | const t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[3971] | 874 | char sys = rnxSat.satSys;
|
---|
[3966] | 875 |
|
---|
[3971] | 876 | for (int iTypeV2 = 0; iTypeV2 < nTypes(sys); iTypeV2++) {
|
---|
[3967] | 877 |
|
---|
| 878 | if (iTypeV2 > 0 && iTypeV2 % 5 == 0) {
|
---|
| 879 | *_stream << endl;
|
---|
| 880 | }
|
---|
| 881 |
|
---|
[3971] | 882 | int iType = -1;
|
---|
[3966] | 883 | if (_trafo == trafoNone) {
|
---|
[3967] | 884 | iType = iTypeV2;
|
---|
[3966] | 885 | }
|
---|
| 886 | else {
|
---|
[3971] | 887 | if (_indexMap2to3[sys].find(iTypeV2) != _indexMap2to3[sys].end()) {
|
---|
| 888 | iType = _indexMap2to3[sys][iTypeV2];
|
---|
| 889 | }
|
---|
[3966] | 890 | }
|
---|
| 891 |
|
---|
[3971] | 892 | if (iType == -1 || rnxSat.obs[iType] == 0.0) {
|
---|
[3858] | 893 | *_stream << QString().leftJustified(16);
|
---|
| 894 | }
|
---|
| 895 | else {
|
---|
[3979] | 896 | *_stream << QString("%1").arg(rnxSat.obs[iType], 14, 'f', 3);
|
---|
| 897 | if (rnxSat.lli[iType] != 0.0) {
|
---|
| 898 | *_stream << QString("%1").arg(rnxSat.lli[iType],1);
|
---|
| 899 | }
|
---|
| 900 | else {
|
---|
| 901 | *_stream << ' ';
|
---|
| 902 | }
|
---|
| 903 | if (rnxSat.snr[iType] != 0.0) {
|
---|
| 904 | *_stream << QString("%1").arg(rnxSat.snr[iType],1);
|
---|
| 905 | }
|
---|
| 906 | else {
|
---|
| 907 | *_stream << ' ';
|
---|
| 908 | }
|
---|
[3858] | 909 | }
|
---|
| 910 | }
|
---|
| 911 | *_stream << endl;
|
---|
| 912 | }
|
---|
[3845] | 913 | }
|
---|
[3866] | 914 |
|
---|
| 915 | // Write Data Epoch (RINEX Version 3)
|
---|
| 916 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 917 | void t_rnxObsFile::writeEpochV3(const t_rnxEpo* epo) {
|
---|
| 918 |
|
---|
| 919 | unsigned year, month, day, hour, min;
|
---|
| 920 | double sec;
|
---|
| 921 | epo->tt.civil_date(year, month, day);
|
---|
| 922 | epo->tt.civil_time(hour, min, sec);
|
---|
| 923 |
|
---|
[3867] | 924 | QString dateStr;
|
---|
[3868] | 925 | QTextStream(&dateStr) << QString("> %1 %2 %3 %4 %5%6")
|
---|
[3867] | 926 | .arg(year, 4)
|
---|
| 927 | .arg(month, 2, 10, QChar('0'))
|
---|
| 928 | .arg(day, 2, 10, QChar('0'))
|
---|
| 929 | .arg(hour, 2, 10, QChar('0'))
|
---|
| 930 | .arg(min, 2, 10, QChar('0'))
|
---|
| 931 | .arg(sec, 11, 'f', 7);
|
---|
[3866] | 932 |
|
---|
[3867] | 933 | int flag = 0;
|
---|
| 934 | *_stream << dateStr
|
---|
| 935 | << QString("%1%2\n").arg(flag, 3).arg(epo->rnxSat.size(), 3);
|
---|
| 936 |
|
---|
[3869] | 937 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 938 | const t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[3971] | 939 | char sys = rnxSat.satSys;
|
---|
| 940 | *_stream << sys
|
---|
[3869] | 941 | << QString("%1").arg(rnxSat.satNum, 2, 10, QChar('0'));
|
---|
[3964] | 942 |
|
---|
[3971] | 943 | for (int iTypeV3 = 0; iTypeV3 < nTypes(sys); iTypeV3++) {
|
---|
[3964] | 944 |
|
---|
[3971] | 945 | int iType = -1;
|
---|
[3964] | 946 | if (_trafo == trafoNone) {
|
---|
[3967] | 947 | iType = iTypeV3;
|
---|
[3964] | 948 | }
|
---|
| 949 | else {
|
---|
[3971] | 950 | if (_indexMap3to2[sys].find(iTypeV3) != _indexMap3to2[sys].end()) {
|
---|
| 951 | iType = _indexMap3to2[sys][iTypeV3];
|
---|
| 952 | }
|
---|
[3964] | 953 | }
|
---|
| 954 |
|
---|
[3971] | 955 | if (iType == -1 || rnxSat.obs[iType] == 0.0) {
|
---|
[3869] | 956 | *_stream << QString().leftJustified(16);
|
---|
| 957 | }
|
---|
| 958 | else {
|
---|
[3979] | 959 | *_stream << QString("%1").arg(rnxSat.obs[iType], 14, 'f', 3);
|
---|
| 960 | if (rnxSat.lli[iType] != 0.0) {
|
---|
| 961 | *_stream << QString("%1").arg(rnxSat.lli[iType],1);
|
---|
| 962 | }
|
---|
| 963 | else {
|
---|
| 964 | *_stream << ' ';
|
---|
| 965 | }
|
---|
| 966 | if (rnxSat.snr[iType] != 0.0) {
|
---|
| 967 | *_stream << QString("%1").arg(rnxSat.snr[iType],1);
|
---|
| 968 | }
|
---|
| 969 | else {
|
---|
| 970 | *_stream << ' ';
|
---|
| 971 | }
|
---|
[3869] | 972 | }
|
---|
| 973 | }
|
---|
| 974 | *_stream << endl;
|
---|
| 975 | }
|
---|
[3866] | 976 | }
|
---|
[3956] | 977 |
|
---|
| 978 | // Translate Observation Type v2 --> v3
|
---|
| 979 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 980 | QString t_rnxObsFile::type2to3(char sys, const QString& typeV2) {
|
---|
| 981 |
|
---|
| 982 | if (sys == 'G') {
|
---|
| 983 | if (typeV2 == "C1") return "C1C";
|
---|
| 984 | if (typeV2 == "C2") return "C2C";
|
---|
| 985 | if (typeV2 == "C5") return "C5C";
|
---|
| 986 | if (typeV2 == "P1") return "C1P";
|
---|
| 987 | if (typeV2 == "P2") return "C2P";
|
---|
| 988 | if (typeV2 == "L1") return "L1";
|
---|
| 989 | if (typeV2 == "L2") return "L2";
|
---|
| 990 | if (typeV2 == "L5") return "L5";
|
---|
| 991 | if (typeV2 == "D1") return "D1";
|
---|
| 992 | if (typeV2 == "D2") return "D2";
|
---|
| 993 | if (typeV2 == "D5") return "D5";
|
---|
| 994 | if (typeV2 == "S1") return "S1";
|
---|
| 995 | if (typeV2 == "S2") return "S2";
|
---|
| 996 | if (typeV2 == "S5") return "S5";
|
---|
| 997 | }
|
---|
| 998 |
|
---|
| 999 | else if (sys == 'R') {
|
---|
| 1000 | if (typeV2 == "C1") return "C1C";
|
---|
| 1001 | if (typeV2 == "C2") return "C2C";
|
---|
| 1002 | if (typeV2 == "P1") return "C1P";
|
---|
| 1003 | if (typeV2 == "P2") return "C2P";
|
---|
| 1004 | if (typeV2 == "L1") return "L1";
|
---|
| 1005 | if (typeV2 == "L2") return "L2";
|
---|
| 1006 | if (typeV2 == "D1") return "D1";
|
---|
| 1007 | if (typeV2 == "D2") return "D2";
|
---|
| 1008 | if (typeV2 == "S1") return "S1";
|
---|
| 1009 | if (typeV2 == "S2") return "S2";
|
---|
| 1010 | }
|
---|
| 1011 |
|
---|
| 1012 | else if (sys == 'E') {
|
---|
| 1013 | if (typeV2 == "C1") return "C1";
|
---|
| 1014 | if (typeV2 == "C5") return "C5";
|
---|
| 1015 | if (typeV2 == "C6") return "C6";
|
---|
| 1016 | if (typeV2 == "C7") return "C7";
|
---|
| 1017 | if (typeV2 == "C8") return "C8";
|
---|
| 1018 | if (typeV2 == "L1") return "L1";
|
---|
| 1019 | if (typeV2 == "L5") return "L5";
|
---|
| 1020 | if (typeV2 == "L6") return "L6";
|
---|
| 1021 | if (typeV2 == "L7") return "L7";
|
---|
| 1022 | if (typeV2 == "L8") return "L8";
|
---|
| 1023 | if (typeV2 == "D1") return "D1";
|
---|
| 1024 | if (typeV2 == "D5") return "D5";
|
---|
| 1025 | if (typeV2 == "D6") return "D6";
|
---|
| 1026 | if (typeV2 == "D7") return "D7";
|
---|
| 1027 | if (typeV2 == "D8") return "D8";
|
---|
| 1028 | if (typeV2 == "S1") return "S1";
|
---|
| 1029 | if (typeV2 == "S5") return "S5";
|
---|
| 1030 | if (typeV2 == "S6") return "S6";
|
---|
| 1031 | if (typeV2 == "S7") return "S7";
|
---|
| 1032 | if (typeV2 == "S8") return "S8";
|
---|
| 1033 | }
|
---|
| 1034 |
|
---|
| 1035 | else if (sys == 'S') {
|
---|
| 1036 | if (typeV2 == "C1") return "C1C";
|
---|
| 1037 | if (typeV2 == "C5") return "C5C";
|
---|
| 1038 | if (typeV2 == "L1") return "L1";
|
---|
| 1039 | if (typeV2 == "L5") return "L5";
|
---|
| 1040 | if (typeV2 == "D1") return "D1";
|
---|
| 1041 | if (typeV2 == "D5") return "D5";
|
---|
| 1042 | if (typeV2 == "S1") return "S1";
|
---|
| 1043 | if (typeV2 == "S5") return "S5";
|
---|
| 1044 | }
|
---|
| 1045 |
|
---|
| 1046 | return "";
|
---|
| 1047 | }
|
---|
[3962] | 1048 |
|
---|
| 1049 | // Translate Observation Type v3 --> v2
|
---|
| 1050 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1051 | QString t_rnxObsFile::type3to2(const QString& typeV3) {
|
---|
| 1052 | if (typeV3 == "C1P") {
|
---|
| 1053 | return "P1";
|
---|
| 1054 | }
|
---|
| 1055 | else if (typeV3 == "C2P") {
|
---|
| 1056 | return "P2";
|
---|
| 1057 | }
|
---|
| 1058 | else {
|
---|
| 1059 | return typeV3.left(2);
|
---|
| 1060 | }
|
---|
[3965] | 1061 |
|
---|
| 1062 | return "";
|
---|
[3962] | 1063 | }
|
---|
[4053] | 1064 |
|
---|
| 1065 | // Check for Changes in Header
|
---|
| 1066 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1067 | void t_rnxObsFile::checkNewHeader(const t_rnxObsHeader& header) {
|
---|
| 1068 |
|
---|
| 1069 | t_rnxObsHeader oldHeader(_header);
|
---|
| 1070 | setHeader(header, oldHeader._version);
|
---|
| 1071 |
|
---|
[4054] | 1072 | // Check Observation Types
|
---|
| 1073 | // -----------------------
|
---|
| 1074 | bool same = true;
|
---|
| 1075 | if (_header._version < 3.0) {
|
---|
| 1076 | if (_header._obsTypesV2 != oldHeader._obsTypesV2) {
|
---|
| 1077 | same = false;
|
---|
| 1078 | }
|
---|
| 1079 | }
|
---|
| 1080 | else {
|
---|
| 1081 | QMapIterator<char, QVector<QString> > it(_header._obsTypesV3);
|
---|
| 1082 | while (it.hasNext()) {
|
---|
| 1083 | it.next();
|
---|
| 1084 | char sys = it.key();
|
---|
| 1085 | const QVector<QString>& typesV3 = it.value();
|
---|
| 1086 | if (!oldHeader._obsTypesV3.contains(sys) ||
|
---|
| 1087 | oldHeader._obsTypesV3[sys] != typesV3) {
|
---|
| 1088 | same = false;
|
---|
| 1089 | break;
|
---|
| 1090 | }
|
---|
| 1091 | }
|
---|
| 1092 | }
|
---|
[4053] | 1093 |
|
---|
[4054] | 1094 | if (!same) {
|
---|
[4481] | 1095 | QStringList strLst = _header.obsTypesStrings();
|
---|
[4748] | 1096 | if (_header._version < 3.0) {
|
---|
| 1097 | *_stream << QString().leftJustified(26);
|
---|
| 1098 | }
|
---|
| 1099 | else {
|
---|
| 1100 | *_stream << '>' << QString().leftJustified(28);
|
---|
| 1101 | }
|
---|
| 1102 | *_stream << QString(" 4%1\n").arg(strLst.size(), 3)
|
---|
[4056] | 1103 | << strLst.join("");
|
---|
[4053] | 1104 | }
|
---|
| 1105 | }
|
---|