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

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