00001 #pragma ident "$Id: Rinex3ObsFilterOperators.hpp 3319 2012-09-19 16:58:10Z prestonherrmann $"
00002
00008 #ifndef GPSTK_RINEX3OBSFILTEROPERATORS_HPP
00009 #define GPSTK_RINEX3OBSFILTEROPERATORS_HPP
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include <set>
00048 #include <algorithm>
00049
00050 #include "FileFilter.hpp"
00051 #include "Rinex3ObsData.hpp"
00052 #include "Rinex3ObsHeader.hpp"
00053 #include "ObsID.hpp"
00054
00055 namespace gpstk
00056 {
00059
00062 struct Rinex3ObsDataOperatorLessThanFull :
00063 public std::binary_function<Rinex3ObsData, Rinex3ObsData, bool>
00064 {
00065 public:
00069 Rinex3ObsDataOperatorLessThanFull
00071 (const std::vector<ObsID>& rohset)
00072 : obsSet(rohset)
00073 {}
00074
00075 bool operator()(const Rinex3ObsData& l, const Rinex3ObsData& r) const
00076 {
00077
00078
00079
00080 if (l.time < r.time)
00081 return true;
00082 else if (l.time == r.time)
00083 {
00084 if (l.epochFlag < r.epochFlag)
00085 return true;
00086 else if (l.epochFlag == r.epochFlag)
00087 {
00088 if (l.clockOffset < r.clockOffset)
00089 return true;
00090 else if (l.clockOffset > r.clockOffset)
00091 return false;
00092 }
00093 else
00094 return false;
00095 }
00096 else
00097 return false;
00098
00099
00100
00101 if (l.obs.size() < r.obs.size())
00102 return true;
00103
00104 if (l.obs.size() > r.obs.size())
00105 return false;
00106
00107
00108
00109 Rinex3ObsData::DataMap::const_iterator lItr = l.obs.begin(), rItr;
00110
00111 SatID sat;
00112
00113 while (lItr != l.obs.end())
00114 {
00115 sat = (*lItr).first;
00116 rItr = r.obs.find(sat);
00117 if (rItr == r.obs.end())
00118 return false;
00119
00121 std::vector<Rinex3ObsData::RinexDatum> lObs = lItr->second,
00122 rObs = rItr->second;
00123
00126
00128 for(int i = 0; i < obsSet.size(); ++i)
00129 {
00130 Rinex3ObsData::RinexDatum lData, rData;
00132 lData = lObs[i];
00134 rData = rObs[i];
00135
00136 if (lData.data < rData.data)
00137 return true;
00138
00139 if ( lData.lli != 0 && rData.lli != 0 )
00140 if (lData.lli < rData.lli)
00141 return true;
00142
00143 if ( lData.ssi != 0 && rData.ssi != 0 )
00144 if (lData.ssi < rData.ssi)
00145 return true;
00146
00148 }
00149
00150 lItr++;
00151 }
00152
00153
00154 return false;
00155 }
00156
00157 private:
00159 std::vector<ObsID> obsSet;
00160 };
00161
00164 struct Rinex3ObsDataOperatorLessThanSimple :
00165 public std::binary_function<Rinex3ObsData, Rinex3ObsData, bool>
00166 {
00167 public:
00168 bool operator()(const Rinex3ObsData& l, const Rinex3ObsData& r) const
00169 {
00170 if (l.time < r.time)
00171 return true;
00172 return false;
00173 }
00174 };
00175
00178 struct Rinex3ObsDataOperatorEqualsSimple :
00179 public std::binary_function<Rinex3ObsData, Rinex3ObsData, bool>
00180 {
00181 public:
00182 bool operator()(const Rinex3ObsData& l, const Rinex3ObsData& r) const
00183 {
00184 if (l.time == r.time)
00185 return true;
00186 return false;
00187 }
00188 };
00189
00197 struct Rinex3ObsHeaderTouchHeaderMerge :
00198 public std::unary_function<Rinex3ObsHeader, bool>
00199 {
00200 public:
00201 Rinex3ObsHeaderTouchHeaderMerge()
00202 : firstHeader(true)
00203 {}
00204
00205 bool operator()(const Rinex3ObsHeader& l)
00206 {
00207 if (firstHeader)
00208 {
00209 theHeader = l;
00210 firstHeader = false;
00211 }
00212 else
00213 {
00214 std::vector<ObsID> thisObsSet, tempObsSet;
00215 std::set<std::string> commentSet;
00216 obsSet.clear();
00217
00218
00219
00220 copy(theHeader.commentList.begin(),
00221 theHeader.commentList.end(),
00222 inserter(commentSet, commentSet.begin()));
00223 copy(l.commentList.begin(),
00224 l.commentList.end(),
00225 inserter(commentSet, commentSet.begin()));
00226
00227 theHeader.commentList.clear();
00228 copy(commentSet.begin(), commentSet.end(),
00229 inserter(theHeader.commentList,
00230 theHeader.commentList.begin()));
00231
00232
00233 copy(theHeader.obsTypeList.begin(),
00234 theHeader.obsTypeList.end(),
00235 inserter(thisObsSet, thisObsSet.begin()));
00236 copy(l.obsTypeList.begin(),
00237 l.obsTypeList.end(),
00238 inserter(tempObsSet, tempObsSet.begin()));
00239 set_intersection(thisObsSet.begin(), thisObsSet.end(),
00240 tempObsSet.begin(), tempObsSet.end(),
00241 inserter(obsSet, obsSet.begin()));
00242
00243 theHeader.obsTypeList.clear();
00244 copy(obsSet.begin(), obsSet.end(),
00245 inserter(theHeader.obsTypeList,
00246 theHeader.obsTypeList.begin()));
00247 }
00248 return true;
00249 }
00250
00251 bool firstHeader;
00252 Rinex3ObsHeader theHeader;
00253 std::vector<ObsID> obsSet;
00254 };
00255
00257
00258 }
00259
00260 #endif // GPSTK_RINEX3OBSFILTEROPERATORS_HPP