00001 #pragma ident "$Id: RinexObsFilterOperators.hpp 2150 2009-10-26 15:39:25Z renfroba $"
00002
00003
00004
00010 #ifndef GPSTK_RINEXOBSFILTEROPERATORS_HPP
00011 #define GPSTK_RINEXOBSFILTEROPERATORS_HPP
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
00048
00049
00050
00051
00052
00053
00054 #include "FileFilter.hpp"
00055 #include "RinexObsData.hpp"
00056 #include "RinexObsHeader.hpp"
00057
00058 #include <set>
00059 #include <algorithm>
00060
00061 namespace gpstk
00062 {
00065
00068 struct RinexObsDataOperatorLessThanFull :
00069 public std::binary_function<gpstk::RinexObsData,
00070 gpstk::RinexObsData, bool>
00071 {
00072 public:
00076 RinexObsDataOperatorLessThanFull
00077 (const std::set<gpstk::RinexObsHeader::RinexObsType>& rohset)
00078 : obsSet(rohset)
00079 {}
00080
00081 bool operator()(const gpstk::RinexObsData& l,
00082 const gpstk::RinexObsData& r) const
00083 {
00084
00085
00086
00087 if (l.time < r.time)
00088 return true;
00089 else if (l.time == r.time)
00090 {
00091 if (l.epochFlag < r.epochFlag)
00092 return true;
00093 else if (l.epochFlag == r.epochFlag)
00094 {
00095 if (l.clockOffset < r.clockOffset)
00096 return true;
00097 else if (l.clockOffset > r.clockOffset)
00098 return false;
00099 }
00100 else
00101 return false;
00102 }
00103 else
00104 return false;
00105
00106
00107
00108 if (l.obs.size() < r.obs.size())
00109 return true;
00110
00111 if (l.obs.size() > r.obs.size())
00112 return false;
00113
00114
00115
00116 gpstk::RinexObsData::RinexSatMap::const_iterator lItr =
00117 l.obs.begin(), rItr;
00118
00119 gpstk::SatID sat;
00120
00121 while (lItr != l.obs.end())
00122 {
00123 sat = (*lItr).first;
00124 rItr = r.obs.find(sat);
00125 if (rItr == r.obs.end())
00126 return false;
00127
00128 gpstk::RinexObsData::RinexObsTypeMap
00129 lObs = (*lItr).second,
00130 rObs = (*rItr).second;
00131
00132 std::set<gpstk::RinexObsHeader::RinexObsType>::const_iterator obsItr =
00133 obsSet.begin();
00134
00135 while (obsItr != obsSet.end())
00136 {
00137 gpstk::RinexObsData::RinexDatum lData, rData;
00138 lData = lObs[*obsItr];
00139 rData = rObs[*obsItr];
00140
00141 if (lData.data < rData.data)
00142 return true;
00143
00144 if ( (lData.lli != 0) && (rData.lli != 0) )
00145 if (lData.lli < rData.lli)
00146 return true;
00147
00148 if ( (lData.ssi != 0) && (rData.ssi != 0) )
00149 if (lData.ssi < rData.ssi)
00150 return true;
00151
00152 obsItr++;
00153 }
00154
00155 lItr++;
00156 }
00157
00158
00159 return false;
00160 }
00161
00162 private:
00163 std::set<gpstk::RinexObsHeader::RinexObsType> obsSet;
00164 };
00165
00170 struct RinexObsDataOperatorLessThanSimple :
00171 public std::binary_function<gpstk::RinexObsData,
00172 gpstk::RinexObsData, bool>
00173 {
00174 public:
00175 bool operator()(const gpstk::RinexObsData& l,
00176 const gpstk::RinexObsData& r) const
00177 {
00178 if (l.time < r.time)
00179 return true;
00180 else if (l.time == r.time)
00181 {
00182 if (l.epochFlag < r.epochFlag)
00183 return true;
00184 }
00185 return false;
00186 }
00187 };
00188
00191 struct RinexObsDataOperatorEqualsSimple :
00192 public std::binary_function<gpstk::RinexObsData,
00193 gpstk::RinexObsData, bool>
00194 {
00195 public:
00196 bool operator()(const gpstk::RinexObsData& l,
00197 const gpstk::RinexObsData& r) const
00198 {
00199 if (l.time == r.time &&
00200 l.epochFlag == r.epochFlag)
00201 return true;
00202 return false;
00203 }
00204 };
00205
00213 struct RinexObsHeaderTouchHeaderMerge :
00214 public std::unary_function<gpstk::RinexObsHeader, bool>
00215 {
00216 public:
00217 RinexObsHeaderTouchHeaderMerge()
00218 : firstHeader(true)
00219 {}
00220
00221 bool operator()(const gpstk::RinexObsHeader& l)
00222 {
00223 if (firstHeader)
00224 {
00225 theHeader = l;
00226 firstHeader = false;
00227 }
00228 else
00229 {
00230 std::set<gpstk::RinexObsHeader::RinexObsType> thisObsSet,
00231 tempObsSet;
00232 std::set<std::string> commentSet;
00233 obsSet.clear();
00234
00235
00236
00237 copy(theHeader.commentList.begin(),
00238 theHeader.commentList.end(),
00239 inserter(commentSet, commentSet.begin()));
00240 copy(l.commentList.begin(),
00241 l.commentList.end(),
00242 inserter(commentSet, commentSet.begin()));
00243
00244 theHeader.commentList.clear();
00245 copy(commentSet.begin(), commentSet.end(),
00246 inserter(theHeader.commentList,
00247 theHeader.commentList.begin()));
00248
00249
00250 copy(theHeader.obsTypeList.begin(),
00251 theHeader.obsTypeList.end(),
00252 inserter(thisObsSet, thisObsSet.begin()));
00253 copy(l.obsTypeList.begin(),
00254 l.obsTypeList.end(),
00255 inserter(tempObsSet, tempObsSet.begin()));
00256 set_intersection(thisObsSet.begin(), thisObsSet.end(),
00257 tempObsSet.begin(), tempObsSet.end(),
00258 inserter(obsSet, obsSet.begin()));
00259
00260 theHeader.obsTypeList.clear();
00261 copy(obsSet.begin(), obsSet.end(),
00262 inserter(theHeader.obsTypeList,
00263 theHeader.obsTypeList.begin()));
00264 }
00265 return true;
00266 }
00267
00268 bool firstHeader;
00269 gpstk::RinexObsHeader theHeader;
00270 std::set<gpstk::RinexObsHeader::RinexObsType> obsSet;
00271 };
00272
00274
00275 }
00276
00277
00278 #endif