ExtractData.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ExtractData.hpp 1889 2009-05-11 15:47:23Z afarris $"
00002 
00008 #ifndef ExtractData_GPSTK
00009 #define ExtractData_GPSTK
00010 
00011 //============================================================================
00012 //
00013 //  This file is part of GPSTk, the GPS Toolkit.
00014 //
00015 //  The GPSTk is free software; you can redistribute it and/or modify
00016 //  it under the terms of the GNU Lesser General Public License as published
00017 //  by the Free Software Foundation; either version 2.1 of the License, or
00018 //  any later version.
00019 //
00020 //  The GPSTk is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 //  GNU Lesser General Public License for more details.
00024 //
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with GPSTk; if not, write to the Free Software Foundation,
00027 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //  
00029 //  Dagoberto Salazar - gAGE. 2006
00030 //
00031 //============================================================================
00032 
00033 
00034 
00035 #include "Exception.hpp"
00036 #include "RinexObsHeader.hpp"
00037 #include "RinexObsData.hpp"
00038 #include "CheckPRData.hpp"
00039 #include "Vector.hpp"
00040 
00041 
00042 namespace gpstk
00043 {
00046     NEW_EXCEPTION_CLASS(InvalidData, gpstk::Exception);
00047 
00048 
00051 
00052 
00054     class ExtractData
00055     {
00056     public:
00057 
00059         inline bool isValid(void)
00060             { return valid; }
00061 
00062 
00064         int numSV;
00065 
00066 
00068         Vector<SatID> availableSV;
00069 
00070 
00072         Vector<double> obsData;
00073 
00074 
00076         ExtractData() throw(InvalidData) : checkData(true), valid(false), minPRange(15000000.0), maxPRange(30000000.0) {};
00077 
00078 
00086         inline virtual int getData(const RinexObsData& rinexData, RinexObsHeader::RinexObsType typeObs) throw(InvalidData)
00087         {
00088         try {
00089             // Let's make sure each time we start with clean Vectors
00090             availableSV.resize(0);
00091             obsData.resize(0);
00092 
00093             // Create a CheckPRData object with the given limits
00094             CheckPRData checker(minPRange, maxPRange);
00095 
00096             // Let's define the "it" iterator to visit the observations PRN map
00097             // RinexSatMap is a map from SatID to RinexObsTypeMap: 
00098             //      std::map<SatID, RinexObsTypeMap>
00099             RinexObsData::RinexSatMap::const_iterator it;
00100             for (it = rinexData.obs.begin(); it!= rinexData.obs.end(); it++) 
00101             {
00102                 // RinexObsTypeMap is a map from RinexObsType to RinexDatum:
00103                 //   std::map<RinexObsHeader::RinexObsType, RinexDatum>
00104                 RinexObsData::RinexObsTypeMap otmap;
00105                 // Let's define a iterator to visit the observations type map
00106                 RinexObsData::RinexObsTypeMap::const_iterator itObs1;
00107                 // The "second" field of a RinexSatMap (it) is a RinexObsTypeMap (otmap)
00108                 otmap = (*it).second;
00109 
00110                 // Let's find the observation type inside the RinexObsTypeMap that is "otmap"
00111                 itObs1 = otmap.find(typeObs);
00112 
00113                 // Let's check if we found this type of observation and it is between the limits
00114                 if ( (itObs1!=otmap.end()) && ( (checker.check((*itObs1).second.data)) || !(checkData) ) )
00115                 {
00116                     // Store all relevant data of this epoch
00117                     availableSV = availableSV && (*it).first;
00118                     obsData = obsData && (*itObs1).second.data;
00119                 }
00120             } // End of data extraction from this epoch
00121         }
00122         catch(...) {
00123             InvalidData e("Unable to get data from RinexObsData object");
00124             GPSTK_THROW(e);
00125         }
00126 
00127         // Let's record the number of SV with this type of data available
00128         numSV = (int)obsData.size();
00129 
00130         // If everything is fine so far, then the results should be valid
00131         valid = true;
00132 
00133         return numSV;
00134 
00135         };  // end ExtractData::getData()
00136 
00137 
00139         bool checkData;
00140 
00142         virtual void setMinPRange(const double minPR) { minPRange = minPR; };
00143 
00145         virtual double getMinPRange(void) { return minPRange; };
00146 
00148         virtual void setMaxPRange(const double maxPR) { maxPRange = maxPR; };
00149 
00151         virtual double getMaxPRange(void) { return maxPRange; };
00152 
00153 
00155         inline virtual ~ExtractData() {};
00156 
00157 
00158     protected:
00160         bool valid;
00161 
00163         double minPRange;
00164 
00166         double maxPRange;
00167 
00168 
00169    }; // end class ExtractData
00170    
00171 
00173    
00174 }
00175 
00176 #endif

Generated on Wed Feb 8 03:30:59 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1