JulianDayNum.hxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 //-----------------------------------------------------------------------------
00005 // CVS: $Revision: 6327 $, $Date: 2009-11-10 18:05:07 +0000 (Tue, 10 Nov 2009) $, $Author: EckhardSutorius $
00006 //-----------------------------------------------------------------------------
00007 #ifndef JULIANDAYNUM_H
00008 #define JULIANDAYNUM_H
00009 
00010 #include <cstdlib>
00011 
00012 #include "DataMethod.hxx"
00013 #include "DataOps.h"
00014 //-----------------------------------------------------------------------------
00016 template<typename DataType>
00017 class JulianDayNum : public DataMethod<DataType>
00018 {
00019 public:
00021   JulianDayNum() { DataMethod<DataType>::methodName = "JulianDayNum"; }
00022 
00024   virtual ~JulianDayNum() { }
00025 
00027   void setSource(IntMap& tbls, IntMap& cols, StringMap units)
00028   {
00029     utColno = cols[0];
00030     if (utColno < 0)
00031     {
00032       throw DataMethodException("JulianDayNum method. Couldn't source");
00033     }
00034   }
00035 
00037   void setTarget(IntMap& cols, StringMap units) { jdColno = cols[0]; }
00038 
00040   void doit(TableData<DataType>& data, int row1, int row2)
00041   {
00042     for (int rowNo = row1; rowNo < row2; ++rowNo)
00043     {
00044       std::string date;
00045       size_t found;
00046       data.value(utColno, rowNo, date);
00047       date.resize(10);
00048       found = date.find_first_of("-");
00049       while (found != string::npos)
00050       {
00051         date.erase(found,1);  
00052         found = date.find_first_of("-", found+1);
00053       }
00054       int utDate = atoi(date.c_str());
00055       int jdnum = DataOps::calcJulianDay(utDate);
00056       data.assign(jdColno, rowNo, jdnum);
00057     }
00058   }
00059 
00060   // No data from raw data included
00061   void doit2(TableData<DataType>& rawData, TableData<DataType>& data, int row1, int row2) { }
00062 
00063 private:
00064   int utColno;
00065   int jdColno;
00066 };
00067 //-----------------------------------------------------------------------------
00068 #endif
00069 //-----------------------------------------------------------------------------
00070 // Change log:
00071 //
00072 // 27-May-2004,  IAB: Original version.
00073 //  7-Apr-2008, ETWS: Upgraded to use new detection table layout.
Generated on Mon Oct 4 10:38:34 2010 for WfcamSrc by  doxygen 1.6.3