RinexNavFilterOperators.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: RinexNavFilterOperators.hpp 70 2006-08-01 18:36:21Z ehagen $"
00002 
00003 
00004 
00010 #ifndef GPSTK_RINEXNAVFILTEROPERATORS_HPP
00011 #define GPSTK_RINEXNAVFILTEROPERATORS_HPP
00012 
00013 //============================================================================
00014 //
00015 //  This file is part of GPSTk, the GPS Toolkit.
00016 //
00017 //  The GPSTk is free software; you can redistribute it and/or modify
00018 //  it under the terms of the GNU Lesser General Public License as published
00019 //  by the Free Software Foundation; either version 2.1 of the License, or
00020 //  any later version.
00021 //
00022 //  The GPSTk is distributed in the hope that it will be useful,
00023 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 //  GNU Lesser General Public License for more details.
00026 //
00027 //  You should have received a copy of the GNU Lesser General Public
00028 //  License along with GPSTk; if not, write to the Free Software Foundation,
00029 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00030 //  
00031 //  Copyright 2004, The University of Texas at Austin
00032 //
00033 //============================================================================
00034 
00035 //============================================================================
00036 //
00037 //This software developed by Applied Research Laboratories at the University of
00038 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00039 //Department of Defense. The U.S. Government retains all rights to use,
00040 //duplicate, distribute, disclose, or release this software. 
00041 //
00042 //Pursuant to DoD Directive 523024 
00043 //
00044 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00045 //                           release, distribution is unlimited.
00046 //
00047 //=============================================================================
00048 
00049 
00050 
00051 
00052 
00053 
00054 #include "FileFilter.hpp"
00055 #include "RinexNavData.hpp"
00056 #include "RinexNavHeader.hpp"
00057 
00058 #include <set>
00059 
00060 namespace gpstk
00061 {
00064 
00066    struct RinexNavDataOperatorLessThanFull : 
00067       public std::binary_function<gpstk::RinexNavData, 
00068          gpstk::RinexNavData, bool>
00069    {
00070    public:
00071       bool operator()(const gpstk::RinexNavData& l,
00072                       const gpstk::RinexNavData& r) const
00073          {
00074                      gpstk::DayTime lXmitTime(0.L);
00075             lXmitTime.setGPSfullweek(l.weeknum, (double)l.HOWtime);
00076             gpstk::DayTime rXmitTime(0.L);
00077             rXmitTime.setGPSfullweek(r.weeknum, (double)r.HOWtime);
00078 
00079             if (lXmitTime < rXmitTime)
00080                return true;
00081             else if (lXmitTime == rXmitTime)
00082             {
00083                   // compare the times and all data members
00084                if (l.time < r.time)
00085                   return true;
00086                else if (l.time == r.time)
00087                {
00088                   std::list<double>
00089                      llist = l.toList(),
00090                      rlist = r.toList();
00091                   
00092                   std::list<double>::iterator 
00093                      litr = llist.begin(), 
00094                      ritr = rlist.begin();
00095                   
00096                   while (litr != llist.end())
00097                   {
00098                      if (*litr < *ritr)
00099                         return true;
00100                      else if (*litr > *ritr)
00101                         return false;
00102                      else
00103                      {
00104                         litr++;
00105                         ritr++;
00106                      }
00107                   }
00108                }
00109             } // if (lXmitTime == rXmitTime)
00110 
00111             return false;
00112          }
00113    };
00114 
00116    struct RinexNavDataOperatorEqualsFull : 
00117       public std::binary_function<gpstk::RinexNavData, 
00118          gpstk::RinexNavData, bool>
00119    {
00120    public:
00121       bool operator()(const gpstk::RinexNavData& l,
00122                       const gpstk::RinexNavData& r) const
00123          {
00124                // compare the times and all data members
00125             if (l.time != r.time)
00126                return false;
00127             else // if (l.time == r.time)
00128             {
00129                std::list<double>
00130                   llist = l.toList(),
00131                   rlist = r.toList();
00132 
00133                std::list<double>::iterator 
00134                   litr = llist.begin(), 
00135                   ritr = rlist.begin();
00136 
00137                while (litr != llist.end())
00138                {
00139                   if (*litr != *ritr)
00140                      return false;
00141                   litr++;
00142                   ritr++;
00143                }
00144             }
00145 
00146             return true;
00147          }
00148    };
00149 
00151    struct RinexNavDataOperatorLessThanSimple : 
00152       public std::binary_function<gpstk::RinexNavData, 
00153          gpstk::RinexNavData, bool>
00154    {
00155    public:
00156       bool operator()(const gpstk::RinexNavData& l,
00157                       const gpstk::RinexNavData& r) const
00158          {
00159             gpstk::DayTime lXmitTime(0.L);
00160             lXmitTime.setGPSfullweek(l.weeknum, (double)l.HOWtime);
00161             gpstk::DayTime rXmitTime(0.L);
00162             rXmitTime.setGPSfullweek(r.weeknum, (double)r.HOWtime);
00163             if (lXmitTime < rXmitTime)
00164                return true;
00165             return false;
00166          }
00167    };
00168 
00175    struct RinexNavHeaderTouchHeaderMerge :
00176       public std::unary_function<gpstk::RinexNavHeader, bool>
00177    {
00178    public:
00179       RinexNavHeaderTouchHeaderMerge()
00180             : firstHeader(true)
00181          {}
00182 
00183       bool operator()(const gpstk::RinexNavHeader& l)
00184          {
00185             if (firstHeader)
00186             {
00187                theHeader = l;
00188                firstHeader = false;
00189             }
00190             else
00191             {
00192                std::set<std::string> commentSet;
00193 
00194                   // insert the comments to the set
00195                   // and let the set take care of uniqueness
00196                copy(theHeader.commentList.begin(),
00197                     theHeader.commentList.end(),
00198                     inserter(commentSet, commentSet.begin()));
00199                copy(l.commentList.begin(),
00200                     l.commentList.end(),
00201                     inserter(commentSet, commentSet.begin()));
00202                   // then copy the comments back into theHeader
00203                theHeader.commentList.clear();
00204                copy(commentSet.begin(), commentSet.end(),
00205                     inserter(theHeader.commentList,
00206                              theHeader.commentList.begin()));
00207             }
00208             return true;
00209          }
00210 
00211       bool firstHeader;
00212       gpstk::RinexNavHeader theHeader;
00213    };
00214 
00216    struct RinexNavDataFilterPRN : 
00217       public std::unary_function<gpstk::RinexNavData,  bool>
00218    {
00219    public:
00220       RinexNavDataFilterPRN(const std::list<long>& lst )
00221          :prnList(lst)
00222          {}
00224       bool operator()(const gpstk::RinexNavData& l) const
00225          {
00226             long testValue = (long) l.PRNID;
00227             return find(prnList.begin(), prnList.end(), testValue )
00228                                                        == prnList.end(); 
00229          }
00230    private:
00231       std::list<long> prnList;
00232    };
00233 
00235 
00236 }
00237 
00238 
00239 #endif
00240 

Generated on Tue May 22 03:31:01 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1