FICFilterOperators.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: FICFilterOperators.hpp 2435 2010-06-04 15:08:49Z afarris $"
00002 
00003 
00004 
00010 //============================================================================
00011 //
00012 //  This file is part of GPSTk, the GPS Toolkit.
00013 //
00014 //  The GPSTk is free software; you can redistribute it and/or modify
00015 //  it under the terms of the GNU Lesser General Public License as published
00016 //  by the Free Software Foundation; either version 2.1 of the License, or
00017 //  any later version.
00018 //
00019 //  The GPSTk is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU Lesser General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU Lesser General Public
00025 //  License along with GPSTk; if not, write to the Free Software Foundation,
00026 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 //  
00028 //  Copyright 2004, The University of Texas at Austin
00029 //
00030 //============================================================================
00031 
00032 //============================================================================
00033 //
00034 //This software developed by Applied Research Laboratories at the University of
00035 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00036 //Department of Defense. The U.S. Government retains all rights to use,
00037 //duplicate, distribute, disclose, or release this software. 
00038 //
00039 //Pursuant to DoD Directive 523024 
00040 //
00041 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00042 //                           release, distribution is unlimited.
00043 //
00044 //=============================================================================
00045 
00046 
00047 
00048 
00049 
00050 
00051 #ifndef FICFILTEROPERATORS_HPP
00052 #define FICFILTEROPERATORS_HPP
00053 
00054 #include "FileFilter.hpp"
00055 #include "FICData.hpp"
00056 
00057 namespace gpstk
00058 {
00060    struct FICDataFilterPRN :
00061       public std::unary_function<gpstk::FICData, bool>
00062    {
00063    public:
00064       FICDataFilterPRN(const std::list<long>& lst)
00065          : prnList(lst)
00066          {}
00067 
00069       bool operator() (const gpstk::FICData& l) const
00070          {
00071                // this criteria is the same as the r44 navdump criteria
00072             switch (l.blockNum)
00073             {
00074                case 9:
00075                   return find(prnList.begin(), prnList.end(), l.f[19]) ==
00076                      prnList.end();
00077                   break;
00078 
00079                case 109:
00080                   return find(prnList.begin(), prnList.end(), l.i[1]) ==
00081                      prnList.end();
00082                   break;
00083 
00084                      // For 62 and 162, all SVIDs 51-63 will be added
00085                      //  as well as any PRNs 1-32 that were selected.
00086 
00087                case 62:
00088                   return find(prnList.begin(), prnList.end(), l.i[3]) ==
00089                      prnList.end();
00090                   
00091                   break;
00092 
00093                case 162:
00094                   return find(prnList.begin(), prnList.end(), l.i[0]) ==
00095                      prnList.end();
00096                   break;
00097 
00098                default:
00099                   return true;
00100                   break;
00101             }
00102          }
00103 
00104    private:
00105       std::list<long> prnList;
00106    };
00107 
00109    struct FICDataFilterBlock :
00110       public std::unary_function<gpstk::FICData, bool>
00111    {
00112    public:
00113       FICDataFilterBlock(const std::list<long>& lst)
00114          : blockList(lst)
00115          {}
00116 
00118       bool operator() (const gpstk::FICData& l) const
00119          {
00120             return find(blockList.begin(), blockList.end(), l.blockNum) ==
00121                blockList.end();
00122          }
00123 
00124    private:
00125       std::list<long> blockList;
00126    };
00127 
00128    struct FICDataFilterStartTime :
00129       public std::unary_function<gpstk::FICData, bool>
00130    {
00131    public:
00132       FICDataFilterStartTime(const gpstk::DayTime start)
00133          : stime(start)
00134          {}
00135 
00137       bool operator() (const gpstk::FICData& l) const
00138          {
00139             DayTime dt(0,0.0);
00140             if(l.getTransmitTime(dt)) //if valid trasmit time
00141               return dt <= stime;
00142             else
00143               return true; // exclude data if no transmit time
00144          }
00145 
00146    private:
00147       gpstk::DayTime stime;
00148    };
00149 
00150    struct FICDataFilterEndTime :
00151       public std::unary_function<gpstk::FICData, bool>
00152    {
00153    public:
00154       FICDataFilterEndTime(const gpstk::DayTime end)
00155          : etime(end)
00156          {}
00157 
00159       bool operator() (const gpstk::FICData& l) const
00160          {
00161             DayTime dt(0,0.0);
00162             if(l.getTransmitTime(dt)) //if valid trasmit time
00163               return dt >= etime;
00164             else
00165               return true; // exclude data if no transmit time
00166          }
00167 
00168    private:
00169       gpstk::DayTime etime;
00170    };
00171 
00173    struct FICDataFindBlock :
00174       public std::unary_function<gpstk::FICData, bool>
00175    {
00176    public:
00177       FICDataFindBlock(const std::list<long>& lst)
00178          : blockList(lst)
00179          {}
00180 
00181       bool operator() (const gpstk::FICData& l) const
00182          {
00183             return find(blockList.begin(), blockList.end(), l.blockNum) !=
00184                blockList.end();
00185          }
00186    private:
00187       std::list<long> blockList;
00188    };
00189 
00191    struct FICDataOperatorLessThanBlock9 : 
00192       public std::binary_function<gpstk::FICData, gpstk::FICData, bool>
00193    {
00194    public:
00195       bool operator() (const gpstk::FICData& l, 
00196                        const gpstk::FICData& r) const
00197          {
00198             if ( (l.blockNum != 9) || (r.blockNum != 9) )
00199                return false;
00200 
00201                // sort by transmit time, prn
00202             if (l.f[5] < r.f[5])
00203                return true;
00204             else if (l.f[5] == r.f[5])
00205                if (l.f[33] < r.f[33])
00206                   return true;
00207                else if (l.f[33] == r.f[33])
00208                   if (l.f[19] < r.f[19])
00209                      return true;
00210             
00211             return false;
00212          }
00213    };
00214 
00216    struct FICDataOperatorLessThanBlock109 :
00217       public std::binary_function<gpstk::FICData, gpstk::FICData, bool>
00218    {
00219    public:
00220       bool operator() (const gpstk::FICData& l, 
00221                        const gpstk::FICData& r) const
00222          {
00223             if ( (l.blockNum != 109) || (r.blockNum != 109) )
00224                return false;
00225 
00226                // sort by transmit time, prn
00227             if(l.i[0] < r.i[0])  // week numbers
00228                return true;
00229             else if(l.i[0] == r.i[0])
00230             {
00231                   // crack the HOW.  Note: I know I'm not multiplying by 6.
00232                if( ((l.i[3] >> 13) & 0x1FFFF) < 
00233                    ((r.i[3] >> 13) & 0x1FFFF) )
00234                   return true;
00235                else if( ((l.i[3] >> 13) & 0x1FFFF) == 
00236                         ((r.i[3] >> 13) & 0x1FFFF) )
00237                   if(l.i[1] < r.i[1])
00238                      return true;
00239             }
00240                
00241             return false;
00242          }
00243    };
00244 
00246    struct FICDataOperatorLessThanFull : 
00247       public std::binary_function<gpstk::FICData, gpstk::FICData, bool>
00248    {
00249    public:
00250       bool operator() (const gpstk::FICData& l, 
00251                        const gpstk::FICData& r) const
00252          {
00253             if (l.blockNum < r.blockNum)
00254                return true;
00255             if (l.blockNum > r.blockNum)
00256                return false;
00257 
00258             if ( (l.f.size() < r.f.size()) ||
00259                  (l.i.size() < r.i.size()) ||
00260                  (l.c.size() < r.c.size()))
00261                return true;
00262 
00263             if ( (l.f.size() > r.f.size()) ||
00264                  (l.i.size() > r.i.size()) ||
00265                  (l.c.size() > r.c.size()))
00266                return false;
00267             
00268                // ok, they're the same block and type of data - check
00269                // the individual contents
00270             std::vector<double>::size_type findex;
00271             for (findex = 0; findex < l.f.size(); findex++)
00272             {
00273                if (l.f[findex] < r.f[findex])
00274                   return true;
00275                if (l.f[findex] > r.f[findex])
00276                   return false;
00277             }
00278 
00279             std::vector<long>::size_type iindex;
00280             for (iindex = 0; iindex < l.i.size(); iindex++)
00281             {
00282                if (l.i[iindex] < r.i[iindex])
00283                   return true;
00284                if (l.i[iindex] > r.i[iindex])
00285                   return false;
00286             }
00287 
00288             std::vector<char>::size_type cindex;
00289             for (cindex = 0; cindex < l.c.size(); cindex++)
00290             {
00291                if (l.c[cindex] < r.c[cindex])
00292                   return true;
00293                if (l.c[cindex] > r.c[cindex])
00294                   return false;
00295             }
00296                // they're equal
00297             return false;
00298          }
00299    };
00300 
00302    struct FICDataUniqueBlock9 : 
00303       public std::binary_function<gpstk::FICData, gpstk::FICData, bool>
00304    {
00305    public:
00306       bool operator() (const gpstk::FICData& l, 
00307                        const gpstk::FICData& r) const
00308          {
00309             if ( (l.blockNum != 9) || (r.blockNum != 9) )
00310                return false;
00311                // the unique criteria are PRN, week, IODC, AS/alert bits
00312             return ( (l.f[19] == r.f[19]) &&
00313                      (l.f[3] == r.f[3]) &&
00314                      (l.f[5] == r.f[5]) &&
00315                      (l.f[23] == r.f[23]) &&
00316                      (l.f[43] == r.f[43]) &&
00317                      ( (l.f[9] / 2048) == (r.f[9] / 2048) ) );
00318          }
00319    };
00320 
00322    struct FICDataUniqueBlock109 : 
00323       public std::binary_function<gpstk::FICData, gpstk::FICData, bool>
00324    {
00325    public:
00326       bool operator() (const gpstk::FICData& l, 
00327                        const gpstk::FICData& r) const
00328       {
00329          if ( (l.blockNum != 109) || (r.blockNum != 109) )
00330             return false;
00331             // the unique criteria are PRN, week, IODC, AS/alert bits
00332          return ( (l.i[1] == r.i[1]) &&
00333                   (l.i[0] == r.i[0]) &&
00334                      // crack IODC on subframe 1
00335                   ((((l.i[4] << 2) & 0x00000300) + ((l.i[9] >> 22) & 0xFF)) ==
00336                    (((r.i[4] << 2) & 0x00000300) + ((r.i[9] >> 22) & 0xFF))) &&
00337                       // crack AS/Alert on subframe 1
00338                   ( ((l.i[4] >> 11) & 0x3) == ((r.i[4] >> 11) & 0x3) ) &&
00339                      // crack AS/Alert on subframe 2
00340                   ( ((l.i[14] >> 11) & 0x3) == ((r.i[14] >> 11) & 0x3) ) &&
00341                      // crack AS/Alert on subframe 3
00342                   ( ((l.i[24] >> 11) & 0x3) == ((r.i[24] >> 11) & 0x3) ) );
00343       }
00344    };
00345    
00347    struct FICDataUniqueBlock62:
00348       public std::binary_function<gpstk::FICData, gpstk::FICData, bool>
00349    {
00350    public:
00351       bool operator() (const gpstk::FICData& l,
00352                        const gpstk::FICData& r) const
00353          {
00354                // the unique criteria are:
00355                         // SV ID - dimensionless
00356             return ( (l.i[3] == r.i[3]) &&
00357                         // transmit week
00358                      (l.i[5] == r.i[5]) &&
00359                         // reference week - full GPS week number
00360                      (l.f[18] == r.f[18]) &&
00361                         // toa (time of epoch) - GPS sec of week
00362                      (l.f[8] == r.f[8]) &&
00363                         // AS/alert bit - dimensionless
00364                      (l.f[3] == r.f[3]) );         
00365          }   
00366    };
00367    
00369    struct FICDataUniqueBlock162:
00370       public std::binary_function<gpstk::FICData, gpstk::FICData, bool>
00371    {
00372    public:
00373       bool operator() (const gpstk::FICData& l,
00374                        const gpstk::FICData& r) const
00375          {
00376                // the unique criteria are: 
00377                         // SV ID  - dimensionless
00378             return ( (l.i[0] == r.i[0]) &&
00379                         // transmit week
00380                      (l.i[14] == r.i[14]) &&
00381                         // reference week - full GPS week number
00382                      (l.i[13] == r.i[13]) &&
00383                         // toa (time of week) - GPS sec week
00384                      ((((l.i[2] & 0x3FFFFFFFL) >> 13) * 6) == 
00385                       (((r.i[2] & 0x3FFFFFFFL) >> 13) * 6)) );       
00386          }   
00387    };
00388    
00389 }
00390 
00391 #endif
00392 

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