source: ntrip/trunk/BNC/src/bncantex.cpp@ 5815

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