Rinex3NavFilterOperators.hpp

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

Generated on Sat May 18 03:31:09 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1