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 <QByteArray>


29  #include <QMap>


30  #include <QStringList>


31  #include <QVector>


32  #include <newmat.h>


33 


34  #include "bncconst.h"


35  #include "bnctime.h"


36 


37  class bncAntex;


38 


39  namespace BNC_PPP {


40 


41  class t_pppClient;


42  class t_pppOptions;


43  class t_epoData;


44  class t_satData;


45  class t_tides;


46 


47  class t_satData {


48  public:


49  t_satData() {


50  obsIndex = 0;


51  P1 = 0.0;


52  P2 = 0.0;


53  P5 = 0.0;


54  P6 = 0.0;


55  P7 = 0.0;


56  P3 = 0.0;


57  P3sig = 0.0;


58  L1 = 0.0;


59  L2 = 0.0;


60  L5 = 0.0;


61  L6 = 0.0;


62  L7 = 0.0;


63  L3 = 0.0;


64  L3sig = 0.0;


65  lkA = 0.0;


66  lkB = 0.0;


67  clk = 0.0;


68  eleSat = 0.0;


69  azSat = 0.0;


70  rho = 0.0;


71  slipFlag = false;


72  lambda3 = 0.0;


73  }


74  ~t_satData() {}


75  bncTime tt;


76  QString prn;


77  double P1;


78  double P2;


79  double P5;


80  double P6;


81  double P7;


82  double P3;


83  double P3sig;


84  double L1;


85  double L2;


86  double L5;


87  double L6;


88  double L7;


89  double L3;


90  double L3sig;


91  ColumnVector xx;


92  ColumnVector vv;


93  double clk;


94  double eleSat;


95  double azSat;


96  double rho;


97  bool slipFlag;


98  double lambda3;


99  double lkA;


100  double lkB;


101  unsigned obsIndex;


102  char system() const {return prn.toLatin1()[0];}


103  };


104 


105  class t_epoData {


106  public:


107  t_epoData() {}


108 


109  ~t_epoData() {


110  clear();


111  }


112 


113  void clear() {


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


115  while (it.hasNext()) {


116  it.next();


117  delete it.value();


118  }


119  satData.clear();


120  tt.reset();


121  }


122 


123  void deepCopy(const t_epoData* from) {


124  clear();


125  tt = from>tt;


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


127  while (it.hasNext()) {


128  it.next();


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


130  }


131  }


132 


133  unsigned sizeSys(char system) const {


134  unsigned ans = 0;


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


136  while (it.hasNext()) {


137  it.next();


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


139  ++ans;


140  }


141  }


142  return ans;


143  }


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


145 


146  bncTime tt;


147  QMap<QString, t_satData*> satData;


148  };


149 


150  class t_pppParam {


151  public:


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


153  GLONASS_OFFSET, GALILEO_OFFSET, BDS_OFFSET};


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


155  ~t_pppParam();


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


157  bool isCrd() const {


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


159  }


160  parType type;


161  double xx;


162  int index;


163  int index_old;


164  int numEpo;


165  QString prn;


166  };


167 


168  class t_pppFilter {


169  public:


170  t_pppFilter(t_pppClient* pppClient);


171  ~t_pppFilter();


172  t_irc update(t_epoData* epoData);


173  bncTime time() const {return _time;}


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


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


176  int numSat() const {return _numSat;}


177  double HDOP() const {return _hDop;}


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


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


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


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


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


183  double trp() const {


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


185  t_pppParam* pp = _params[ii];


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


187  return pp>xx;


188  }


189  }


190  return 0.0;


191  }


192  double trpStdev() const {


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


194  t_pppParam* pp = _params[ii];


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


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


197  }


198  }


199  return 0.0;


200  }


201  double Glonass_offset() const {


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


203  t_pppParam* pp = _params[ii];


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


205  return pp>xx;


206  }


207  }


208  return 0.0;


209  }


210  double Galileo_offset() const {


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


212  t_pppParam* pp = _params[ii];


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


214  return pp>xx;


215  }


216  }


217  return 0.0;


218  }


219  double Bds_offset() const {


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


221  t_pppParam* pp = _params[ii];


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


223  return pp>xx;


224  }


225  }


226  return 0.0;


227  }


228  private:


229  void reset();


230  t_irc cmpBancroft(t_epoData* epoData);


231  void cmpEle(t_satData* satData);


232  void addAmb(t_satData* satData);


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


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


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


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


237  void findMaxRes(const ColumnVector& vv,


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


239  QString& prnGPS, QString& prnGlo,


240  double& maxResGPS, double& maxResGlo);


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


242  double delay_saast(double Ele);


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


244  t_irc update_p(t_epoData* epoData);


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


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


247 


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


249  const ColumnVector& rRec);


250 


251  bncTime _startTime;


252 


253  void rememberState(t_epoData* epoData);


254  void restoreState(t_epoData* epoData);


255 


256  t_irc selectSatellites(const QString& lastOutlierPrn,


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


258 


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


260 


261  void cmpDOP(t_epoData* epoData);


262 


263  t_pppClient* _pppClient;


264  bncTime _time;


265  bncTime _lastTimeOK;


266  QVector<t_pppParam*> _params;


267  SymmetricMatrix _QQ;


268  QVector<t_pppParam*> _params_sav;


269  SymmetricMatrix _QQ_sav;


270  t_epoData* _epoData_sav;


271  ColumnVector _xcBanc;


272  ColumnVector _ellBanc;


273  QMap<QString, double> _windUpTime;


274  QMap<QString, double> _windUpSum;


275  QStringList _outlierGPS;


276  QStringList _outlierGlo;


277  bncAntex* _antex;


278  t_tides* _tides;


279  ColumnVector _neu;


280  int _numSat;


281  double _hDop;


282  };


283 


284  }


285 


286  #endif

