Index: trunk/BNC/src/PPP/pppClient.cpp
===================================================================
--- trunk/BNC/src/PPP/pppClient.cpp	(revision 8911)
+++ trunk/BNC/src/PPP/pppClient.cpp	(revision 8912)
@@ -68,6 +68,6 @@
 
   if (_opt->_refSatRequired) {
-    for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
-      char system = OPT->systems()[iSys];
+    for (unsigned iSys = 0; iSys < _opt->systems().size(); iSys++) {
+      char system = _opt->systems()[iSys];
       _obsPool->initRefSatMapElement(system);
     }
@@ -165,5 +165,5 @@
   for (unsigned ii = 0; ii < satObs.size(); ii++) {
     char system = satObs[ii]->_prn.system();
-    if (OPT->useSystem(system)) {
+    if (_opt->useSystem(system)) {
       t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
       if (pppSatObs->isValid()) {
@@ -180,6 +180,6 @@
   if (_opt->_refSatRequired) {
     // reference satellite definition per system
-    for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
-      char system = OPT->systems()[iSys];
+    for (unsigned iSys = 0; iSys < _opt->systems().size(); iSys++) {
+      char system = _opt->systems()[iSys];
       bool refSatDefined = false;
       t_pppRefSat* refSat = _obsPool->getRefSatMapElement(system);
@@ -187,5 +187,5 @@
         const t_pppSatObs* satObs = obsVector.at(ii);
         // reference satellite is unchanged
-        if      (!_obsPool->epoReProcessing() && refSat->prn() == satObs->prn()) {
+        if      (!_obsPool->refSatChangeRequired() && refSat->prn() == satObs->prn()) {
           refSatDefined = true;
           obsVector[ii]->setAsReference();
@@ -193,5 +193,5 @@
         }
         // reference satellite has changed
-        else if (_obsPool->epoReProcessing() && refSat->prn() != satObs->prn()) {
+        else if ( _obsPool->refSatChangeRequired() && refSat->prn() != satObs->prn()) {
           if (satObs->prn().system() == system) {
             refSatDefined = true;
@@ -217,5 +217,5 @@
       }
     }
-    _obsPool->setEpoReProcessing(false); //TODO: später erst nach Trafo false setzen
+    _obsPool->setRefSatChangeRequired(false);
   }
 
@@ -252,5 +252,5 @@
   bool pseudoObsIono = false;
 
-  if (OPT->_pseudoObsIono) {
+  if (_opt->_pseudoObsIono) {
     vector<t_pppSatObs*>::iterator it = obsVector.begin();
     while (it != obsVector.end()) {
@@ -295,5 +295,5 @@
         }
       }
-      if ( satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
+      if ( satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
         ++iObs;
         BB[iObs][0] = satObs->xc()[0];
@@ -303,5 +303,5 @@
       }
     }
-    if (iObs + 1 < OPT->_minObs) {
+    if (iObs + 1 < _opt->_minObs) {
       LOG << "t_pppClient::cmpBancroft not enough observations" << endl;
       return failure;
@@ -321,5 +321,5 @@
       if (satObs->isValid() &&
           satObs->prn().system() == 'G' &&
-          (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
+          (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
         ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
         double res = rr.NormFrobenius() - satObs->obsValue(tLC)
@@ -363,5 +363,5 @@
   double     offGG = 0.0;
 
-  if (OPT->useSystem('R')) {
+  if (_opt->useSystem('R')) {
     while (obsVector.size() > 0) {
       offGG = 0.0;
@@ -376,5 +376,5 @@
             tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
           }
-          if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle)) {
+          if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
             double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
             ++nObs;
@@ -465,14 +465,14 @@
   bncTime time;
   time = _epoTimeRover;
-  station->setName(OPT->_roverName);
-  station->setAntName(OPT->_antNameRover);
+  station->setName(_opt->_roverName);
+  station->setAntName(_opt->_antNameRover);
   station->setEpochTime(time);
-  if (OPT->xyzAprRoverSet()) {
-    station->setXyzApr(OPT->_xyzAprRover);
+  if (_opt->xyzAprRoverSet()) {
+    station->setXyzApr(_opt->_xyzAprRover);
   }
   else {
     station->setXyzApr(xyzc.Rows(1,3));
   }
-  station->setNeuEcc(OPT->_neuEccRover);
+  station->setNeuEcc(_opt->_neuEccRover);
 
   // Receiver Clock
@@ -495,7 +495,7 @@
     }
     if (satObs->isValid() &&
-        satObs->eleSat() >= OPT->_minEle &&
+        satObs->eleSat() >= _opt->_minEle &&
         modelSetup == success) {
-      if (satObs->isReference() && OPT->_pseudoObsIono) {
+      if (satObs->isReference() && _opt->_pseudoObsIono) {
         char system = satObs->prn().system();
         t_pppRefSat* refSat = _obsPool->getRefSatMapElement(system);
@@ -519,9 +519,9 @@
   try {
     initOutput(output);
-    _num = 0;
-    _obsPool->setEpoReProcessing(false); // initialize for epoch
+    int num = 0;
+    bool epochReProcessing = false;
 
     do {
-      _num++;
+      num++;
 
       // Prepare Observations of the Rover
@@ -550,12 +550,11 @@
       // Prepare Pseudo Observations of the Rover
       // ----------------------------------------
-      _pseudoObsIono = preparePseudoObs(_obsRover);//qDebug() << "_pseudoObsIonoAvailable: " << _pseudoObsIono;
-
-      if (int(_obsRover.size()) < OPT->_minObs) {
+      _pseudoObsIono = preparePseudoObs(_obsRover);
+      if (int(_obsRover.size()) < _opt->_minObs) {
         LOG << "t_pppClient::processEpoch not enough observations" << endl;
         return finish(failure);
       }
 
-      if (OPT->_refSatRequired) {
+      if (_opt->_refSatRequired) {
         LOG.setf(ios::fixed);
         QMapIterator<char, t_pppRefSat*> it(_obsPool->getRefSatMap());
@@ -575,9 +574,23 @@
       // Process Epoch in Filter
       // -----------------------
-      if (_filter->processEpoch(_num) != success) {
+      if (_filter->processEpoch(num) != success) {
         return finish(failure);
       }
-      // if num > 1 und !obsPool->epoReProcessing() => filter ->datumTransformation
-    } while (_obsPool->epoReProcessing());
+
+      // Epoch re-processing required?
+      // -----------------------------
+      if (_obsPool->refSatChangeRequired()) {
+        epochReProcessing = true;
+      }
+      else {
+        epochReProcessing = false;
+      }
+      // Datum transformation required?
+      // ------------------------------
+      if (num > 1 && epochReProcessing) {
+        _filter->datumTransformation();
+      }
+
+    } while (epochReProcessing);
   }
   catch (Exception& exc) {
Index: trunk/BNC/src/PPP/pppFilter.cpp
===================================================================
--- trunk/BNC/src/PPP/pppFilter.cpp	(revision 8911)
+++ trunk/BNC/src/PPP/pppFilter.cpp	(revision 8912)
@@ -51,4 +51,5 @@
 t_irc t_pppFilter::processEpoch(int num) {
   _numSat     = 0;
+  _numOfEpochProcessing = num;
   const double maxSolGap = 60.0;
 
@@ -87,9 +88,7 @@
   ColumnVector    xFltOld = _xFlt;
   SymmetricMatrix QFltOld = _QFlt;
-
   _QFlt.ReSize(_parlist->nPar()); _QFlt = 0.0;
   _xFlt.ReSize(_parlist->nPar()); _xFlt = 0.0;
   _x0.ReSize(_parlist->nPar());   _x0   = 0.0;
-
   for (unsigned ii = 0; ii < params.size(); ii++) {
     const t_pppParam* par1 = params[ii];
@@ -111,5 +110,4 @@
     }
   }
-
   predictCovCrdPart(QFltOld);
 
@@ -141,6 +139,9 @@
   // Process Satellite Systems separately
   // ------------------------------------
+  int numOfAllUsedLCs = 0;
+  preProcessing = false;
   for (unsigned iSys = 0; iSys < OPT->systems().size(); iSys++) {
     char system = OPT->systems()[iSys];
+    numOfAllUsedLCs += OPT->LCs(system).size();
     if (OPT->_refSatRequired) {
       _refPrn = (_obsPool->getRefSatMapElement(system))->prn();
@@ -160,9 +161,14 @@
     }
   }
-  if (_obsPool->epoReProcessing()) {
-    // set A1 und A2 abhängig von num
-    // if num == 1 => A1
-    // if num >  1 => A2
-  }
+
+  // refSat change required?
+  // -----------------------
+  if (_obsPool->refSatChangeRequired()) {
+    _xFlt = xFltOld;
+    _QFlt = QFltOld;
+    initDatumTransformation(numOfAllUsedLCs);
+  }
+  // close epoch processing
+  // ----------------------
   else {
     cmpDOP(allObs);
@@ -223,5 +229,6 @@
     ColumnVector          ll(maxObs);
     DiagonalMatrix        PP(maxObs); PP = 0.0;
-    //TETSPLOT
+
+    // TETSPLOT
     for (unsigned iPar = 0; iPar < params.size(); iPar++) {
       const t_pppParam* par = params[iPar];
@@ -229,4 +236,5 @@
     }
     cout << endl;
+    //END TETSPLOT
 
     int iObs = -1;
@@ -307,5 +315,5 @@
       if      (par && preProcessing) {
         if (par->prn() == refPrn) {
-          _obsPool->setEpoReProcessing(true);
+          _obsPool->setRefSatChangeRequired(true);
         }
       }
@@ -392,5 +400,5 @@
           if (preProcessing) {
             if (obs->prn() == refPrn) {
-              _obsPool->setEpoReProcessing(true);
+              _obsPool->setRefSatChangeRequired(true);
             }
           }
@@ -412,5 +420,5 @@
             if (preProcessing) {
               if (obs->prn() == refPrn) {
-                _obsPool->setEpoReProcessing(true);
+                _obsPool->setRefSatChangeRequired(true);
               }
             }
@@ -542,2 +550,27 @@
   }
 }
+
+//
+////////////////////////////////////////////////////////////////////////////
+void t_pppFilter::initDatumTransformation(int numOfUsedLCs) {
+
+  if (_numOfEpochProcessing == 1) {
+	   _AA1.ReSize(numOfUsedLCs, _parlist->nPar());
+	   _AA1 = 0.0;
+     _AA2.ReSize(numOfUsedLCs, _parlist->nPar());
+     _AA2 = 0.0;
+  }
+}
+
+//
+////////////////////////////////////////////////////////////////////////////
+void t_pppFilter::datumTransformation() {
+
+  Matrix D21 = (_AA2.t() * _AA2).i() * _AA2.t() * _AA1;
+
+  _QFlt = D21 * _QFlt * D21.t();
+}
+
+
+
+
Index: trunk/BNC/src/PPP/pppFilter.h
===================================================================
--- trunk/BNC/src/PPP/pppFilter.h	(revision 8911)
+++ trunk/BNC/src/PPP/pppFilter.h	(revision 8912)
@@ -21,4 +21,6 @@
 
   t_irc processEpoch(int num);
+
+  void datumTransformation();
 
   const ColumnVector&    x() const {return _xFlt;}
@@ -91,12 +93,17 @@
   void predictCovCrdPart(const SymmetricMatrix& QFltOld);
 
+  void initDatumTransformation(int numOfAllUsedLCs);
+
   bncTime         _epoTime;
   t_pppParlist*   _parlist;
   t_pppObsPool*   _obsPool;
   SymmetricMatrix _QFlt;
+  Matrix          _AA1;
+  Matrix          _AA2;
   ColumnVector    _xFlt;
   ColumnVector    _x0;
   t_slip          _slips[t_prn::MAXPRN+1];
   int             _numSat;
+  int             _numOfEpochProcessing;
   t_dop           _dop;
   bncTime         _firstEpoTime;
