00001 #pragma ident "$Id: Decimate.cpp 1315 2008-07-25 18:35:21Z architest $" 00002 00009 //============================================================================ 00010 // 00011 // This file is part of GPSTk, the GPS Toolkit. 00012 // 00013 // The GPSTk is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU Lesser General Public License as published 00015 // by the Free Software Foundation; either version 2.1 of the License, or 00016 // any later version. 00017 // 00018 // The GPSTk is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU Lesser General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU Lesser General Public 00024 // License along with GPSTk; if not, write to the Free Software Foundation, 00025 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 // 00027 // Dagoberto Salazar - gAGE ( http://www.gage.es ). 2008 00028 // 00029 //============================================================================ 00030 00031 00032 #include "Decimate.hpp" 00033 00034 00035 namespace gpstk 00036 { 00037 00038 // Index initially assigned to this class 00039 int Decimate::classIndex = 8000000; 00040 00041 00042 // Returns an index identifying this object. 00043 int Decimate::getIndex(void) const 00044 { return index; } 00045 00046 00047 // Returns a string identifying this object. 00048 std::string Decimate::getClassName() const 00049 { return "Decimate"; } 00050 00051 00052 00053 /* Sets sampling interval. 00054 * 00055 * @param sampleInterval Sampling interval, in seconds. 00056 */ 00057 Decimate& Decimate::setSampleInterval(const double sampleInterval) 00058 { 00059 00060 // Make sure that sample interval is positive 00061 if( sampleInterval >= 0.0 ) 00062 { 00063 sampling = sampleInterval; 00064 } 00065 00066 return (*this); 00067 00068 } // End of method 'Decimate::setSampleInterval()' 00069 00070 00071 00072 /* Sets tolerance, in seconds. 00073 * 00074 * @param tol Tolerance, in seconds. 00075 */ 00076 Decimate& Decimate::setTolerance(const double tol) 00077 { 00078 00079 // Make sure that tolerance is positive 00080 if( tol >= 0.0 ) 00081 { 00082 tolerance = tol; 00083 } 00084 00085 return (*this); 00086 00087 } // End of method 'Decimate::setTolerance()' 00088 00089 00090 00091 /* Returns a satTypeValueMap object, adding the new data generated when 00092 * calling this object. 00093 * 00094 * @param time Epoch corresponding to the data. 00095 * @param gData Data object holding the data. 00096 */ 00097 satTypeValueMap& Decimate::Process( const DayTime& time, 00098 satTypeValueMap& gData ) 00099 throw(DecimateEpoch) 00100 { 00101 00102 // Set a threshold 00103 double threshold( std::abs(sampling - tolerance) ); 00104 00105 // Check if current epoch - lastEpoch is NOT within threshold, 00106 // implying that it must be decimated 00107 if ( !(std::abs(time - lastEpoch) > threshold) ) 00108 { 00109 00110 // If epoch must be decimated, we issue an Exception 00111 DecimateEpoch e("This epoch must be decimated."); 00112 00113 GPSTK_THROW(e); 00114 00115 } 00116 00117 // Update reference epoch 00118 lastEpoch = time; 00119 00120 return gData; 00121 00122 } // End of method 'Decimate::Process()' 00123 00124 00125 00126 } // End of namespace gpstk
1.3.9.1