Index: branches/BNC_2.12/src/PPP_SSR_I/pppFilter.cpp
===================================================================
--- branches/BNC_2.12/src/PPP_SSR_I/pppFilter.cpp	(revision 9281)
+++ branches/BNC_2.12/src/PPP_SSR_I/pppFilter.cpp	(revision 9471)
@@ -55,9 +55,6 @@
 using namespace std;
 
-const double   MAXRES_CODE           = 2.98 * 3.0;
-const double   MAXRES_PHASE_GPS      = 0.04;
-const double   MAXRES_PHASE_GLONASS  = 2.98 * 0.03;
 const double   GLONASS_WEIGHT_FACTOR = 5.0;
-const double   BDS_WEIGHT_FACTOR     = 5.0;
+const double   BDS_WEIGHT_FACTOR     = 2.0; // 5.0;
 
 #define LOG (_pppClient->log())
@@ -352,6 +349,8 @@
 
   double offset = 0.0;
-  t_frequency::type frqA = t_frequency::G1;
-  t_frequency::type frqB = t_frequency::G2;
+
+  t_frequency::type frqA;
+  t_frequency::type frqB;
+
   if      (satData->prn[0] == 'R') {
     offset = Glonass_offset();
@@ -367,7 +366,13 @@
     offset = Bds_offset();
     frqA = t_frequency::C2;
-    frqB = t_frequency::C7;
-  }
+    frqB = t_frequency::C6;
+  }
+  else {
+    frqA = t_frequency::G1;
+    frqB = t_frequency::G2;
+  }
+
   double phaseCenter = 0.0;
+
   if (_antex) {
     bool found;
@@ -535,5 +540,8 @@
       // --------------
       else if (pp->type == t_pppParam::GALILEO_OFFSET) {
-        _QQ(iPar,iPar) += 0.1 * 0.1;
+        if (_QQ(iPar,iPar)>pow(1000.0,2))
+          _QQ(iPar,iPar) = 1000.0 * 1000.0;
+        else
+          _QQ(iPar,iPar) += 0.1 * 0.1;
       }
 
@@ -541,5 +549,8 @@
       // ----------
       else if (pp->type == t_pppParam::BDS_OFFSET) {
-        _QQ(iPar,iPar) += 0.1 * 0.1;    //TODO: TEST
+        if (_QQ(iPar,iPar)>pow(1000.0,2))
+          _QQ(iPar,iPar) = 1000.0 * 1000.0;
+        else
+          _QQ(iPar,iPar) += 0.1 * 0.1;
       }
     }
@@ -746,4 +757,14 @@
 }
 
+// Iono combi noise factor
+////////////////////////////////////////////////////////////////////////////
+double ionFac(const QString prn, QMap<QString, t_satData*>& satData) {
+  if (satData.contains(prn))
+    return sqrt(pow(satData.value(prn)->lkA,2) +
+                pow(satData.value(prn)->lkB,2)  );
+  else
+    return 0.0;
+};
+
 // Outlier Detection
 ////////////////////////////////////////////////////////////////////////////
@@ -755,21 +776,37 @@
   QString prnGPS;
   QString prnGlo;
+
+  double  ionFacGPS;
+  double  ionFacGLO;
+
   double  maxResGPS = 0.0; // GPS + Galileo
   double  maxResGlo = 0.0; // GLONASS + BDS
+
   findMaxRes(vv, satData, prnGPS, prnGlo, maxResGPS, maxResGlo);
 
+  ionFacGLO = ionFac(prnGlo,satData);
+  if (iPhase == 0)
+    ionFacGLO *= (prnGlo[0]=='R'? GLONASS_WEIGHT_FACTOR : BDS_WEIGHT_FACTOR);
+  ionFacGPS = ionFac(prnGPS,satData);
+
   if      (iPhase == 1) {
-    if      (maxResGlo > 2.98 * OPT->_maxResL1) {
+    if      (maxResGlo > ionFacGLO * OPT->_maxResL1) {
       LOG << "Outlier Phase " << prnGlo.mid(0,3).toAscii().data() << ' ' << maxResGlo << endl;
       return prnGlo;
     }
-    else if (maxResGPS > MAXRES_PHASE_GPS) {
+    else if (maxResGPS > ionFacGPS * OPT->_maxResL1) {
       LOG << "Outlier Phase " << prnGPS.mid(0,3).toAscii().data() << ' ' << maxResGPS << endl;
       return prnGPS;
     }
   }
-  else if (iPhase == 0 && maxResGPS > 2.98 * OPT->_maxResC1) {
-    LOG << "Outlier Code  " << prnGPS.mid(0,3).toAscii().data() << ' ' << maxResGPS << endl;
-    return prnGPS;
+  else if (iPhase == 0) {
+    if (maxResGlo > ionFacGLO * OPT->_maxResC1) {
+      LOG << "Outlier Code  " << prnGlo.mid(0,3).toLatin1().data() << ' ' << maxResGlo << endl;
+      return prnGlo;
+    }
+    else if (maxResGPS > ionFacGPS * OPT->_maxResC1) {
+      LOG << "Outlier Code  " << prnGPS.mid(0,3).toLatin1().data() << ' ' << maxResGPS << endl;
+      return prnGPS;
+    }
   }
 
@@ -780,5 +817,5 @@
 ///////////////////////////////////////////////////////////////////////////
 double t_pppFilter::windUp(const QString& prn, const ColumnVector& rSat,
-                        const ColumnVector& rRec) {
+                           const ColumnVector& rRec) {
 
   Tracer tracer("t_pppFilter::windUp");
@@ -919,10 +956,13 @@
   satData->obsIndex = iObs;
 
+  // Iono-free combination noise factor
+  // ----------------------------------
+  double ionFac = sqrt(pow(satData->lkA,2) + pow(satData->lkB,2));
+
   // Phase Observations
   // ------------------
 
   if (iPhase == 1) {
-    ll(iObs)      = satData->L3 - cmpValue(satData, true);
-    double sigL3 = 2.98 * OPT->_sigmaL1;
+    double sigL3 = ionFac * ellWgtCoef * OPT->_sigmaL1;
     if (satData->system() == 'R') {
       sigL3 *= GLONASS_WEIGHT_FACTOR;
@@ -931,5 +971,7 @@
       sigL3 *= BDS_WEIGHT_FACTOR;
     }
-    PP(iObs,iObs) = 1.0 / (sigL3 * sigL3) / (ellWgtCoef * ellWgtCoef);
+    satData->L3sig = sigL3;
+    ll(iObs)      = satData->L3 - cmpValue(satData, true);
+    PP(iObs,iObs) = 1.0 / (sigL3 * sigL3);
     for (int iPar = 1; iPar <= _params.size(); iPar++) {
       if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
@@ -944,7 +986,14 @@
   // -----------------
   else {
-    double sigP3 = 2.98 * OPT->_sigmaC1;
+    double sigP3 = ionFac * ellWgtCoef * OPT->_sigmaC1;
+    if (satData->system() == 'R') {
+      sigP3 *= GLONASS_WEIGHT_FACTOR;
+    }
+    if  (satData->system() == 'C') {
+      sigP3 *= BDS_WEIGHT_FACTOR;
+    }
+    satData->P3sig = sigP3;
     ll(iObs)      = satData->P3 - cmpValue(satData, false);
-    PP(iObs,iObs) = 1.0 / (sigP3 * sigP3) / (ellWgtCoef * ellWgtCoef);
+    PP(iObs,iObs) = 1.0 / (sigP3 * sigP3);
     for (int iPar = 1; iPar <= _params.size(); iPar++) {
       AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
@@ -1166,5 +1215,5 @@
 }
 
-// Remeber Original State Vector and Variance-Covariance Matrix
+// Remember Original State Vector and Variance-Covariance Matrix
 ////////////////////////////////////////////////////////////////////////////
 void t_pppFilter::rememberState(t_epoData* epoData) {
