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  P3 = 0.0;


53  L1 = 0.0;


54  L2 = 0.0;


55  L5 = 0.0;


56  L3 = 0.0;


57  }


58  ~t_satData() {}


59  bncTime tt;


60  QString prn;


61  double P1;


62  double P2;


63  double P5;


64  double P3;


65  double L1;


66  double L2;


67  double L5;


68  double L3;


69  ColumnVector xx;


70  ColumnVector vv;


71  double clk;


72  double eleSat;


73  double azSat;


74  double rho;


75  bool slipFlag;


76  double lambda3;


77  unsigned obsIndex;


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


79  };


80 


81  class t_epoData {


82  public:


83  t_epoData() {}


84 


85  ~t_epoData() {


86  clear();


87  }


88 


89  void clear() {


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


91  while (it.hasNext()) {


92  it.next();


93  delete it.value();


94  }


95  satData.clear();


96  tt.reset();


97  }


98 


99  void deepCopy(const t_epoData* from) {


100  clear();


101  tt = from>tt;


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


103  while (it.hasNext()) {


104  it.next();


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


106  }


107  }


108 


109  unsigned sizeSys(char system) const {


110  unsigned ans = 0;


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


112  while (it.hasNext()) {


113  it.next();


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


115  ++ans;


116  }


117  }


118  return ans;


119  }


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


121 


122  bncTime tt;


123  QMap<QString, t_satData*> satData;


124  };


125 


126  class t_pppParam {


127  public:


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


129  GLONASS_OFFSET, GALILEO_OFFSET};


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


131  ~t_pppParam();


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


133  bool isCrd() const {


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


135  }


136  parType type;


137  double xx;


138  int index;


139  int index_old;


140  int numEpo;


141  QString prn;


142  };


143 


144  class t_pppFilter {


145  public:


146  t_pppFilter(t_pppClient* pppClient);


147  ~t_pppFilter();


148  t_irc update(t_epoData* epoData);


149  bncTime time() const {return _time;}


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


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


152  int numSat() const {return _numSat;}


153  double PDOP() const {return _pDop;}


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


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


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


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


158  double trp() const {


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


160  t_pppParam* pp = _params[ii];


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


162  return pp>xx;


163  }


164  }


165  return 0.0;


166  }


167  double Glonass_offset() const {


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


169  t_pppParam* pp = _params[ii];


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


171  return pp>xx;


172  }


173  }


174  return 0.0;


175  }


176  double Galileo_offset() const {


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


178  t_pppParam* pp = _params[ii];


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


180  return pp>xx;


181  }


182  }


183  return 0.0;


184  }


185 


186  private:


187  void reset();


188  t_irc cmpBancroft(t_epoData* epoData);


189  void cmpEle(t_satData* satData);


190  void addAmb(t_satData* satData);


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


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


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


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


195  void findMaxRes(const ColumnVector& vv,


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


197  QString& prnGPS, QString& prnGlo,


198  double& maxResGPS, double& maxResGlo);


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


200  double delay_saast(double Ele);


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


202  t_irc update_p(t_epoData* epoData);


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


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


205 


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


207  const ColumnVector& rRec);


208 


209  bncTime _startTime;


210 


211  void rememberState(t_epoData* epoData);


212  void restoreState(t_epoData* epoData);


213 


214  t_irc selectSatellites(const QString& lastOutlierPrn,


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


216 


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


218 


219  void cmpDOP(t_epoData* epoData);


220 


221  t_pppClient* _pppClient;


222  bncTime _time;


223  bncTime _lastTimeOK;


224  QVector<t_pppParam*> _params;


225  SymmetricMatrix _QQ;


226  QVector<t_pppParam*> _params_sav;


227  SymmetricMatrix _QQ_sav;


228  t_epoData* _epoData_sav;


229  ColumnVector _xcBanc;


230  ColumnVector _ellBanc;


231  QMap<QString, double> _windUpTime;


232  QMap<QString, double> _windUpSum;


233  QStringList _outlierGPS;


234  QStringList _outlierGlo;


235  bncAntex* _antex;


236  t_tides* _tides;


237  ColumnVector _neu;


238  int _numSat;


239  double _pDop;


240  };


241 


242  }


243 


244  #endif

