From 58c0e8e4fbb235b6c1acfdbdb918672d7700d836 Mon Sep 17 00:00:00 2001
From: joanvallve <jvallve@iri.upc.edu>
Date: Wed, 31 Mar 2021 17:18:23 +0200
Subject: [PATCH] filter snapshot filters ranges and satellites too

---
 include/gnss_utils/snapshot.h | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/include/gnss_utils/snapshot.h b/include/gnss_utils/snapshot.h
index 84bbcb0..49a1675 100644
--- a/include/gnss_utils/snapshot.h
+++ b/include/gnss_utils/snapshot.h
@@ -133,7 +133,15 @@ inline std::set<int> Snapshot::filterObservations(const std::set<int>&      disc
                                                   const bool&               check_carrier_phase,
                                                   const Options&            opt)
 {
-    return obs_->filter(sats_, discarded_sats, x_r, check_code, check_carrier_phase, opt);
+    std::set<int> filtered_sats = obs_->filter(sats_, discarded_sats, x_r, check_code, check_carrier_phase, opt);
+
+    for (auto sat : filtered_sats)
+    {
+        sats_.erase(sat);
+        ranges_.erase(sat);
+    }
+
+    return filtered_sats;
 }
 
 inline std::set<int> Snapshot::filterObservations(const std::set<int>&  discarded_sats,
@@ -142,7 +150,15 @@ inline std::set<int> Snapshot::filterObservations(const std::set<int>&  discarde
                                                   const bool&           check_carrier_phase,
                                                   const Options&        opt)
 {
-    return obs_->filter(sats_, discarded_sats, azels, check_code, check_carrier_phase, opt);
+    std::set<int> filtered_sats = obs_->filter(sats_, discarded_sats, azels, check_code, check_carrier_phase, opt);
+
+    for (auto sat : filtered_sats)
+    {
+        sats_.erase(sat);
+        ranges_.erase(sat);
+    }
+
+    return filtered_sats;
 }
 
 inline const Ranges& Snapshot::getRanges() const
-- 
GitLab