HtmIndex.hxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 //-----------------------------------------------------------------------------
00005 // CVS: $Revision: 4695 $, $Date: 2008-04-09 16:18:42 +0100 (Wed, 09 Apr 2008) $, $Author: EckhardSutorius $
00006 //-----------------------------------------------------------------------------
00007 #ifndef HTMINDEX_H
00008 #define HTMINDEX_H
00009 
00010 #include "htm.h"
00011 
00012 #include "Constants.h"
00013 #include "Converter.h"
00014 #include "DataMethod.hxx"
00015 #include "Logger.h"
00016 #include "StringOps.h"
00017 //-----------------------------------------------------------------------------
00019 template<typename DataType>
00020 class HtmIndex : public DataMethod<DataType>
00021 {
00022 public:
00025   HtmIndex(int htmLevel)
00026   {
00027     DataMethod<DataType>::methodName = "HtmIndex";
00028     Logger log;
00029     log.addMessage("Making HTM indicies with level = "
00030                    + StringOps::NumToString(htmLevel));
00031     mHtmPtr = new SpatialIndex(htmLevel);
00032   }
00033 
00035   virtual ~HtmIndex() { delete mHtmPtr; }
00036 
00038   void setSource(IntMap& tbls, IntMap& cols, StringMap units)
00039   {
00040     raColno  = cols[0];
00041     decColno = cols[1];
00042     Converter converter;
00043     mDecFact = converter.getFactor(units[0], "Degrees");
00044     mRAFact  = converter.getFactor(units[1], "Degrees");
00045   }
00046 
00048   void setTarget(IntMap& cols, StringMap units)
00049   {
00050     htmColno = cols[0];
00051   }
00052 
00054   void doit(TableData<DataType>& data, int row1, int row2)
00055   {
00056     // Calculate HTM indices
00057     for (int rowNo = row1; rowNo < row2; ++rowNo)
00058     {
00059       double ra, dec;
00060       data.value(raColno, rowNo, ra);
00061       data.value(decColno, rowNo, dec);
00062 
00063       data.assign(htmColno, rowNo, static_cast<double>(
00064                     mHtmPtr->idByPoint(ra * mRAFact, dec * mDecFact)));
00065     }
00066   }
00067 
00068   // No data from raw data included
00069   void doit2(TableData<DataType>& rawData, TableData<DataType>& data, int row1, int row2) { }
00070 
00071 private:
00072   int htmColno;
00073   int raColno;
00074   int decColno;
00075   double mDecFact;
00076   double mRAFact;
00077   SpatialIndex* mHtmPtr;
00078 };
00079 //-----------------------------------------------------------------------------
00080 #endif
00081 //-----------------------------------------------------------------------------
00082 // Change log:
00083 //
00084 //  3-Jun-2004,  IAB: Original version.
00085 // 22-Mar-2007,  RSC: Robustified against dodgy WCS values.
00086 //  2-May-2007,  RSC: Reverted to original design of allowing dodgy WCS values.
00087 //  7-Apr-2008, ETWS: Upgraded to use new detection table layout.

Generated on Thu Apr 2 21:52:16 2009 for WfcamSrc by  doxygen 1.5.2