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 = 1 : _sampl = sampl;
|
---|
35 |
|
---|
36 | if (!_opt->_antexFileName.empty()) {
|
---|
37 | _antex = new bncAntex(_opt->_antexFileName.c_str());
|
---|
38 | }
|
---|
39 | else {
|
---|
40 | _antex = 0;
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | // Destructor
|
---|
45 | ////////////////////////////////////////////////////////////////////////////
|
---|
46 | bncSinexTro::~bncSinexTro() {
|
---|
47 | closeFile();
|
---|
48 | if (_antex)
|
---|
49 | delete _antex;
|
---|
50 | }
|
---|
51 |
|
---|
52 | // Write Header
|
---|
53 | ////////////////////////////////////////////////////////////////////////////
|
---|
54 | void bncSinexTro::writeHeader(const QDateTime& datTim) {
|
---|
55 | int GPSWeek;
|
---|
56 | double GPSWeeks;
|
---|
57 | bncSettings settings;
|
---|
58 | GPSweekFromDateAndTime(datTim, GPSWeek, GPSWeeks);
|
---|
59 | int daysec = int(fmod(GPSWeeks, 86400.0));
|
---|
60 | int dayOfYear = datTim.date().dayOfYear();
|
---|
61 | QString yy = datTim.toString("yy");
|
---|
62 |
|
---|
63 | QString creationTime = QString("%1:%2:%3").arg(yy)
|
---|
64 | .arg(dayOfYear, 3, 10, QLatin1Char('0'))
|
---|
65 | .arg(daysec , 5, 10, QLatin1Char('0'));
|
---|
66 | QString startTime = creationTime;
|
---|
67 | QString endTime = QString("%1:%2:%3").arg(yy)
|
---|
68 | .arg(dayOfYear, 3, 10, QLatin1Char('0'))
|
---|
69 | .arg(84600 , 5, 10);
|
---|
70 |
|
---|
71 | QString intStr = settings.value("PPP/snxtroIntr").toString();
|
---|
72 | int intr, indHlp = 0;
|
---|
73 | if ((indHlp = intStr.indexOf("min")) != -1) {
|
---|
74 | intr = intStr.left(indHlp-1).toInt();
|
---|
75 | intr *= 60;
|
---|
76 | }
|
---|
77 | else if ((indHlp = intStr.indexOf("hour")) != -1) {
|
---|
78 | intr = intStr.left(indHlp-1).toInt();
|
---|
79 | intr *= 3600;
|
---|
80 | }
|
---|
81 | else if ((indHlp = intStr.indexOf("day")) != -1) {
|
---|
82 | intr = intStr.left(indHlp-1).toInt();
|
---|
83 | intr *= 86400;
|
---|
84 | }
|
---|
85 |
|
---|
86 |
|
---|
87 | QString numberOfEpochs = QString("%1").arg(1, 5, 10, QLatin1Char('0'));
|
---|
88 | _out << "%=TRO 2.00 BNC " << creationTime.toStdString() << " BNC "
|
---|
89 | << startTime.toStdString() << " " << endTime.toStdString() << " P "
|
---|
90 | << numberOfEpochs.toStdString() << " 0 " << " T " << endl;
|
---|
91 |
|
---|
92 |
|
---|
93 | _out << "+FILE/REFERENCE" << endl;
|
---|
94 | _out << " DESCRIPTION " << "BNC generated SINEX TRO file" << endl;
|
---|
95 | _out << " OUTPUT " << "Total Troposphere Zenith Path Delay Product" << endl;
|
---|
96 | _out << " SOFTWARE " << BNCPGMNAME << endl;
|
---|
97 | _out << " INPUT " << "Orbit and Clock information used from BRDC and RTCM-SSR streams" << endl;
|
---|
98 | _out << "-FILE/REFERENCE" << endl << endl;
|
---|
99 |
|
---|
100 |
|
---|
101 | _out << "+SITE/ID" << endl;
|
---|
102 | _out << "-SITE/ID" << endl << endl;
|
---|
103 |
|
---|
104 | if (!_opt->_recNameRover.empty()) {
|
---|
105 | _out << "+SITE/RECEIVER" << endl;
|
---|
106 | _out << "*SITE PT SOLN T DATA_START__ DATA_END____ DESCRIPTION_________ S/N__ FIRMWARE___" << endl;
|
---|
107 | _out << " " << _opt->_roverName.substr(0,4) << " A 1 P "
|
---|
108 | << startTime.toStdString() << " " << endTime.toStdString() << " " << _opt->_recNameRover << endl;
|
---|
109 | _out << "-SITE/RECEIVER" << endl << endl;
|
---|
110 | }
|
---|
111 |
|
---|
112 | _out << "+SITE/ANTENNA" << endl;
|
---|
113 | _out << "*SITE PT SOLN T DATA_START__ DATA_END____ DESCRIPTION_________ S/N__" << endl;
|
---|
114 | _out << " " << _opt->_roverName.substr(0,4) << " A 1 P "
|
---|
115 | << startTime.toStdString() << " " << endTime.toStdString() << " " << _opt->_antNameRover << endl;
|
---|
116 | _out << "-SITE/ANTENNA" << endl << endl;
|
---|
117 |
|
---|
118 | if (_antex) {
|
---|
119 | if (_opt->_LCsGPS.size()) {
|
---|
120 | _out << "+SITE/GPS_PHASE_CENTER" << endl;
|
---|
121 | _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__ " << endl;
|
---|
122 | _out << "*DESCRIPTION_________ S/N__ L1->ARP(M)__________ __L2->ARP(M)________ AZ_EL_____" << endl;
|
---|
123 | _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
124 | << " "
|
---|
125 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::G1).toStdString()
|
---|
126 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::G2).toStdString()
|
---|
127 | << endl;
|
---|
128 | _out << "-SITE/GPS_PHASE_CENTER" << endl << endl;
|
---|
129 | }
|
---|
130 | if (_opt->_LCsGLONASS.size()) {
|
---|
131 | _out << "+SITE/GLONASS_PHASE_CENTER" << endl;
|
---|
132 | _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__ " << endl;
|
---|
133 | _out << "*DESCRIPTION_________ S/N__ L1->ARP(M)__________ __L2->ARP(M)________ AZ_EL_____" << endl;
|
---|
134 | _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
135 | << " "
|
---|
136 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::R1).toStdString()
|
---|
137 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::R2).toStdString()
|
---|
138 | << endl;
|
---|
139 | _out << "-SITE/GLONASS_PHASE_CENTER" << endl << endl;
|
---|
140 | }
|
---|
141 | if (_opt->_LCsGalileo.size()) {
|
---|
142 | _out << "+SITE/GALILEO_PHASE_CENTER" << endl;
|
---|
143 | _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__ " << endl;
|
---|
144 | _out << "*DESCRIPTION_________ S/N__ L1->ARP(M)__________ __L2->ARP(M)________ AZ_EL_____" << endl;
|
---|
145 | _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
146 | << " "
|
---|
147 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::E1).toStdString()
|
---|
148 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::E5).toStdString()
|
---|
149 | << endl;
|
---|
150 | _out << "-SITE/GALILEO_PHASE_CENTER" << endl << endl;
|
---|
151 | }
|
---|
152 | if (_opt->_LCsBDS.size()) {
|
---|
153 | _out << "+SITE/BEIDOU_PHASE_CENTER" << endl;
|
---|
154 | _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__ " << endl;
|
---|
155 | _out << "*DESCRIPTION_________ S/N__ L1->ARP(M)__________ __L2->ARP(M)________ AZ_EL_____" << endl;
|
---|
156 | _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
157 | << " "
|
---|
158 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::C2).toStdString()
|
---|
159 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::C7).toStdString()
|
---|
160 | << endl;
|
---|
161 | _out << "-SITE/BEIDOU_PHASE_CENTER" << endl << endl;
|
---|
162 | }
|
---|
163 | }
|
---|
164 |
|
---|
165 | _out << "+SITE/ECCENTRICITY" << endl;
|
---|
166 | _out << "* UP______ NORTH___ EAST____" << endl;
|
---|
167 | _out << "*SITE PT SOLN T DATA_START__ DATA_END____ AXE ARP->BENCHMARK(M)_________" << endl;
|
---|
168 | _out << " " << _opt->_roverName.substr(0,4) << " A 1 P "
|
---|
169 | << startTime.toStdString() << " " << endTime.toStdString() << " " << " UNE"
|
---|
170 | << QString("%1").arg(_opt->_neuEccRover(3), 9, 'f', 4, QLatin1Char(' ')).toStdString()
|
---|
171 | << QString("%1").arg(_opt->_neuEccRover(1), 9, 'f', 4, QLatin1Char(' ')).toStdString()
|
---|
172 | << QString("%1").arg(_opt->_neuEccRover(2), 9, 'f', 4, QLatin1Char(' ')).toStdString() << endl;
|
---|
173 | _out << "-SITE/ANTENNA" << endl << endl;
|
---|
174 |
|
---|
175 |
|
---|
176 | _out << "+TROP/COORDINATES" << endl;
|
---|
177 | _out << "*SITE PT SOLN T __STA_X_____ __STA_Y_____ __STA_Z_____ SYSTEM REMRK" << endl;
|
---|
178 | _out << " " << _opt->_roverName.substr(0,4) << " A 1 P"
|
---|
179 | << QString("%1").arg(_opt->_xyzAprRover(1), 13, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
180 | << QString("%1").arg(_opt->_xyzAprRover(2), 13, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
181 | << QString("%1").arg(_opt->_xyzAprRover(3), 13, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
182 | << " ITRF08"<< endl;
|
---|
183 | _out << "-TROP/COORDINATES"<< endl << endl;
|
---|
184 |
|
---|
185 |
|
---|
186 | _out << "+TROP/DESCRIPTION" << endl;
|
---|
187 | _out << "*KEYWORD______________________ VALUE(S)______________" << endl;
|
---|
188 | _out << " SAMPLING INTERVAL "
|
---|
189 | << setw(4) << _sampl << endl;
|
---|
190 | _out << " SAMPLING TROP "
|
---|
191 | << setw(4) << _sampl << endl;
|
---|
192 | _out << " ELEVATION CUTOFF ANGLE "
|
---|
193 | << setw(4) << int(_opt->_minEle * 180.0/M_PI) << endl;
|
---|
194 | _out << " TROP MAPPING FUNCTION " << "Saastamoinen" << endl;
|
---|
195 | _out << " SOLUTION_FIELDS_1 " << "TROTOT STDEV" << endl;
|
---|
196 | _out << "-TROP/DESCRIPTION"<< endl << endl;
|
---|
197 |
|
---|
198 |
|
---|
199 | _out << "+TROP/SOLUTION" << endl;
|
---|
200 | _out << "*SITE EPOCH_______ TROTOT STDEV" << endl;
|
---|
201 | }
|
---|
202 |
|
---|
203 | // Write One Epoch
|
---|
204 | ////////////////////////////////////////////////////////////////////////////
|
---|
205 | t_irc bncSinexTro::write(QByteArray staID, int GPSWeek, double GPSWeeks,
|
---|
206 | double trotot, double stdev) {
|
---|
207 |
|
---|
208 | QDateTime datTim = dateAndTimeFromGPSweek(GPSWeek, GPSWeeks);
|
---|
209 | int daysec = int(fmod(GPSWeeks, 86400.0));
|
---|
210 | int dayOfYear = datTim.date().dayOfYear();
|
---|
211 | QString yy = datTim.toString("yy");
|
---|
212 | QString time = QString("%1:%2:%3").arg(yy)
|
---|
213 | .arg(dayOfYear, 3, 10, QLatin1Char('0'))
|
---|
214 | .arg(daysec , 5, 10, QLatin1Char('0'));
|
---|
215 |
|
---|
216 | if ((reopen(GPSWeek, GPSWeeks) == success) &&
|
---|
217 | (fmod(daysec, double(_sampl)) == 0.0)) {
|
---|
218 | _out << ' ' << staID.left(4).data() << ' ' << time.toStdString() << ' '
|
---|
219 | << noshowpos << setw(6) << setprecision(1) << trotot * 1000.0
|
---|
220 | << noshowpos << setw(6) << setprecision(1) << stdev * 1000.0 << endl;
|
---|
221 | _out.flush();
|
---|
222 | return success;
|
---|
223 | } else {
|
---|
224 | return failure;
|
---|
225 | }
|
---|
226 | }
|
---|
227 |
|
---|
228 | // Close File (write last lines)
|
---|
229 | ////////////////////////////////////////////////////////////////////////////
|
---|
230 | void bncSinexTro::closeFile() {
|
---|
231 | _out << "-TROP/SOLUTION" << endl;
|
---|
232 | _out << "%=ENDTROP" << endl;
|
---|
233 | bncoutf::closeFile();
|
---|
234 | }
|
---|
235 |
|
---|
236 |
|
---|
237 |
|
---|
238 |
|
---|