[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 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
[2890] | 42 | #include <newmatio.h>
|
---|
[2880] | 43 |
|
---|
| 44 | #include "bncantex.h"
|
---|
[5802] | 45 | #include "PPP/pppModel.h"
|
---|
[2880] | 46 |
|
---|
[5805] | 47 | using namespace BNC;
|
---|
[2880] | 48 | using namespace std;
|
---|
| 49 |
|
---|
| 50 | // Constructor
|
---|
| 51 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 52 | bncAntex::bncAntex() {
|
---|
| 53 | }
|
---|
| 54 |
|
---|
[5754] | 55 | // Constructor
|
---|
| 56 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 57 | bncAntex::bncAntex(const char* fileName) {
|
---|
| 58 | readFile(QString(fileName));
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[2880] | 61 | // Destructor
|
---|
| 62 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 63 | bncAntex::~bncAntex() {
|
---|
[2882] | 64 | QMapIterator<QString, t_antMap*> it(_maps);
|
---|
| 65 | while (it.hasNext()) {
|
---|
| 66 | it.next();
|
---|
| 67 | delete it.value();
|
---|
| 68 | }
|
---|
[2880] | 69 | }
|
---|
| 70 |
|
---|
[2894] | 71 | // Print
|
---|
[2880] | 72 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2887] | 73 | void 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;
|
---|
[2890] | 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;
|
---|
[2887] | 93 | }
|
---|
| 94 | }
|
---|
| 95 |
|
---|
[2894] | 96 | // Read ANTEX File
|
---|
[2887] | 97 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2882] | 98 | t_irc bncAntex::readFile(const QString& fileName) {
|
---|
[2880] | 99 |
|
---|
[2881] | 100 | QFile inFile(fileName);
|
---|
| 101 | inFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
---|
| 102 |
|
---|
| 103 | QTextStream in(&inFile);
|
---|
| 104 |
|
---|
[2888] | 105 | t_antMap* newAntMap = 0;
|
---|
| 106 | t_frqMap* newFrqMap = 0;
|
---|
| 107 |
|
---|
[2881] | 108 | while ( !in.atEnd() ) {
|
---|
| 109 | QString line = in.readLine();
|
---|
[2882] | 110 |
|
---|
[2883] | 111 | // Start of Antenna
|
---|
| 112 | // ----------------
|
---|
[2882] | 113 | if (line.indexOf("START OF ANTENNA") == 60) {
|
---|
[2883] | 114 | if (newAntMap) {
|
---|
| 115 | delete newAntMap;
|
---|
[2882] | 116 | return failure;
|
---|
| 117 | }
|
---|
| 118 | else {
|
---|
[3295] | 119 | delete newAntMap;
|
---|
[2883] | 120 | newAntMap = new t_antMap();
|
---|
[2882] | 121 | }
|
---|
| 122 | }
|
---|
[2881] | 123 |
|
---|
[2883] | 124 | // End of Antenna
|
---|
| 125 | // --------------
|
---|
[2882] | 126 | else if (line.indexOf("END OF ANTENNA") == 60) {
|
---|
[2883] | 127 | if (newAntMap) {
|
---|
[3542] | 128 | if (_maps.contains(newAntMap->antName)) {
|
---|
| 129 | delete _maps[newAntMap->antName];
|
---|
| 130 | }
|
---|
[2883] | 131 | _maps[newAntMap->antName] = newAntMap;
|
---|
| 132 | newAntMap = 0;
|
---|
[2882] | 133 | }
|
---|
| 134 | else {
|
---|
[3295] | 135 | delete newAntMap;
|
---|
[2882] | 136 | return failure;
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
[2883] | 139 |
|
---|
| 140 | // Antenna Reading in Progress
|
---|
| 141 | // ---------------------------
|
---|
| 142 | else if (newAntMap) {
|
---|
| 143 | if (line.indexOf("TYPE / SERIAL NO") == 60) {
|
---|
[2889] | 144 | if (line.indexOf("BLOCK I") == 0 ||
|
---|
[2884] | 145 | line.indexOf("GLONASS") == 0) {
|
---|
| 146 | newAntMap->antName = line.mid(20,3);
|
---|
| 147 | }
|
---|
| 148 | else {
|
---|
| 149 | newAntMap->antName = line.mid(0,20);
|
---|
| 150 | }
|
---|
[2883] | 151 | }
|
---|
| 152 | else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
|
---|
[2884] | 153 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
| 154 | inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
|
---|
[2883] | 155 | }
|
---|
| 156 |
|
---|
[2885] | 157 | // Start of Frequency
|
---|
| 158 | // ------------------
|
---|
[2883] | 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 |
|
---|
[2885] | 170 | // End of Frequency
|
---|
| 171 | // ----------------
|
---|
[2888] | 172 | else if (line.indexOf("END OF FREQUENCY") == 60) {
|
---|
[2883] | 173 | if (newFrqMap) {
|
---|
[2891] | 174 | if (line.indexOf("G01") == 3 || line.indexOf("R01") == 3) {
|
---|
[3550] | 175 | delete newAntMap->frqMapL1;
|
---|
[2883] | 176 | newAntMap->frqMapL1 = newFrqMap;
|
---|
| 177 | }
|
---|
[2891] | 178 | else if (line.indexOf("G02") == 3 || line.indexOf("R02") == 3) {
|
---|
[3550] | 179 | delete newAntMap->frqMapL2;
|
---|
[2883] | 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 |
|
---|
[2885] | 193 | // Frequency Reading in Progress
|
---|
| 194 | // -----------------------------
|
---|
[2883] | 195 | else if (newFrqMap) {
|
---|
[2891] | 196 | if (line.indexOf("NORTH / EAST / UP") == 60) {
|
---|
[2885] | 197 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
| 198 | inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
|
---|
[2894] | 199 | newFrqMap->neu[0] *= 1e-3;
|
---|
| 200 | newFrqMap->neu[1] *= 1e-3;
|
---|
| 201 | newFrqMap->neu[2] *= 1e-3;
|
---|
[2883] | 202 | }
|
---|
[2884] | 203 | else if (line.indexOf("NOAZI") == 3) {
|
---|
[2885] | 204 | QTextStream inLine(&line, QIODevice::ReadOnly);
|
---|
[2886] | 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 | }
|
---|
[2894] | 212 | newFrqMap->pattern *= 1e-3;
|
---|
[2884] | 213 | }
|
---|
[2883] | 214 | }
|
---|
| 215 | }
|
---|
[2881] | 216 | }
|
---|
[2882] | 217 |
|
---|
[3034] | 218 | delete newFrqMap;
|
---|
| 219 | delete newAntMap;
|
---|
| 220 |
|
---|
[2882] | 221 | return success;
|
---|
[2880] | 222 | }
|
---|
[2894] | 223 |
|
---|
[3052] | 224 | // Satellite Antenna Offset
|
---|
| 225 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3055] | 226 | t_irc bncAntex::satCoMcorrection(const QString& prn, double Mjd,
|
---|
| 227 | const ColumnVector& xSat, ColumnVector& dx) {
|
---|
| 228 |
|
---|
[3052] | 229 | QMap<QString, t_antMap*>::const_iterator it = _maps.find(prn);
|
---|
| 230 | if (it != _maps.end()) {
|
---|
| 231 | t_antMap* map = it.value();
|
---|
[3055] | 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 |
|
---|
[5802] | 239 | ColumnVector xSun = t_astro::Sun(Mjd);
|
---|
[3055] | 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 |
|
---|
[3052] | 251 | return success;
|
---|
| 252 | }
|
---|
| 253 | else {
|
---|
| 254 | return failure;
|
---|
| 255 | }
|
---|
| 256 | }
|
---|
| 257 |
|
---|
[2894] | 258 | // Phase Center Offset (Receiver Antenna and GPS only)
|
---|
| 259 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5755] | 260 | double bncAntex::pco(const QString& antName, double eleSat, bool& found) const {
|
---|
[2894] | 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()) {
|
---|
[2938] | 269 | found = true;
|
---|
[2894] | 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 | }
|
---|
[2938] | 277 | else {
|
---|
| 278 | found = false;
|
---|
| 279 | }
|
---|
[2894] | 280 |
|
---|
| 281 | return 0.0;
|
---|
| 282 | }
|
---|
[5755] | 283 |
|
---|
| 284 | //
|
---|
| 285 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 286 | double 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 | }
|
---|