Changeset 6405 in ntrip for trunk/BNC/src/bncantex.cpp


Ignore:
Timestamp:
Dec 22, 2014, 6:09:12 PM (9 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncantex.cpp

    r6041 r6405  
    7171////////////////////////////////////////////////////////////////////////////
    7272void bncAntex::print() const {
    73   QMapIterator<QString, t_antMap*> it(_maps);
    74   while (it.hasNext()) {
    75     it.next();
    76     t_antMap* map = it.value();
     73  QMapIterator<QString, t_antMap*> itAnt(_maps);
     74  while (itAnt.hasNext()) {
     75    itAnt.next();
     76    t_antMap* map = itAnt.value();
    7777    cout << map->antName.toAscii().data() << endl;
    7878    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();
     79    QMapIterator<t_frequency::type, t_frqMap*> itFrq(map->frqMap);
     80    while (itFrq.hasNext()) {
     81      itFrq.next();
     82      const t_frqMap* frqMap = itFrq.value();
     83      cout << "    " << frqMap->neu[0] << " "
     84                     << frqMap->neu[1] << " "
     85                     << frqMap->neu[2] << endl;
     86      cout << "    " << frqMap->pattern.t();
    9087    }
    9188    cout << endl;
     
    171168      else if (line.indexOf("END OF FREQUENCY") == 60) {
    172169        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;
     170          t_frequency::type frqType = t_frequency::dummy;
     171          if      (line.indexOf("G01") == 3) {
     172            frqType = t_frequency::G1;
     173          }
     174          else if (line.indexOf("G02") == 3) {
     175            frqType = t_frequency::G2;
     176          }
     177          else if (line.indexOf("R01") == 3) {
     178            frqType = t_frequency::R1;
     179          }
     180          else if (line.indexOf("R02") == 3) {
     181            frqType = t_frequency::R2;
     182          }
     183          if (frqType != t_frequency::dummy) {
     184            if (newAntMap->frqMap.find(frqType) != newAntMap->frqMap.end()) {
     185              delete newAntMap->frqMap[frqType];
     186            }
     187            newAntMap->frqMap[frqType] = newFrqMap;
    180188          }
    181189          else {
     
    226234                                 const ColumnVector& xSat, ColumnVector& dx) {
    227235
     236  t_frequency::type frqType = t_frequency::dummy;
     237  if      (prn[0] == 'G') {
     238    frqType = t_frequency::G1;
     239  }
     240  else if (prn[0] == 'R') {
     241    frqType = t_frequency::R1;
     242  }
     243
    228244  QMap<QString, t_antMap*>::const_iterator it = _maps.find(prn);
    229245  if (it != _maps.end()) {
    230246    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));
     247    if (map->frqMap.find(frqType) != map->frqMap.end()) {
     248
     249      double* neu = map->frqMap[frqType]->neu;
     250
     251      // Unit Vectors sz, sy, sx
     252      // -----------------------
     253      ColumnVector sz = -xSat;
     254      sz /= sqrt(DotProduct(sz,sz));
     255
     256      ColumnVector xSun = BNC_PPP::t_astro::Sun(Mjd);
     257      xSun /= sqrt(DotProduct(xSun,xSun));
    240258 
    241     ColumnVector sy = crossproduct(sz, xSun);
    242     sy /= sqrt(DotProduct(sy,sy));
     259      ColumnVector sy = crossproduct(sz, xSun);
     260      sy /= sqrt(DotProduct(sy,sy));
    243261 
    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 ////////////////////////////////////////////////////////////////////////////
    259 double bncAntex::pco(const QString& antName, double eleSat, bool& found) const {
    260 
    261   static const double f1 = t_CST::freq(t_frequency::G1, 0);
    262   static const double f2 = t_CST::freq(t_frequency::G2, 0);
    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()) {
     262      ColumnVector sx = crossproduct(sy, sz);
     263
     264      dx[0] = sx[0] * neu[0] + sy[0] * neu[1] + sz[0] * neu[2];
     265      dx[1] = sx[1] * neu[0] + sy[1] * neu[1] + sz[1] * neu[2];
     266      dx[2] = sx[2] * neu[0] + sy[2] * neu[1] + sz[2] * neu[2];
     267
     268      return success;
     269    }
     270  }
     271
     272  return failure;
     273}
     274
     275//
     276////////////////////////////////////////////////////////////////////////////
     277double bncAntex::rcvCorr(const string& antName, t_frequency::type frqType,
     278                         double eleSat, double /* azSat */, bool& found) const {
     279
     280  if (antName.find("NULLANTENNA") != string::npos) {
    268281    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 {
     282    return 0.0;
     283  }
     284
     285  QString antNameQ = antName.c_str();
     286
     287  if (_maps.find(antNameQ) == _maps.end()) {
    277288    found = false;
    278   }
    279 
    280   return 0.0;
    281 }
    282 
    283 //
    284 ////////////////////////////////////////////////////////////////////////////
    285 double bncAntex::rcvCorr(const std::string& antName, double eleSat, bool& found) const {
    286   return pco(QString(antName.c_str()), eleSat, found);
    287 }
     289    return 0.0;
     290  }
     291
     292  t_antMap* map = _maps[antNameQ];
     293
     294  if (map->frqMap.find(frqType) == map->frqMap.end()) {
     295    found = false;
     296    return 0.0;
     297  }
     298
     299  t_frqMap* frqMap = map->frqMap[frqType];
     300
     301  double var = 0.0;
     302  if (frqMap->pattern.ncols() > 0) {
     303    double zenDiff = 999.999;
     304    double zenSat  = 90.0 - eleSat * 180.0 / M_PI;
     305    unsigned iZen = 0;
     306    for (double zen = map->zen1; zen <= map->zen2; zen += map->dZen) {
     307      iZen += 1;
     308      double newZenDiff = fabs(zen - zenSat);
     309      if (newZenDiff < zenDiff) {
     310        zenDiff = newZenDiff;
     311        var = frqMap->pattern(iZen);
     312      }
     313    }
     314  }
     315
     316  found = true;
     317  return var - frqMap->neu[2] * sin(eleSat);
     318}
Note: See TracChangeset for help on using the changeset viewer.