1 |
|
---|
2 | /* -------------------------------------------------------------------------
|
---|
3 | * BKG NTRIP Server
|
---|
4 | * -------------------------------------------------------------------------
|
---|
5 | *
|
---|
6 | * Class: bncSinexTro
|
---|
7 | *
|
---|
8 | * Purpose: writes SINEX TRO files
|
---|
9 | *
|
---|
10 | * Author: A. Stürze
|
---|
11 | *
|
---|
12 | * Created: 19-Feb-2015
|
---|
13 | *
|
---|
14 | * Changes:
|
---|
15 | *
|
---|
16 | * -----------------------------------------------------------------------*/
|
---|
17 |
|
---|
18 | #include <math.h>
|
---|
19 | #include <iomanip>
|
---|
20 |
|
---|
21 | #include "bncsinextro.h"
|
---|
22 |
|
---|
23 | using namespace BNC_PPP;
|
---|
24 | using namespace std;
|
---|
25 |
|
---|
26 | // Constructor
|
---|
27 | ////////////////////////////////////////////////////////////////////////////
|
---|
28 | bncSinexTro::bncSinexTro(const t_pppOptions* opt,
|
---|
29 | const QString& sklFileName, const QString& intr,
|
---|
30 | int sampl)
|
---|
31 | : bncoutf(sklFileName, intr, sampl) {
|
---|
32 |
|
---|
33 | _opt = opt;
|
---|
34 | _sampl = sampl;
|
---|
35 |
|
---|
36 | _antex = 0;
|
---|
37 | }
|
---|
38 |
|
---|
39 | // Destructor
|
---|
40 | ////////////////////////////////////////////////////////////////////////////
|
---|
41 | bncSinexTro::~bncSinexTro() {
|
---|
42 | closeFile();
|
---|
43 | if (_antex)
|
---|
44 | delete _antex;
|
---|
45 | }
|
---|
46 |
|
---|
47 | // Write Header
|
---|
48 | ////////////////////////////////////////////////////////////////////////////
|
---|
49 | void bncSinexTro::writeHeader(const QDateTime& datTim) {
|
---|
50 | int GPSWeek;
|
---|
51 | double GPSWeeks;
|
---|
52 | bncSettings settings;
|
---|
53 | GPSweekFromDateAndTime(datTim, GPSWeek, GPSWeeks);
|
---|
54 | int daysec = int(fmod(GPSWeeks, 86400.0));
|
---|
55 | int dayOfYear = datTim.date().dayOfYear();
|
---|
56 | QString yyyy = datTim.toString("yyyy");
|
---|
57 | QString creationTime = QString("%1:%2:%3").arg(yyyy)
|
---|
58 | .arg(dayOfYear, 3, 10, QLatin1Char('0'))
|
---|
59 | .arg(daysec , 5, 10, QLatin1Char('0'));
|
---|
60 | QString startTime = creationTime;
|
---|
61 | QString intStr = settings.value("PPP/snxtroIntr").toString();
|
---|
62 | int intr, indHlp = 0;
|
---|
63 | if ((indHlp = intStr.indexOf("min")) != -1) {
|
---|
64 | intr = intStr.left(indHlp-1).toInt();
|
---|
65 | intr *= 60;
|
---|
66 | }
|
---|
67 | else if ((indHlp = intStr.indexOf("hour")) != -1) {
|
---|
68 | intr = intStr.left(indHlp-1).toInt();
|
---|
69 | intr *= 3600;
|
---|
70 | }
|
---|
71 | else if ((indHlp = intStr.indexOf("day")) != -1) {
|
---|
72 | intr = intStr.left(indHlp-1).toInt();
|
---|
73 | intr *= 86400;
|
---|
74 | }
|
---|
75 | int nominalStartSec = daysec - (int(fmod(double(daysec), double(intr))));
|
---|
76 | int nominalEndSec = nominalStartSec + intr - _sampl;
|
---|
77 | QString endTime = QString("%1:%2:%3").arg(yyyy)
|
---|
78 | .arg(dayOfYear , 3, 10, QLatin1Char('0'))
|
---|
79 | .arg(nominalEndSec , 5, 10, QLatin1Char('0'));
|
---|
80 | int numEpochs = ((nominalEndSec - daysec) / _sampl) +1;
|
---|
81 | QString epo = QString("%1").arg(numEpochs, 5, 10, QLatin1Char('0'));
|
---|
82 | QString ac = QString("%1").arg(settings.value("PPP/snxtroAc").toString(),3,QLatin1Char(' '));
|
---|
83 | QString solId = settings.value("PPP/snxtroSolId").toString();
|
---|
84 | QString corr = "";
|
---|
85 | if (settings.value("PPP/dataSource").toString() == "Real-Time Streams") {
|
---|
86 | corr = settings.value("PPP/corrMount").toString();
|
---|
87 | }
|
---|
88 | else if (settings.value("PPP/dataSource").toString() == "RINEX Files") {
|
---|
89 | corr = settings.value("PPP/corrFile").toString();
|
---|
90 | }
|
---|
91 | QString signalPriorities = QString::fromStdString(_opt->_signalPriorities);
|
---|
92 | if (!signalPriorities.size()) {
|
---|
93 | signalPriorities = "G:12&CWPSLX R:12&CP E:1&CBX E:5&QIX C:26&IQX";
|
---|
94 | }
|
---|
95 | QStringList priorList = signalPriorities.split(" ", QString::SkipEmptyParts);
|
---|
96 | QStringList frqStrList;
|
---|
97 | for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
|
---|
98 | t_frequency::type frqType = static_cast<t_frequency::type>(iFreq);
|
---|
99 | char frqSys = t_frequency::toString(frqType)[0];
|
---|
100 | char frqNum = t_frequency::toString(frqType)[1];
|
---|
101 | QStringList hlp;
|
---|
102 | for (int ii = 0; ii < priorList.size(); ii++) {
|
---|
103 | if (priorList[ii].indexOf(":") != -1) {
|
---|
104 | hlp = priorList[ii].split(":", QString::SkipEmptyParts);
|
---|
105 | if (hlp.size() == 2 && hlp[0].length() == 1 && hlp[0][0] == frqSys) {
|
---|
106 | hlp = hlp[1].split("&", QString::SkipEmptyParts);
|
---|
107 | }
|
---|
108 | if (hlp.size() == 2 && hlp[0].indexOf(frqNum) != -1) {
|
---|
109 | frqStrList.append(QString("%1%2").arg(frqSys).arg(frqNum));
|
---|
110 | }
|
---|
111 | }
|
---|
112 | }
|
---|
113 | }
|
---|
114 |
|
---|
115 | _out << "%=TRO 2.00 " << ac.toStdString() << " "
|
---|
116 | << creationTime.toStdString() << " " << ac.toStdString() << " "
|
---|
117 | << startTime.toStdString() << " " << endTime.toStdString() << " P "
|
---|
118 | << _opt->_roverName.substr(0,9) << endl;
|
---|
119 | _out << "*-------------------------------------------------------------------------------" << endl;
|
---|
120 | _out << "+FILE/REFERENCE" << endl;
|
---|
121 | _out << "*INFO_TYPE_________ INFO________________________________________________________" << endl;
|
---|
122 | _out << " DESCRIPTION " << "BNC generated SINEX TRO file" << endl;
|
---|
123 | _out << " OUTPUT " << "Total Troposphere Zenith Path Delay Product" << endl;
|
---|
124 | _out << " SOFTWARE " << BNCPGMNAME << endl;
|
---|
125 | _out << " INPUT " << "OBS: " << _opt->_roverName.substr(0,9) << ", SSR: " << corr.toStdString() << endl;
|
---|
126 | _out << " VERSION NUMBER " << QString("%1").arg(solId, 3, QLatin1Char('0')).toStdString() << endl;
|
---|
127 | _out << "-FILE/REFERENCE" << endl;
|
---|
128 | _out << "*-------------------------------------------------------------------------------" << endl;
|
---|
129 |
|
---|
130 | QString systems;
|
---|
131 | if (settings.value("PPP/lcGPS" ).toString() != "no") {systems += "G, ";}
|
---|
132 | if (settings.value("PPP/lcGLONASS").toString() != "no") {systems += "R, ";}
|
---|
133 | if (settings.value("PPP/lcGalileo").toString() != "no") {systems += "E, ";}
|
---|
134 | if (settings.value("PPP/lcBDS" ).toString() != "no") {systems += "C";}
|
---|
135 | QString blqFileName = QString::fromStdString(_opt->_blqFileName);
|
---|
136 | QString blqFileBaseName;
|
---|
137 | QString blqFileExtension;
|
---|
138 | if (! blqFileName.isEmpty()) {
|
---|
139 | QFileInfo fileInfo(blqFileName);
|
---|
140 | blqFileBaseName = fileInfo.baseName();
|
---|
141 | blqFileExtension = fileInfo.completeSuffix();
|
---|
142 | if (!blqFileExtension.isEmpty()) {
|
---|
143 | blqFileExtension = "." + blqFileExtension;
|
---|
144 | }
|
---|
145 | }
|
---|
146 | bool eleWeighting = false;
|
---|
147 | if (settings.value("PPP/eleWgtCode").toInt() > 0 ||
|
---|
148 | settings.value("PPP/eleWgtCode").toInt() > 0 ) {
|
---|
149 | eleWeighting = true;
|
---|
150 | }
|
---|
151 |
|
---|
152 | _out << "+TROP/DESCRIPTION" << endl;
|
---|
153 | _out << "*KEYWORD______________________ VALUE(S)______________" << endl;
|
---|
154 | _out << " TROPO SAMPLING INTERVAL " << left << setw(22) << _sampl << endl;
|
---|
155 | _out << " DATA SAMPLING INTERVAL " << left << setw(22) << 1 << endl;
|
---|
156 | _out << " ELEVATION CUTOFF ANGLE " << left << setw(22) << int(_opt->_minEle * 180.0/M_PI) << endl;
|
---|
157 | _out << " OBSERVATION WEIGHTING " << ((eleWeighting) ? "SINEL" : "") << endl;
|
---|
158 | _out << " GNSS SYSTEMS " << systems.toStdString() << endl;
|
---|
159 | _out << " TIME SYSTEM " << "G" << endl;
|
---|
160 | _out << " TROPO MODELING METHOD " << "KALMAN FILTER" << endl;
|
---|
161 | if (! blqFileName.isEmpty()) {
|
---|
162 | _out << " OCEAN TIDE LOADING MODEL " << blqFileBaseName.toStdString() + blqFileExtension.toStdString() << endl;
|
---|
163 | }
|
---|
164 | _out << " TROP MAPPING FUNCTION " << "Saastamoinen" << endl;
|
---|
165 | _out << " TROPO PARAMETER NAMES " << "TROTOT STDEV" << endl;
|
---|
166 | _out << " TROPO PARAMETER UNITS " << "1e+03 1e+03" << endl;
|
---|
167 | _out << "-TROP/DESCRIPTION"<< endl;
|
---|
168 | _out << "*-------------------------------------------------------------------------------" << endl;
|
---|
169 |
|
---|
170 | double recEll[3];
|
---|
171 | int lonD, lonM, latD, latM;
|
---|
172 | double lonS, latS;
|
---|
173 | xyz2ell(_opt->_xyzAprRover.data(), recEll);
|
---|
174 | deg2DMS(recEll[0] * 180.0 / M_PI, latD, latM, latS);
|
---|
175 | deg2DMS(recEll[1] * 180.0 / M_PI, lonD, lonM, lonS);
|
---|
176 | QString country;
|
---|
177 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
178 | while (it.hasNext()) {
|
---|
179 | QStringList hlp = it.next().split(" ");
|
---|
180 | if (hlp.size() < 7)
|
---|
181 | continue;
|
---|
182 | if (hlp.join(" ").indexOf(QString::fromStdString(_opt->_roverName), 0) != -1) {
|
---|
183 | country = hlp[2];
|
---|
184 | }
|
---|
185 | }
|
---|
186 | _out << "+SITE/ID" << endl;
|
---|
187 | _out << "*STATION__ PT __DOMES__ T _STATION_DESCRIPTION__ _LONGITUDE _LATITUDE_ _HGT_ELI_" << endl;
|
---|
188 | _out << " " << _opt->_roverName.substr(0,9) << " A P "
|
---|
189 | << country.toStdString() << " "
|
---|
190 | << QString(" %1").arg(recEll[0]* 180.0 / M_PI,10, 'f', 6, QLatin1Char(' ')).toStdString()
|
---|
191 | << QString(" %1").arg(recEll[1]* 180.0 / M_PI,10, 'f', 6, QLatin1Char(' ')).toStdString()
|
---|
192 | << QString(" %1").arg(recEll[2], 9, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
193 | << endl;
|
---|
194 | _out << "-SITE/ID" << endl;
|
---|
195 | _out << "*-------------------------------------------------------------------------------" << endl;
|
---|
196 |
|
---|
197 | _out << "+TROP/COORDINATES" << endl;
|
---|
198 | _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ __STA_X_____ __STA_Y_____ __STA_Z_____ SYSTEM REMRK" << endl;
|
---|
199 | _out << " " << _opt->_roverName.substr(0,9) << " A "
|
---|
200 | << QString("%1").arg(solId, 4, QLatin1Char(' ')).toStdString() << " P "
|
---|
201 | << startTime.toStdString() << " " << endTime.toStdString()
|
---|
202 | << QString(" %1").arg(_opt->_xyzAprRover(1), 12, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
203 | << QString(" %1").arg(_opt->_xyzAprRover(2), 12, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
204 | << QString(" %1").arg(_opt->_xyzAprRover(3), 12, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
205 | << QString(" %1").arg("IGS20", 6, QLatin1Char(' ')).toStdString()
|
---|
206 | << QString(" %1").arg(ac, 5, QLatin1Char(' ')).toStdString() << endl;
|
---|
207 | _out << "-TROP/COORDINATES"<< endl;
|
---|
208 | _out << "*-------------------------------------------------------------------------------" << endl;
|
---|
209 |
|
---|
210 |
|
---|
211 | _out << "+SITE/ECCENTRICITY" << endl;
|
---|
212 | _out << "* UP______ NORTH___ EAST____" << endl;
|
---|
213 | _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ AXE MARKER->ARP(m)__________" << endl;
|
---|
214 | _out << " " << _opt->_roverName.substr(0,9) << " A "
|
---|
215 | << QString("%1").arg(solId, 4, QLatin1Char(' ')).toStdString() << " P "
|
---|
216 | << startTime.toStdString() << " " << endTime.toStdString()
|
---|
217 | << QString(" %1").arg("UNE", 3, QLatin1Char(' ')).toStdString()
|
---|
218 | << QString("%1").arg(_opt->_neuEccRover(3), 8, 'f', 4, QLatin1Char(' ')).toStdString()
|
---|
219 | << QString("%1").arg(_opt->_neuEccRover(1), 8, 'f', 4, QLatin1Char(' ')).toStdString()
|
---|
220 | << QString("%1").arg(_opt->_neuEccRover(2), 8, 'f', 4, QLatin1Char(' ')).toStdString() << endl;
|
---|
221 | _out << "-SITE/ECCENTRICITY" << endl;
|
---|
222 | _out << "*-------------------------------------------------------------------------------" << endl;
|
---|
223 |
|
---|
224 | if (!_opt->_recNameRover.empty()) {
|
---|
225 | _out << "+SITE/RECEIVER" << endl;
|
---|
226 | _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ DESCRIPTION_________ S/N_________________ FIRMW______" << endl;
|
---|
227 | _out << " " << _opt->_roverName.substr(0,9) << " A "
|
---|
228 | << QString("%1").arg(solId, 4, QLatin1Char(' ')).toStdString() << " P "
|
---|
229 | << startTime.toStdString() << " " << endTime.toStdString() << " "
|
---|
230 | << left << std::setw(20) << _opt->_recNameRover
|
---|
231 | << " --------------------" << " -----------" << endl;
|
---|
232 | _out << "-SITE/RECEIVER" << endl;
|
---|
233 | _out << "*-------------------------------------------------------------------------------" << endl;
|
---|
234 | }
|
---|
235 | if (!_opt->_antexFileName.empty()) {
|
---|
236 | _antex = new bncAntex(_opt->_antexFileName.c_str());
|
---|
237 | _out << "+SITE/ANTENNA" << endl;
|
---|
238 | _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ DESCRIPTION_________ S/N_________________ PCV_MODEL_" << endl;
|
---|
239 | _out << " " << _opt->_roverName.substr(0,9) << " A "
|
---|
240 | << QString("%1").arg(solId, 4, QLatin1Char(' ')).toStdString() << " P "
|
---|
241 | << startTime.toStdString() << " " << endTime.toStdString()
|
---|
242 | << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
243 | << " --------------------" << _antex->snxCodeSinexString(_opt->_antNameRover).toStdString() << endl;
|
---|
244 | _out << "-SITE/ANTENNA" << endl;
|
---|
245 | _out << "*-------------------------------------------------------------------------------" << endl;
|
---|
246 | delete _antex;
|
---|
247 | _antex = 0;
|
---|
248 | }
|
---|
249 | _out << "+TROP/SOLUTION" << endl;
|
---|
250 | _out << "*STATION__ ____EPOCH_____ TROTOT STDDEV " << endl;
|
---|
251 | }
|
---|
252 |
|
---|
253 | // Write One Epoch
|
---|
254 | ////////////////////////////////////////////////////////////////////////////
|
---|
255 | t_irc bncSinexTro::write(QByteArray staID, int GPSWeek, double GPSWeeks,
|
---|
256 | double trotot, double stdev) {
|
---|
257 |
|
---|
258 | QDateTime datTim = dateAndTimeFromGPSweek(GPSWeek, GPSWeeks);
|
---|
259 | int daysec = int(fmod(GPSWeeks, 86400.0));
|
---|
260 | int dayOfYear = datTim.date().dayOfYear();
|
---|
261 | QString yyyy = datTim.toString("yyyy");
|
---|
262 | QString time = QString("%1:%2:%3").arg(yyyy)
|
---|
263 | .arg(dayOfYear, 3, 10, QLatin1Char('0'))
|
---|
264 | .arg(daysec , 5, 10, QLatin1Char('0'));
|
---|
265 |
|
---|
266 | if ((reopen(GPSWeek, GPSWeeks) == success) &&
|
---|
267 | (fmod(daysec, double(_sampl)) == 0.0)) {
|
---|
268 | _out << ' ' << staID.left(9).data() << ' ' << time.toStdString()
|
---|
269 | << QString(" %1").arg(trotot * 1000.0, 6, 'f', 1, QLatin1Char(' ')).toStdString()
|
---|
270 | << QString(" %1").arg(stdev * 1000.0, 6, 'f', 1, QLatin1Char(' ')).toStdString() << endl;
|
---|
271 | _out.flush();
|
---|
272 | return success;
|
---|
273 | } else {
|
---|
274 | return failure;
|
---|
275 | }
|
---|
276 | }
|
---|
277 |
|
---|
278 | // Close File (write last lines)
|
---|
279 | ////////////////////////////////////////////////////////////////////////////
|
---|
280 | void bncSinexTro::closeFile() {
|
---|
281 | _out << "-TROP/SOLUTION" << endl;
|
---|
282 | _out << "%=ENDTROP" << endl;
|
---|
283 | bncoutf::closeFile();
|
---|
284 | }
|
---|
285 |
|
---|
286 |
|
---|
287 |
|
---|
288 |
|
---|