Rinex3NavFilterOperators.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
44 #ifndef GNSSTK_RINEX3NAVFILTEROPERATORS_HPP
45 #define GNSSTK_RINEX3NAVFILTEROPERATORS_HPP
46 
47 #include <set>
48 #include <list>
49 #include <string>
50 
51 #include "FileFilter.hpp"
52 #include "Rinex3NavData.hpp"
53 #include "Rinex3NavHeader.hpp"
54 #include "GPSWeekSecond.hpp"
55 #include <math.h>
56 
57 namespace gnsstk
58 {
60 
61 
64  public std::binary_function<Rinex3NavData, Rinex3NavData, bool>
65  {
66  public:
69  : epsilon(1e-5)
70  {}
71 
76  void setPrecision(int e)
77  {
78  epsilon = std::pow(10.0, -e);
79  }
80 
88  bool operator()(const Rinex3NavData& l, const Rinex3NavData& r) const
89  {
90  GPSWeekSecond lXmitTime(l.weeknum, (double)l.xmitTime);
91  GPSWeekSecond rXmitTime(r.weeknum, (double)r.xmitTime);
92 
93  if (lXmitTime < rXmitTime)
94  {
95  return true;
96  }
97  else if (lXmitTime == rXmitTime)
98  {
99  // compare the times and all data members
100  if (l.time < r.time)
101  {
102  return true;
103  }
104  else if (r.time < l.time)
105  {
106  return false;
107  }
108  else if (l.sat < r.sat)
109  {
110  return true;
111  }
112  else if (r.sat < l.sat)
113  {
114  return false;
115  }
116  else
117  {
118  std::list<double>
119  llist = l.toList(),
120  rlist = r.toList();
121 
122  std::list<double>::iterator
123  litr = llist.begin(),
124  ritr = rlist.begin();
125 
126  while (litr != llist.end())
127  {
128  // Compare the two values against each other,
129  // with an epsilon-sized slop.
130  double diff = *litr - *ritr;
131  double err = (*litr == 0 ? *ritr : (diff/(*litr)));
132  if (err > epsilon)
133  {
134  return true;
135  }
136  else if (err < -epsilon)
137  {
138  return false;
139  }
140  else
141  {
142  litr++;
143  ritr++;
144  }
145  }
146  }
147  } // if (lXmitTime == rXmitTime)
148  return false;
149  }
150  private:
152  double epsilon;
153  };
154 
157  public std::binary_function<Rinex3NavData, Rinex3NavData, bool>
158  {
159  public:
160 
161  bool operator()(const Rinex3NavData& l, const Rinex3NavData& r) const
162  {
163  // compare the times and all data members
164  if (l.time != r.time)
165  return false;
166  else // if (l.time == r.time)
167  {
168  std::list<double>
169  llist = l.toList(),
170  rlist = r.toList();
171 
172  std::list<double>::iterator
173  litr = llist.begin(),
174  ritr = rlist.begin();
175 
176  while (litr != llist.end())
177  {
178  if (*litr != *ritr)
179  return false;
180  litr++;
181  ritr++;
182  }
183  }
184 
185  return true;
186  }
187  };
188 
191  public std::binary_function<Rinex3NavData, Rinex3NavData, bool>
192  {
193  public:
194 
195  bool operator()(const Rinex3NavData& l, const Rinex3NavData& r) const
196  {
197  GPSWeekSecond lXmitTime(l.weeknum, static_cast<double>(l.xmitTime));
198  GPSWeekSecond rXmitTime(r.weeknum, static_cast<double>(r.xmitTime));
199  if (lXmitTime < rXmitTime)
200  return true;
201  return false;
202  }
203  };
204 
211  public std::unary_function<Rinex3NavHeader, bool>
212  {
213  public:
214 
216  : firstHeader(true)
217  {}
218 
220  {
221  if (firstHeader)
222  {
223  theHeader = l;
224  firstHeader = false;
225  }
226  else
227  {
228  std::set<std::string> commentSet;
229 
230  // insert the comments to the set
231  // and let the set take care of uniqueness
232  copy(theHeader.commentList.begin(),
233  theHeader.commentList.end(),
234  inserter(commentSet, commentSet.begin()));
235  copy(l.commentList.begin(),
236  l.commentList.end(),
237  inserter(commentSet, commentSet.begin()));
238  // then copy the comments back into theHeader
239  theHeader.commentList.clear();
240  copy(commentSet.begin(), commentSet.end(),
241  inserter(theHeader.commentList,
242  theHeader.commentList.begin()));
243  }
244  return true;
245  }
246 
249  };
250 
253  public std::unary_function<Rinex3NavData, bool>
254  {
255  public:
256 
257  Rinex3NavDataFilterPRN(const std::list<long>& lst )
258  :prnList(lst)
259  {}
260 
262  bool operator()(const Rinex3NavData& l) const
263  {
264  long testValue = (long) l.PRNID;
265  return find(prnList.begin(), prnList.end(), testValue )
266  == prnList.end();
267  }
268 
269  private:
270 
271  std::list<long> prnList;
272 
273  };
274 
276 
277 }
278 
279 #endif // GNSSTK_RINEX3NAVFILTEROPERATORS_HPP
gnsstk::Rinex3NavDataOperatorEqualsFull::operator()
bool operator()(const Rinex3NavData &l, const Rinex3NavData &r) const
Definition: Rinex3NavFilterOperators.hpp:161
gnsstk::Rinex3NavDataOperatorLessThanFull::Rinex3NavDataOperatorLessThanFull
Rinex3NavDataOperatorLessThanFull()
Set the default epsilon to 1e-5 for comparison.
Definition: Rinex3NavFilterOperators.hpp:68
Rinex3NavHeader.hpp
gnsstk::Rinex3NavDataFilterPRN
Filter based on PRN ID.
Definition: Rinex3NavFilterOperators.hpp:252
gnsstk::Rinex3NavData
Definition: Rinex3NavData.hpp:69
gnsstk::Rinex3NavData::time
CommonTime time
Time according to the sat/epoch record (TOC)
Definition: Rinex3NavData.hpp:122
gnsstk::Rinex3NavDataFilterPRN::prnList
std::list< long > prnList
Definition: Rinex3NavFilterOperators.hpp:271
gnsstk::Rinex3NavHeaderTouchHeaderMerge::Rinex3NavHeaderTouchHeaderMerge
Rinex3NavHeaderTouchHeaderMerge()
Definition: Rinex3NavFilterOperators.hpp:215
gnsstk::Rinex3NavHeader::commentList
std::vector< std::string > commentList
Definition: Rinex3NavHeader.hpp:185
gnsstk::Rinex3NavData::toList
std::list< double > toList() const
Definition: Rinex3NavData.cpp:502
gnsstk::Rinex3NavDataOperatorLessThanFull
This compares all elements of the Rinex3NavData with less than.
Definition: Rinex3NavFilterOperators.hpp:63
FileFilter.hpp
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::GPSWeekSecond
Definition: GPSWeekSecond.hpp:56
Rinex3NavData.hpp
gnsstk::Rinex3NavDataFilterPRN::Rinex3NavDataFilterPRN
Rinex3NavDataFilterPRN(const std::list< long > &lst)
Definition: Rinex3NavFilterOperators.hpp:257
gnsstk::Rinex3NavDataOperatorLessThanFull::epsilon
double epsilon
Value used to allow some "slop" in measuring equality in operator()
Definition: Rinex3NavFilterOperators.hpp:152
gnsstk::Rinex3NavDataFilterPRN::operator()
bool operator()(const Rinex3NavData &l) const
This should return true when the data are to be erased.
Definition: Rinex3NavFilterOperators.hpp:262
gnsstk::Rinex3NavDataOperatorLessThanSimple::operator()
bool operator()(const Rinex3NavData &l, const Rinex3NavData &r) const
Definition: Rinex3NavFilterOperators.hpp:195
gnsstk::Rinex3NavData::PRNID
short PRNID
SV PRN ID.
Definition: Rinex3NavData.hpp:124
gnsstk::Rinex3NavHeader
Definition: Rinex3NavHeader.hpp:107
gnsstk::Rinex3NavDataOperatorLessThanSimple
Only compares time. Suitable for sorting a Rinex3Nav file.
Definition: Rinex3NavFilterOperators.hpp:190
gnsstk::Rinex3NavHeaderTouchHeaderMerge::theHeader
Rinex3NavHeader theHeader
Definition: Rinex3NavFilterOperators.hpp:248
example4.err
err
Definition: example4.py:126
gnsstk::Rinex3NavDataOperatorLessThanFull::operator()
bool operator()(const Rinex3NavData &l, const Rinex3NavData &r) const
Definition: Rinex3NavFilterOperators.hpp:88
gnsstk::Rinex3NavHeaderTouchHeaderMerge
Definition: Rinex3NavFilterOperators.hpp:210
gnsstk::Rinex3NavData::weeknum
short weeknum
Definition: Rinex3NavData.hpp:127
GPSWeekSecond.hpp
gnsstk::Rinex3NavHeaderTouchHeaderMerge::firstHeader
bool firstHeader
Definition: Rinex3NavFilterOperators.hpp:247
gnsstk::Rinex3NavDataOperatorLessThanFull::setPrecision
void setPrecision(int e)
Definition: Rinex3NavFilterOperators.hpp:76
gnsstk::Rinex3NavData::sat
RinexSatID sat
RinexSatID (from PRNID & satSys)
Definition: Rinex3NavData.hpp:125
gnsstk::Rinex3NavData::xmitTime
long xmitTime
Time of subframe 1-3 (sec of week)
Definition: Rinex3NavData.hpp:126
gnsstk::Rinex3NavDataOperatorEqualsFull
This compares all elements of the Rinex3NavData with equals.
Definition: Rinex3NavFilterOperators.hpp:156
gnsstk::Rinex3NavHeaderTouchHeaderMerge::operator()
bool operator()(const Rinex3NavHeader &l)
Definition: Rinex3NavFilterOperators.hpp:219


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:40