[2880] | 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 | *
|
---|
[7521] | 37 | * Changes:
|
---|
[2880] | 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
[2890] | 42 | #include <newmatio.h>
|
---|
[2880] | 43 |
|
---|
| 44 | #include "bncantex.h"
|
---|
[6041] | 45 | #include "pppModel.h"
|
---|
[2880] | 46 |
|
---|
| 47 | using namespace std;
|
---|
| 48 |
|
---|
| 49 | // Constructor
|
---|
| 50 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 51 | bncAntex::bncAntex() {
|
---|
| 52 | }
|
---|
| 53 |
|
---|
[5754] | 54 | // Constructor
|
---|
| 55 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 56 | bncAntex::bncAntex(const char* fileName) {
|
---|
| 57 | readFile(QString(fileName));
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[2880] | 60 | // Destructor
|
---|
| 61 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 62 | bncAntex::~bncAntex() {
|
---|
[2882] | 63 | QMapIterator<QString, t_antMap*> it(_maps);
|
---|
| 64 | while (it.hasNext()) {
|
---|
| 65 | it.next();
|
---|
| 66 | delete it.value();
|
---|
| 67 | }
|
---|
[8076] | 68 | if (newAntMap) {
|
---|
| 69 | delete newAntMap;
|
---|
| 70 | }
|
---|
| 71 | if (newFrqMap) {
|
---|
| 72 | delete newFrqMap;
|
---|
| 73 | }
|
---|
[2880] | 74 | }
|
---|
| 75 |
|
---|
[7521] | 76 | // Print
|
---|
[2880] | 77 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2887] | 78 | void bncAntex::print() const {
|
---|
[6405] | 79 | QMapIterator<QString, t_antMap*> itAnt(_maps);
|
---|
| 80 | while (itAnt.hasNext()) {
|
---|
| 81 | itAnt.next();
|
---|
| 82 | t_antMap* map = itAnt.value();
|
---|
[2887] | 83 | cout << map->antName.toAscii().data() << endl;
|
---|
[2890] | 84 | cout << " " << map->zen1 << " " << map->zen2 << " " << map->dZen << endl;
|
---|
[6405] | 85 | QMapIterator<t_frequency::type, t_frqMap*> itFrq(map->frqMap);
|
---|
| 86 | while (itFrq.hasNext()) {
|
---|
| 87 | itFrq.next();
|
---|
| 88 | const t_frqMap* frqMap = itFrq.value();
|
---|
| 89 | cout << " " << frqMap->neu[0] << " "
|
---|
| 90 | << frqMap->neu[1] << " "
|
---|
| 91 | << frqMap->neu[2] << endl;
|
---|
| 92 | cout << " " << frqMap->pattern.t();
|
---|
[2890] | 93 | }
|
---|
| 94 | cout << endl;
|
---|
[2887] | 95 | }
|
---|
| 96 | }
|
---|
| 97 |
|
---|
[7521] | 98 | // Print
|
---|
| 99 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 100 | QString bncAntex::pcoSinexString(const std::string& antName, t_frequency::type frqType) {
|
---|
| 101 |
|
---|
| 102 | if (antName.find("NULLANTENNA") != string::npos) {
|
---|
[7848] | 103 | return QString(" ------ ------ ------");
|
---|
[7521] | 104 | }
|
---|
| 105 |
|
---|
| 106 | QString antNameQ = antName.c_str();
|
---|
| 107 | if (_maps.find(antNameQ) == _maps.end()) {
|
---|
[7848] | 108 | return QString(" ------ ------ ------");
|
---|
[7521] | 109 | }
|
---|
| 110 |
|
---|
| 111 | t_antMap* map = _maps[antNameQ];
|
---|
| 112 | if (map->frqMap.find(frqType) == map->frqMap.end()) {
|
---|
[7848] | 113 | return QString(" ------ ------ ------");
|
---|
[7521] | 114 | }
|
---|
| 115 |
|
---|
| 116 | t_frqMap* frqMap = map->frqMap[frqType];
|
---|
| 117 |
|
---|
[7848] | 118 | QString u, n,e;
|
---|
| 119 | u.sprintf("%+6.4f" ,frqMap->neu[2]); if (u.mid(1,1) == "0") {u.remove(1,1);}
|
---|
| 120 | n.sprintf("%+6.4f" ,frqMap->neu[0]); if (n.mid(1,1) == "0") {n.remove(1,1);}
|
---|
| 121 | e.sprintf("%+6.4f" ,frqMap->neu[1]); if (e.mid(1,1) == "0") {e.remove(1,1);}
|
---|
| 122 |
|
---|
| 123 | return QString(" %1 %2 %3").arg(u).arg(n).arg(e);
|
---|
[7521] | 124 | }
|
---|
| 125 |
|
---|
[2894] | 126 | // Read ANTEX File
|
---|
[2887] | 127 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2882] | 128 | t_irc bncAntex::readFile(const QString& fileName) {
|
---|
[2880] | 129 |
|
---|
[2881] | 130 | QFile inFile(fileName);
|
---|
| 131 | inFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
---|
| 132 |
|
---|
| 133 | QTextStream in(&inFile);
|
---|
| 134 |
|
---|
[8076] | 135 | newAntMap = 0;
|
---|
| 136 | newFrqMap = 0;
|
---|
[2888] | 137 |
|
---|
[2881] | 138 | while ( !in.atEnd() ) {
|
---|
| 139 | QString line = in.readLine();
|
---|
[7521] | 140 |
|
---|
[2883] | 141 | // Start of Antenna
|
---|
| 142 | // ----------------
|
---|
[2882] | 143 | if (line.indexOf("START OF ANTENNA") == 60) {
|
---|
[2883] | 144 | if (newAntMap) {
|
---|
| 145 | delete newAntMap;
|
---|
[2882] | 146 | return failure;
|
---|
| 147 | }
|
---|
| 148 | else {
|
---|
[3295] | 149 | delete newAntMap;
|
---|
[2883] | 150 | newAntMap = new t_antMap();
|
---|
[2882] | 151 | }
|
---|
[7521] | 152 | }
|
---|
[2881] | 153 |
|
---|
[2883] | 154 | // End of Antenna
|
---|
| 155 | // --------------
|
---|
[2882] | 156 | else if (line.indexOf("END OF ANTENNA") == 60) {
|
---|
[2883] | 157 | if (newAntMap) {
|
---|
[3542] | 158 | if (_maps.contains(newAntMap->antName)) {
|
---|
| 159 | delete _maps[newAntMap->antName];
|
---|
| 160 | }
|
---|
[2883] | 161 | _maps[newAntMap->antName] = newAntMap;
|
---|
| 162 | newAntMap = 0;
|
---|
[2882] | 163 | }
|
---|
| 164 | else {
|
---|
[3295] | 165 | delete newAntMap;
|
---|
[2882] | 166 | return failure;
|
---|
| 167 | }
|
---|
| 168 | }
|
---|
[2883] | 169 |
|
---|
| 170 | // Antenna Reading in Progress
|
---|
| 171 | // ---------------------------
|
---|
| 172 | else if (newAntMap) {
|
---|
| 173 | if (line.indexOf("TYPE / SERIAL NO") == 60) {
|
---|
[2889] | 174 | if (line.indexOf("BLOCK I") == 0 ||
|
---|
[7141] | 175 | line.indexOf("GLONASS") == 0 ||
|
---|
| 176 | line.indexOf("QZSS") == 0 ||
|
---|
| 177 | line.indexOf("BEIDOU") == 0 ||
|
---|
| 178 | line.indexOf("GALILEO") == 0 ||
|
---|
| 179 | line.indexOf("IRNSS") == 0 ){
|
---|
[2884] | 180 | newAntMap->antName = line.mid(20,3);
|
---|
| 181 | }
|
---|
| 182 | else {
|
---|
| 183 | newAntMap->antName = line.mid(0,20);
|
---|
| 184 | }
|
---|
[2883] | 185 | }
|
---|
| 186 | else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
|
---|
[2884] | 187 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
[7521] | 188 | inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
|
---|
[2883] | 189 | }
|
---|
| 190 |
|
---|
[2885] | 191 | // Start of Frequency
|
---|
| 192 | // ------------------
|
---|
[2883] | 193 | else if (line.indexOf("START OF FREQUENCY") == 60) {
|
---|
| 194 | if (newFrqMap) {
|
---|
| 195 | delete newFrqMap;
|
---|
| 196 | delete newAntMap;
|
---|
| 197 | return failure;
|
---|
| 198 | }
|
---|
| 199 | else {
|
---|
| 200 | newFrqMap = new t_frqMap();
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
| 203 |
|
---|
[2885] | 204 | // End of Frequency
|
---|
| 205 | // ----------------
|
---|
[2888] | 206 | else if (line.indexOf("END OF FREQUENCY") == 60) {
|
---|
[2883] | 207 | if (newFrqMap) {
|
---|
[6405] | 208 | t_frequency::type frqType = t_frequency::dummy;
|
---|
| 209 | if (line.indexOf("G01") == 3) {
|
---|
| 210 | frqType = t_frequency::G1;
|
---|
[2883] | 211 | }
|
---|
[6405] | 212 | else if (line.indexOf("G02") == 3) {
|
---|
| 213 | frqType = t_frequency::G2;
|
---|
[2883] | 214 | }
|
---|
[6405] | 215 | else if (line.indexOf("R01") == 3) {
|
---|
| 216 | frqType = t_frequency::R1;
|
---|
| 217 | }
|
---|
| 218 | else if (line.indexOf("R02") == 3) {
|
---|
| 219 | frqType = t_frequency::R2;
|
---|
| 220 | }
|
---|
[7144] | 221 | else if (line.indexOf("E01") == 3) {
|
---|
| 222 | frqType = t_frequency::E1;
|
---|
| 223 | }
|
---|
| 224 | else if (line.indexOf("E05") == 3) {
|
---|
| 225 | frqType = t_frequency::E5;
|
---|
| 226 | }
|
---|
| 227 | else if (line.indexOf("E06") == 3) {
|
---|
| 228 | frqType = t_frequency::E6;
|
---|
| 229 | }
|
---|
| 230 | else if (line.indexOf("E07") == 3) {
|
---|
| 231 | frqType = t_frequency::E7;
|
---|
| 232 | }
|
---|
| 233 | else if (line.indexOf("E08") == 3) {
|
---|
| 234 | frqType = t_frequency::E8;
|
---|
| 235 | }
|
---|
[7145] | 236 | else if (line.indexOf("J01") == 3) {
|
---|
| 237 | frqType = t_frequency::J1;
|
---|
| 238 | }
|
---|
| 239 | else if (line.indexOf("J02") == 3) {
|
---|
| 240 | frqType = t_frequency::J2;
|
---|
| 241 | }
|
---|
| 242 | else if (line.indexOf("J05") == 3) {
|
---|
| 243 | frqType = t_frequency::J5;
|
---|
| 244 | }
|
---|
| 245 | else if (line.indexOf("J06") == 3) {
|
---|
| 246 | frqType = t_frequency::J6;
|
---|
| 247 | }
|
---|
[7144] | 248 | else if (line.indexOf("C02") == 3) {
|
---|
| 249 | frqType = t_frequency::C2;
|
---|
| 250 | }
|
---|
| 251 | else if (line.indexOf("C06") == 3) {
|
---|
| 252 | frqType = t_frequency::C6;
|
---|
| 253 | }
|
---|
| 254 | else if (line.indexOf("C07") == 3) {
|
---|
| 255 | frqType = t_frequency::C7;
|
---|
| 256 | }
|
---|
[6405] | 257 | if (frqType != t_frequency::dummy) {
|
---|
| 258 | if (newAntMap->frqMap.find(frqType) != newAntMap->frqMap.end()) {
|
---|
| 259 | delete newAntMap->frqMap[frqType];
|
---|
| 260 | }
|
---|
| 261 | newAntMap->frqMap[frqType] = newFrqMap;
|
---|
| 262 | }
|
---|
[2883] | 263 | else {
|
---|
| 264 | delete newFrqMap;
|
---|
| 265 | }
|
---|
| 266 | newFrqMap = 0;
|
---|
| 267 | }
|
---|
| 268 | else {
|
---|
| 269 | delete newAntMap;
|
---|
| 270 | return failure;
|
---|
| 271 | }
|
---|
| 272 | }
|
---|
| 273 |
|
---|
[2885] | 274 | // Frequency Reading in Progress
|
---|
| 275 | // -----------------------------
|
---|
[2883] | 276 | else if (newFrqMap) {
|
---|
[2891] | 277 | if (line.indexOf("NORTH / EAST / UP") == 60) {
|
---|
[2885] | 278 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
| 279 | inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
|
---|
[2894] | 280 | newFrqMap->neu[0] *= 1e-3;
|
---|
| 281 | newFrqMap->neu[1] *= 1e-3;
|
---|
| 282 | newFrqMap->neu[2] *= 1e-3;
|
---|
[2883] | 283 | }
|
---|
[2884] | 284 | else if (line.indexOf("NOAZI") == 3) {
|
---|
[2885] | 285 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
[2886] | 286 | int nPat = int((newAntMap->zen2-newAntMap->zen1)/newAntMap->dZen) + 1;
|
---|
| 287 | newFrqMap->pattern.ReSize(nPat);
|
---|
| 288 | QString dummy;
|
---|
| 289 | inLine >> dummy;
|
---|
| 290 | for (int ii = 0; ii < nPat; ii++) {
|
---|
| 291 | inLine >> newFrqMap->pattern[ii];
|
---|
| 292 | }
|
---|
[2894] | 293 | newFrqMap->pattern *= 1e-3;
|
---|
[2884] | 294 | }
|
---|
[2883] | 295 | }
|
---|
| 296 | }
|
---|
[2881] | 297 | }
|
---|
[7865] | 298 | inFile.close();
|
---|
[3034] | 299 | delete newFrqMap;
|
---|
| 300 | delete newAntMap;
|
---|
| 301 |
|
---|
[2882] | 302 | return success;
|
---|
[2880] | 303 | }
|
---|
[2894] | 304 |
|
---|
[3052] | 305 | // Satellite Antenna Offset
|
---|
| 306 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7521] | 307 | t_irc bncAntex::satCoMcorrection(const QString& prn, double Mjd,
|
---|
[3055] | 308 | const ColumnVector& xSat, ColumnVector& dx) {
|
---|
| 309 |
|
---|
[6405] | 310 | t_frequency::type frqType = t_frequency::dummy;
|
---|
[7145] | 311 |
|
---|
[6405] | 312 | if (prn[0] == 'G') {
|
---|
| 313 | frqType = t_frequency::G1;
|
---|
| 314 | }
|
---|
| 315 | else if (prn[0] == 'R') {
|
---|
| 316 | frqType = t_frequency::R1;
|
---|
| 317 | }
|
---|
| 318 |
|
---|
[6971] | 319 | QMap<QString, t_antMap*>::const_iterator it = _maps.find(prn.mid(0,3));
|
---|
[3052] | 320 | if (it != _maps.end()) {
|
---|
| 321 | t_antMap* map = it.value();
|
---|
[6405] | 322 | if (map->frqMap.find(frqType) != map->frqMap.end()) {
|
---|
[3055] | 323 |
|
---|
[6405] | 324 | double* neu = map->frqMap[frqType]->neu;
|
---|
[3055] | 325 |
|
---|
[6405] | 326 | // Unit Vectors sz, sy, sx
|
---|
| 327 | // -----------------------
|
---|
| 328 | ColumnVector sz = -xSat;
|
---|
| 329 | sz /= sqrt(DotProduct(sz,sz));
|
---|
| 330 |
|
---|
| 331 | ColumnVector xSun = BNC_PPP::t_astro::Sun(Mjd);
|
---|
| 332 | xSun /= sqrt(DotProduct(xSun,xSun));
|
---|
[7521] | 333 |
|
---|
[6405] | 334 | ColumnVector sy = crossproduct(sz, xSun);
|
---|
| 335 | sy /= sqrt(DotProduct(sy,sy));
|
---|
[7521] | 336 |
|
---|
[6405] | 337 | ColumnVector sx = crossproduct(sy, sz);
|
---|
[3055] | 338 |
|
---|
[6405] | 339 | dx[0] = sx[0] * neu[0] + sy[0] * neu[1] + sz[0] * neu[2];
|
---|
| 340 | dx[1] = sx[1] * neu[0] + sy[1] * neu[1] + sz[1] * neu[2];
|
---|
| 341 | dx[2] = sx[2] * neu[0] + sy[2] * neu[1] + sz[2] * neu[2];
|
---|
[3055] | 342 |
|
---|
[6405] | 343 | return success;
|
---|
| 344 | }
|
---|
[3052] | 345 | }
|
---|
[6405] | 346 |
|
---|
| 347 | return failure;
|
---|
[3052] | 348 | }
|
---|
| 349 |
|
---|
[7521] | 350 | //
|
---|
[2894] | 351 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6405] | 352 | double bncAntex::rcvCorr(const string& antName, t_frequency::type frqType,
|
---|
[6694] | 353 | double eleSat, double azSat, bool& found) const {
|
---|
[2894] | 354 |
|
---|
[6405] | 355 | if (antName.find("NULLANTENNA") != string::npos) {
|
---|
[2938] | 356 | found = true;
|
---|
[6405] | 357 | return 0.0;
|
---|
[2894] | 358 | }
|
---|
[6405] | 359 |
|
---|
| 360 | QString antNameQ = antName.c_str();
|
---|
| 361 |
|
---|
| 362 | if (_maps.find(antNameQ) == _maps.end()) {
|
---|
[2938] | 363 | found = false;
|
---|
[6405] | 364 | return 0.0;
|
---|
[2938] | 365 | }
|
---|
[2894] | 366 |
|
---|
[6405] | 367 | t_antMap* map = _maps[antNameQ];
|
---|
| 368 | if (map->frqMap.find(frqType) == map->frqMap.end()) {
|
---|
| 369 | found = false;
|
---|
| 370 | return 0.0;
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | t_frqMap* frqMap = map->frqMap[frqType];
|
---|
| 374 |
|
---|
| 375 | double var = 0.0;
|
---|
| 376 | if (frqMap->pattern.ncols() > 0) {
|
---|
| 377 | double zenDiff = 999.999;
|
---|
| 378 | double zenSat = 90.0 - eleSat * 180.0 / M_PI;
|
---|
| 379 | unsigned iZen = 0;
|
---|
| 380 | for (double zen = map->zen1; zen <= map->zen2; zen += map->dZen) {
|
---|
| 381 | iZen += 1;
|
---|
| 382 | double newZenDiff = fabs(zen - zenSat);
|
---|
| 383 | if (newZenDiff < zenDiff) {
|
---|
| 384 | zenDiff = newZenDiff;
|
---|
| 385 | var = frqMap->pattern(iZen);
|
---|
| 386 | }
|
---|
| 387 | }
|
---|
| 388 | }
|
---|
| 389 |
|
---|
| 390 | found = true;
|
---|
[6694] | 391 | return var - frqMap->neu[0] * cos(azSat)*cos(eleSat)
|
---|
| 392 | - frqMap->neu[1] * sin(azSat)*cos(eleSat)
|
---|
| 393 | - frqMap->neu[2] * sin(eleSat);
|
---|
| 394 |
|
---|
[5755] | 395 | }
|
---|