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: eurefip@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 021111307, USA.


24 


25  #ifndef PPPFILTER_H


26  #define PPPFILTER_H


27 


28  #include <QtCore>


29  #include <QtNetwork>


30  #include <newmat.h>


31 


32  #include "bncconst.h"


33  #include "bnctime.h"


34 


35  class bncAntex;


36 


37  namespace BNC_PPP {


38 


39  class t_pppClient;


40  class t_pppOptions;


41  class t_epoData;


42  class t_satData;


43  class t_tides;


44 


45  class t_satData {


46  public:


47  t_satData() {


48  obsIndex = 0;


49  P1 = 0.0;


50  P2 = 0.0;


51  P5 = 0.0;


52  P7 = 0.0;


53  P3 = 0.0;


54  L1 = 0.0;


55  L2 = 0.0;


56  L5 = 0.0;


57  L7 = 0.0;


58  L3 = 0.0;


59  lkA = 0.0;


60  lkB = 0.0;


61  clk = 0.0;


62  eleSat = 0.0;


63  azSat = 0.0;


64  rho = 0.0;


65  slipFlag = false;


66  lambda3 = 0.0;


67  }


68  ~t_satData() {}


69  bncTime tt;


70  QString prn;


71  double P1;


72  double P2;


73  double P5;


74  double P7;


75  double P3;


76  double L1;


77  double L2;


78  double L5;


79  double L7;


80  double L3;


81  ColumnVector xx;


82  ColumnVector vv;


83  double clk;


84  double eleSat;


85  double azSat;


86  double rho;


87  bool slipFlag;


88  double lambda3;


89  double lkA;


90  double lkB;


91  unsigned obsIndex;


92  char system() const {return prn.toAscii()[0];}


93  };


94 


95  class t_epoData {


96  public:


97  t_epoData() {}


98 


99  ~t_epoData() {


100  clear();


101  }


102 


103  void clear() {


104  QMapIterator<QString, t_satData*> it(satData);


105  while (it.hasNext()) {


106  it.next();


107  delete it.value();


108  }


109  satData.clear();


110  tt.reset();


111  }


112 


113  void deepCopy(const t_epoData* from) {


114  clear();


115  tt = from>tt;


116  QMapIterator<QString, t_satData*> it(from>satData);


117  while (it.hasNext()) {


118  it.next();


119  satData[it.key()] = new t_satData(*it.value());


120  }


121  }


122 


123  unsigned sizeSys(char system) const {


124  unsigned ans = 0;


125  QMapIterator<QString, t_satData*> it(satData);


126  while (it.hasNext()) {


127  it.next();


128  if (it.value()>system() == system) {


129  ++ans;


130  }


131  }


132  return ans;


133  }


134  unsigned sizeAll() const {return satData.size();}


135 


136  bncTime tt;


137  QMap<QString, t_satData*> satData;


138  };


139 


140  class t_pppParam {


141  public:


142  enum parType {CRD_X, CRD_Y, CRD_Z, RECCLK, TROPO, AMB_L3,


143  GLONASS_OFFSET, GALILEO_OFFSET, BDS_OFFSET};


144  t_pppParam(parType typeIn, int indexIn, const QString& prn);


145  ~t_pppParam();


146  double partial(t_satData* satData, bool phase);


147  bool isCrd() const {


148  return (type == CRD_X  type == CRD_Y  type == CRD_Z);


149  }


150  parType type;


151  double xx;


152  int index;


153  int index_old;


154  int numEpo;


155  QString prn;


156  };


157 


158  class t_pppFilter {


159  public:


160  t_pppFilter(t_pppClient* pppClient);


161  ~t_pppFilter();


162  t_irc update(t_epoData* epoData);


163  bncTime time() const {return _time;}


164  const SymmetricMatrix& Q() const {return _QQ;}


165  const ColumnVector& neu() const {return _neu;}


166  int numSat() const {return _numSat;}


167  double HDOP() const {return _hDop;}


168  double x() const {return _params[0]>xx;}


169  double y() const {return _params[1]>xx;}


170  double z() const {return _params[2]>xx;}


171  double clk() const {return _params[3]>xx;}


172  double trp0() {return delay_saast(M_PI/2.0);}


173  double trp() const {


174  for (int ii = 0; ii < _params.size(); ++ii) {


175  t_pppParam* pp = _params[ii];


176  if (pp>type == t_pppParam::TROPO) {


177  return pp>xx;


178  }


179  }


180  return 0.0;


181  }


182  double trpStdev() const {


183  for (int ii = 0; ii < _params.size(); ++ii) {


184  t_pppParam* pp = _params[ii];


185  if (pp>type == t_pppParam::TROPO) {


186  return sqrt(Q()[ii][ii]);


187  }


188  }


189  return 0.0;


190  }


191  double Glonass_offset() const {


192  for (int ii = 0; ii < _params.size(); ++ii) {


193  t_pppParam* pp = _params[ii];


194  if (pp>type == t_pppParam::GLONASS_OFFSET) {


195  return pp>xx;


196  }


197  }


198  return 0.0;


199  }


200  double Galileo_offset() const {


201  for (int ii = 0; ii < _params.size(); ++ii) {


202  t_pppParam* pp = _params[ii];


203  if (pp>type == t_pppParam::GALILEO_OFFSET) {


204  return pp>xx;


205  }


206  }


207  return 0.0;


208  }


209  double Bds_offset() const {


210  for (int ii = 0; ii < _params.size(); ++ii) {


211  t_pppParam* pp = _params[ii];


212  if (pp>type == t_pppParam::BDS_OFFSET) {


213  return pp>xx;


214  }


215  }


216  return 0.0;


217  }


218  private:


219  void reset();


220  t_irc cmpBancroft(t_epoData* epoData);


221  void cmpEle(t_satData* satData);


222  void addAmb(t_satData* satData);


223  void addObs(int iPhase, unsigned& iObs, t_satData* satData,


224  Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP);


225  QByteArray printRes(int iPhase, const ColumnVector& vv,


226  const QMap<QString, t_satData*>& satDataMap);


227  void findMaxRes(const ColumnVector& vv,


228  const QMap<QString, t_satData*>& satData,


229  QString& prnGPS, QString& prnGlo,


230  double& maxResGPS, double& maxResGlo);


231  double cmpValue(t_satData* satData, bool phase);


232  double delay_saast(double Ele);


233  void predict(int iPhase, t_epoData* epoData);


234  t_irc update_p(t_epoData* epoData);


235  QString outlierDetection(int iPhase, const ColumnVector& vv,


236  QMap<QString, t_satData*>& satData);


237 


238  double windUp(const QString& prn, const ColumnVector& rSat,


239  const ColumnVector& rRec);


240 


241  bncTime _startTime;


242 


243  void rememberState(t_epoData* epoData);


244  void restoreState(t_epoData* epoData);


245 


246  t_irc selectSatellites(const QString& lastOutlierPrn,


247  QMap<QString, t_satData*>& satData);


248 


249  void bancroft(const Matrix& BBpass, ColumnVector& pos);


250 


251  void cmpDOP(t_epoData* epoData);


252 


253  t_pppClient* _pppClient;


254  bncTime _time;


255  bncTime _lastTimeOK;


256  QVector<t_pppParam*> _params;


257  SymmetricMatrix _QQ;


258  QVector<t_pppParam*> _params_sav;


259  SymmetricMatrix _QQ_sav;


260  t_epoData* _epoData_sav;


261  ColumnVector _xcBanc;


262  ColumnVector _ellBanc;


263  QMap<QString, double> _windUpTime;


264  QMap<QString, double> _windUpSum;


265  QStringList _outlierGPS;


266  QStringList _outlierGlo;


267  bncAntex* _antex;


268  t_tides* _tides;


269  ColumnVector _neu;


270  int _numSat;


271  double _hDop;


272  };


273 


274  }


275 


276  #endif

