Index: trunk/BNC/bncmodel.cpp
===================================================================
--- trunk/BNC/bncmodel.cpp	(revision 2787)
+++ trunk/BNC/bncmodel.cpp	(revision 2789)
@@ -319,19 +319,6 @@
   while (iGPS.hasNext()) {
     iGPS.next();
-    QString    prn     = iGPS.key();
     t_satData* satData = iGPS.value();
-
-    ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
-    double       rho = rr.norm_Frobenius();
-
-    double neu[3];
-    xyz2neu(_ellBanc.data(), rr.data(), neu);
-
-    satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
-    if (neu[2] < 0) {
-      satData->eleSat *= -1.0;
-    }
-    satData->azSat  = atan2(neu[1], neu[0]);
-
+    cmpEle(satData);
     if (satData->eleSat < MINELE_GPS) {
       delete satData;
@@ -343,19 +330,6 @@
   while (iGlo.hasNext()) {
     iGlo.next();
-    QString    prn     = iGlo.key();
     t_satData* satData = iGlo.value();
-
-    ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
-    double       rho = rr.norm_Frobenius();
-
-    double neu[3];
-    xyz2neu(_ellBanc.data(), rr.data(), neu);
-
-    satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
-    if (neu[2] < 0) {
-      satData->eleSat *= -1.0;
-    }
-    satData->azSat  = atan2(neu[1], neu[0]);
-
+    cmpEle(satData);
     if (satData->eleSat < MINELE_GLO) {
       delete satData;
@@ -367,19 +341,6 @@
   while (iGal.hasNext()) {
     iGal.next();
-    QString    prn     = iGal.key();
     t_satData* satData = iGal.value();
-
-    ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
-    double       rho = rr.norm_Frobenius();
-
-    double neu[3];
-    xyz2neu(_ellBanc.data(), rr.data(), neu);
-
-    satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
-    if (neu[2] < 0) {
-      satData->eleSat *= -1.0;
-    }
-    satData->azSat  = atan2(neu[1], neu[0]);
-
+    cmpEle(satData);
     if (satData->eleSat < MINELE_GAL) {
       delete satData;
@@ -598,17 +559,5 @@
       QString prn        = iGPS.key();
       t_satData* satData = iGPS.value();
-      bool    found = false;
-      for (int iPar = 1; iPar <= _params.size(); iPar++) {
-        if (_params[iPar-1]->type == bncParam::AMB_L3 && 
-            _params[iPar-1]->prn == prn) {
-          found = true;
-          break;
-        }
-      }
-      if (!found) {
-        bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
-        _params.push_back(par);
-        par->xx = satData->L3 - cmpValue(satData, true);
-      }
+      addAmb(satData);
     }
 
@@ -616,19 +565,6 @@
     while (iGlo.hasNext()) {
       iGlo.next();
-      QString prn        = iGlo.key();
       t_satData* satData = iGlo.value();
-      bool    found = false;
-      for (int iPar = 1; iPar <= _params.size(); iPar++) {
-        if (_params[iPar-1]->type == bncParam::AMB_L3 && 
-            _params[iPar-1]->prn == prn) {
-          found = true;
-          break;
-        }
-      }
-      if (!found) {
-        bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
-        _params.push_back(par);
-        par->xx = satData->L3 - cmpValue(satData, true);
-      }
+      addAmb(satData);
     }
 
@@ -636,19 +572,6 @@
     while (iGal.hasNext()) {
       iGal.next();
-      QString prn        = iGal.key();
       t_satData* satData = iGal.value();
-      bool    found = false;
-      for (int iPar = 1; iPar <= _params.size(); iPar++) {
-        if (_params[iPar-1]->type == bncParam::AMB_L3 && 
-            _params[iPar-1]->prn == prn) {
-          found = true;
-          break;
-        }
-      }
-      if (!found) {
-        bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
-        _params.push_back(par);
-        par->xx = satData->L3 - cmpValue(satData, true);
-      }
+      addAmb(satData);
     }
     
@@ -1387,2 +1310,37 @@
   return _windUpSum[prn];  
 }
+
+// 
+///////////////////////////////////////////////////////////////////////////
+void bncModel::cmpEle(t_satData* satData) {
+  ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
+  double       rho = rr.norm_Frobenius();
+
+  double neu[3];
+  xyz2neu(_ellBanc.data(), rr.data(), neu);
+
+  satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
+  if (neu[2] < 0) {
+    satData->eleSat *= -1.0;
+  }
+  satData->azSat  = atan2(neu[1], neu[0]);
+}
+
+// 
+///////////////////////////////////////////////////////////////////////////
+void bncModel::addAmb(t_satData* satData) {
+  bool    found = false;
+  for (int iPar = 1; iPar <= _params.size(); iPar++) {
+    if (_params[iPar-1]->type == bncParam::AMB_L3 && 
+        _params[iPar-1]->prn == satData->prn) {
+      found = true;
+      break;
+    }
+  }
+  if (!found) {
+    bncParam* par = new bncParam(bncParam::AMB_L3, 
+                                 _params.size()+1, satData->prn);
+    _params.push_back(par);
+    par->xx = satData->L3 - cmpValue(satData, true);
+  }
+}
