source: ntrip/trunk/BNC/rinex/reqcedit.cpp@ 3994

Last change on this file since 3994 was 3994, checked in by mervart, 12 years ago
File size: 5.5 KB
Line 
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_reqcEdit
30 *
31 * Purpose: Edit/Concatenate RINEX Files
32 *
33 * Author: L. Mervart
34 *
35 * Created: 11-Apr-2012
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include "reqcedit.h"
43#include "bncapp.h"
44#include "bncsettings.h"
45
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50t_reqcEdit::t_reqcEdit(QObject* parent) : QThread(parent) {
51
52 bncSettings settings;
53
54 _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
55 _outObsFileName = settings.value("reqcOutObsFile").toString();
56 _rnxVersion = settings.value("reqcRnxVersion").toDouble();
57 _samplingRate = settings.value("reqcSampling").toInt();
58 _begTime = bncTime(settings.value("reqcStartDateTime").toString().toAscii().data());
59 _endTime = bncTime(settings.value("reqcEndDateTime").toString().toAscii().data());
60}
61
62// Destructor
63////////////////////////////////////////////////////////////////////////////
64t_reqcEdit::~t_reqcEdit() {
65 for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
66 delete _rnxObsFiles[ii];
67 }
68}
69
70//
71////////////////////////////////////////////////////////////////////////////
72void t_reqcEdit::run() {
73
74 // Initialize input observation files, sort them according to start time
75 // ---------------------------------------------------------------------
76 QStringListIterator it(_obsFileNames);
77 while (it.hasNext()) {
78 QString fileName = it.next();
79 t_rnxObsFile* rnxObsFile = new t_rnxObsFile(fileName, t_rnxObsFile::input);
80 _rnxObsFiles.append(rnxObsFile);
81 }
82 qStableSort(_rnxObsFiles.begin(), _rnxObsFiles.end(),
83 t_rnxObsFile::earlierStartTime);
84
85 // Initialize output observation file
86 // ----------------------------------
87 t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
88
89 // Loop over all input observation files
90 // -------------------------------------
91 for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
92 t_rnxObsFile* obsFile = _rnxObsFiles[ii];
93 if (ii == 0) {
94 outObsFile.setHeader(obsFile->header(), _rnxVersion);
95 if (_begTime.valid() && _begTime > outObsFile.startTime()) {
96 outObsFile.setStartTime(_begTime);
97 }
98 editRnxObsHeader(outObsFile);
99 outObsFile.writeHeader();
100 }
101 t_rnxObsFile::t_rnxEpo* epo = 0;
102 while ( (epo = obsFile->nextEpoch()) != 0) {
103 if (_begTime.valid() && epo->tt < _begTime) {
104 continue;
105 }
106 if (_endTime.valid() && epo->tt > _endTime) {
107 break;
108 }
109
110 if (_samplingRate == 0 ||
111 fmod(round(epo->tt.gpssec()), _samplingRate) == 0) {
112 applyLLI(epo);
113 outObsFile.writeEpoch(epo);
114 }
115 else {
116 rememberLLI(epo);
117 }
118 }
119 }
120
121 bncApp* app = (bncApp*) qApp;
122 if ( app->mode() != bncApp::interactive) {
123 app->exit(0);
124 }
125 else {
126 emit finished();
127 deleteLater();
128 }
129}
130
131// Change RINEX Header Content
132////////////////////////////////////////////////////////////////////////////
133void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
134
135 bncSettings settings;
136
137 QString oldMarkerName = settings.value("reqcOldMarkerName").toString();
138 QString newMarkerName = settings.value("reqcNewMarkerName").toString();
139 if (oldMarkerName.isEmpty() ||
140 QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
141 obsFile.setMarkerName(newMarkerName);
142 }
143
144 QString oldAntennaName = settings.value("reqcOldAntennaName").toString();
145 QString newAntennaName = settings.value("reqcNewAntennaName").toString();
146 if (oldAntennaName.isEmpty() ||
147 QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
148 obsFile.setAntennaName(newAntennaName);
149 }
150
151 QString oldReceiverType = settings.value("reqcOldReceiverName").toString();
152 QString newReceiverType = settings.value("reqcNewReceiverName").toString();
153 if (oldReceiverType.isEmpty() ||
154 QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
155 obsFile.setReceiverType(newReceiverType);
156 }
157}
158
159//
160////////////////////////////////////////////////////////////////////////////
161void t_reqcEdit::rememberLLI(const t_rnxObsFile::t_rnxEpo* epo) {
162
163}
164
165//
166////////////////////////////////////////////////////////////////////////////
167void t_reqcEdit::applyLLI(t_rnxObsFile::t_rnxEpo* epo) {
168
169}
Note: See TracBrowser for help on using the repository browser.