Index: trunk/BNC/src/rinex/reqcedit.cpp
===================================================================
--- trunk/BNC/src/rinex/reqcedit.cpp	(revision 10630)
+++ trunk/BNC/src/rinex/reqcedit.cpp	(revision 10945)
@@ -73,4 +73,5 @@
   }
   _samplingRate   = settings.value("reqcSampling").toString().split("sec").first().toDouble();
+  _minEle         = settings.value("reqcMinEle").toDouble();
   _begTime        = bncTime(settings.value("reqcStartDateTime").toString().toLatin1().data());
   _endTime        = bncTime(settings.value("reqcEndDateTime").toString().toLatin1().data());
@@ -223,4 +224,10 @@
   t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _logStream);
 
+  // Read Ephemerides (needed to apply the elevation mask)
+  // ------------------------------------------------------
+  if (_minEle > 0.0 && _ephs.isEmpty()) {
+    t_reqcEdit::readEphemerides(_navFileNames, _ephs, _logStream, _checkEph);
+  }
+
   // Initialize output observation file
   // ----------------------------------
@@ -361,4 +368,7 @@
         if (sec % (int(_samplingRate)*10) == 0) {
           applyLLI(obsFile, epo);
+          if (_minEle > 0.0) {
+            applyElevationMask(obsFile, epo);
+          }
           outObsFile.writeEpoch(epo);
         }
@@ -518,4 +528,41 @@
 
   _lli.clear();
+}
+
+// Remove satellites below the minimum elevation angle
+////////////////////////////////////////////////////////////////////////////
+void t_reqcEdit::applyElevationMask(const t_rnxObsFile* obsFile,
+                                    t_rnxObsFile::t_rnxEpo* epo) {
+
+  const ColumnVector& xyzSta = obsFile->xyz();
+  if (xyzSta.size() != 3 || (xyzSta(1) == 0.0 && xyzSta(2) == 0.0 && xyzSta(3) == 0.0)) {
+    return;
+  }
+
+  std::vector<t_rnxObsFile::t_rnxSat> keptSats;
+  for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
+    const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
+
+    t_eph* eph = 0;
+    for (int ie = 0; ie < _ephs.size(); ie++) {
+      if (_ephs[ie]->prn() == rnxSat.prn) {
+        eph = _ephs[ie];
+        break;
+      }
+    }
+    if (eph) {
+      ColumnVector xc(6);
+      ColumnVector vv(3);
+      if (eph->getCrd(epo->tt, xc, vv, false) == success) {
+        double rho, eleSat, azSat;
+        topos(xyzSta(1), xyzSta(2), xyzSta(3), xc(1), xc(2), xc(3), rho, eleSat, azSat);
+        if (eleSat * 180.0/M_PI < _minEle) {
+          continue;
+        }
+      }
+    }
+    keptSats.push_back(rnxSat);
+  }
+  epo->rnxSat = keptSats;
 }
 
