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: bncAntex
|
---|
30 | *
|
---|
31 | * Purpose: Antenna Phase Centers and Variations from ANTEX File
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 26-Jan-2011
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <iostream>
|
---|
42 | #include <newmatio.h>
|
---|
43 |
|
---|
44 | #include "bncantex.h"
|
---|
45 | #include "bnctides.h"
|
---|
46 |
|
---|
47 | using namespace std;
|
---|
48 |
|
---|
49 | // Constructor
|
---|
50 | ////////////////////////////////////////////////////////////////////////////
|
---|
51 | bncAntex::bncAntex() {
|
---|
52 | }
|
---|
53 |
|
---|
54 | // Destructor
|
---|
55 | ////////////////////////////////////////////////////////////////////////////
|
---|
56 | bncAntex::~bncAntex() {
|
---|
57 | QMapIterator<QString, t_antMap*> it(_maps);
|
---|
58 | while (it.hasNext()) {
|
---|
59 | it.next();
|
---|
60 | delete it.value();
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | // Print
|
---|
65 | ////////////////////////////////////////////////////////////////////////////
|
---|
66 | void bncAntex::print() const {
|
---|
67 | QMapIterator<QString, t_antMap*> it(_maps);
|
---|
68 | while (it.hasNext()) {
|
---|
69 | it.next();
|
---|
70 | t_antMap* map = it.value();
|
---|
71 | cout << map->antName.toAscii().data() << endl;
|
---|
72 | cout << " " << map->zen1 << " " << map->zen2 << " " << map->dZen << endl;
|
---|
73 | if (map->frqMapL1) {
|
---|
74 | cout << " " << map->frqMapL1->neu[0] << " "
|
---|
75 | << map->frqMapL1->neu[1] << " "
|
---|
76 | << map->frqMapL1->neu[2] << endl;
|
---|
77 | cout << " " << map->frqMapL1->pattern.t();
|
---|
78 | }
|
---|
79 | if (map->frqMapL2) {
|
---|
80 | cout << " " << map->frqMapL2->neu[0] << " "
|
---|
81 | << map->frqMapL2->neu[1] << " "
|
---|
82 | << map->frqMapL2->neu[2] << endl;
|
---|
83 | cout << " " << map->frqMapL2->pattern.t();
|
---|
84 | }
|
---|
85 | cout << endl;
|
---|
86 | }
|
---|
87 | }
|
---|
88 |
|
---|
89 | // Read ANTEX File
|
---|
90 | ////////////////////////////////////////////////////////////////////////////
|
---|
91 | t_irc bncAntex::readFile(const QString& fileName) {
|
---|
92 |
|
---|
93 | QFile inFile(fileName);
|
---|
94 | inFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
---|
95 |
|
---|
96 | QTextStream in(&inFile);
|
---|
97 |
|
---|
98 | t_antMap* newAntMap = 0;
|
---|
99 | t_frqMap* newFrqMap = 0;
|
---|
100 |
|
---|
101 | while ( !in.atEnd() ) {
|
---|
102 | QString line = in.readLine();
|
---|
103 |
|
---|
104 | // Start of Antenna
|
---|
105 | // ----------------
|
---|
106 | if (line.indexOf("START OF ANTENNA") == 60) {
|
---|
107 | if (newAntMap) {
|
---|
108 | delete newAntMap;
|
---|
109 | return failure;
|
---|
110 | }
|
---|
111 | else {
|
---|
112 | delete newAntMap;
|
---|
113 | newAntMap = new t_antMap();
|
---|
114 | }
|
---|
115 | }
|
---|
116 |
|
---|
117 | // End of Antenna
|
---|
118 | // --------------
|
---|
119 | else if (line.indexOf("END OF ANTENNA") == 60) {
|
---|
120 | if (newAntMap) {
|
---|
121 | _maps[newAntMap->antName] = newAntMap;
|
---|
122 | newAntMap = 0;
|
---|
123 | }
|
---|
124 | else {
|
---|
125 | delete newAntMap;
|
---|
126 | return failure;
|
---|
127 | }
|
---|
128 | }
|
---|
129 |
|
---|
130 | // Antenna Reading in Progress
|
---|
131 | // ---------------------------
|
---|
132 | else if (newAntMap) {
|
---|
133 | if (line.indexOf("TYPE / SERIAL NO") == 60) {
|
---|
134 | if (line.indexOf("BLOCK I") == 0 ||
|
---|
135 | line.indexOf("GLONASS") == 0) {
|
---|
136 | newAntMap->antName = line.mid(20,3);
|
---|
137 | }
|
---|
138 | else {
|
---|
139 | newAntMap->antName = line.mid(0,20);
|
---|
140 | }
|
---|
141 | }
|
---|
142 | else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
|
---|
143 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
144 | inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
|
---|
145 | }
|
---|
146 |
|
---|
147 | // Start of Frequency
|
---|
148 | // ------------------
|
---|
149 | else if (line.indexOf("START OF FREQUENCY") == 60) {
|
---|
150 | if (newFrqMap) {
|
---|
151 | delete newFrqMap;
|
---|
152 | delete newAntMap;
|
---|
153 | return failure;
|
---|
154 | }
|
---|
155 | else {
|
---|
156 | newFrqMap = new t_frqMap();
|
---|
157 | }
|
---|
158 | }
|
---|
159 |
|
---|
160 | // End of Frequency
|
---|
161 | // ----------------
|
---|
162 | else if (line.indexOf("END OF FREQUENCY") == 60) {
|
---|
163 | if (newFrqMap) {
|
---|
164 | if (line.indexOf("G01") == 3 || line.indexOf("R01") == 3) {
|
---|
165 | newAntMap->frqMapL1 = newFrqMap;
|
---|
166 | }
|
---|
167 | else if (line.indexOf("G02") == 3 || line.indexOf("R02") == 3) {
|
---|
168 | newAntMap->frqMapL2 = newFrqMap;
|
---|
169 | }
|
---|
170 | else {
|
---|
171 | delete newFrqMap;
|
---|
172 | }
|
---|
173 | newFrqMap = 0;
|
---|
174 | }
|
---|
175 | else {
|
---|
176 | delete newAntMap;
|
---|
177 | return failure;
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | // Frequency Reading in Progress
|
---|
182 | // -----------------------------
|
---|
183 | else if (newFrqMap) {
|
---|
184 | if (line.indexOf("NORTH / EAST / UP") == 60) {
|
---|
185 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
186 | inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
|
---|
187 | newFrqMap->neu[0] *= 1e-3;
|
---|
188 | newFrqMap->neu[1] *= 1e-3;
|
---|
189 | newFrqMap->neu[2] *= 1e-3;
|
---|
190 | }
|
---|
191 | else if (line.indexOf("NOAZI") == 3) {
|
---|
192 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
193 | int nPat = int((newAntMap->zen2-newAntMap->zen1)/newAntMap->dZen) + 1;
|
---|
194 | newFrqMap->pattern.ReSize(nPat);
|
---|
195 | QString dummy;
|
---|
196 | inLine >> dummy;
|
---|
197 | for (int ii = 0; ii < nPat; ii++) {
|
---|
198 | inLine >> newFrqMap->pattern[ii];
|
---|
199 | }
|
---|
200 | newFrqMap->pattern *= 1e-3;
|
---|
201 | }
|
---|
202 | }
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | delete newFrqMap;
|
---|
207 | delete newAntMap;
|
---|
208 |
|
---|
209 | return success;
|
---|
210 | }
|
---|
211 |
|
---|
212 | // Satellite Antenna Offset
|
---|
213 | ////////////////////////////////////////////////////////////////////////////
|
---|
214 | t_irc bncAntex::satCoMcorrection(const QString& prn, double Mjd,
|
---|
215 | const ColumnVector& xSat, ColumnVector& dx) {
|
---|
216 |
|
---|
217 | QMap<QString, t_antMap*>::const_iterator it = _maps.find(prn);
|
---|
218 | if (it != _maps.end()) {
|
---|
219 | t_antMap* map = it.value();
|
---|
220 | double* neu = map->frqMapL1->neu;
|
---|
221 |
|
---|
222 | // Unit Vectors sz, sy, sx
|
---|
223 | // -----------------------
|
---|
224 | ColumnVector sz = -xSat;
|
---|
225 | sz /= sqrt(DotProduct(sz,sz));
|
---|
226 |
|
---|
227 | ColumnVector xSun = Sun(Mjd);
|
---|
228 | xSun /= sqrt(DotProduct(xSun,xSun));
|
---|
229 |
|
---|
230 | ColumnVector sy = crossproduct(sz, xSun);
|
---|
231 | sy /= sqrt(DotProduct(sy,sy));
|
---|
232 |
|
---|
233 | ColumnVector sx = crossproduct(sy, sz);
|
---|
234 |
|
---|
235 | dx[0] = sx[0] * neu[0] + sy[0] * neu[1] + sz[0] * neu[2];
|
---|
236 | dx[1] = sx[1] * neu[0] + sy[1] * neu[1] + sz[1] * neu[2];
|
---|
237 | dx[2] = sx[2] * neu[0] + sy[2] * neu[1] + sz[2] * neu[2];
|
---|
238 |
|
---|
239 | return success;
|
---|
240 | }
|
---|
241 | else {
|
---|
242 | return failure;
|
---|
243 | }
|
---|
244 | }
|
---|
245 |
|
---|
246 | // Phase Center Offset (Receiver Antenna and GPS only)
|
---|
247 | ////////////////////////////////////////////////////////////////////////////
|
---|
248 | double bncAntex::pco(const QString& antName, double eleSat, bool& found) {
|
---|
249 |
|
---|
250 | static const double f1 = t_CST::freq1;
|
---|
251 | static const double f2 = t_CST::freq2;
|
---|
252 | static const double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
253 | static const double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
254 |
|
---|
255 | QMap<QString, t_antMap*>::const_iterator it = _maps.find(antName);
|
---|
256 | if (it != _maps.end()) {
|
---|
257 | found = true;
|
---|
258 | t_antMap* map = it.value();
|
---|
259 | if (map->frqMapL1 && map->frqMapL2) {
|
---|
260 | double corr1 = -map->frqMapL1->neu[2] * sin(eleSat);
|
---|
261 | double corr2 = -map->frqMapL2->neu[2] * sin(eleSat);
|
---|
262 | return c1 * corr1 + c2 * corr2;
|
---|
263 | }
|
---|
264 | }
|
---|
265 | else {
|
---|
266 | found = false;
|
---|
267 | }
|
---|
268 |
|
---|
269 | return 0.0;
|
---|
270 | }
|
---|