Catalog.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef CATALOG_H
00008 #define CATALOG_H
00009
00010 #include "DataBuilder.hxx"
00011 #include "InsertData.hxx"
00012 #include "TableInfo.h"
00013
00016 template<typename DataType>
00017 class Catalog : public DataBuilder<DataType>
00018 {
00019 public:
00021 Catalog(const TableInfo& aInfo)
00022 : mInfo(aInfo)
00023 { DataBuilder<DataType>::builderName = "Catalog"; }
00024
00026 virtual ~Catalog() {}
00027
00029 TableData<DataType>* build(FitsFile& fpix,
00030 FitsFile& fcat,
00031 int fileNo)
00032 {
00033
00034 int numSources = 0;
00035
00036 unsigned mValidExts = 0;
00037
00038 for (int hduNo = 2; hduNo <= fcat.getNumHdus(); ++hduNo)
00039 {
00040 fcat.movabsHdu(hduNo);
00041 int hduRowNum = fcat.getNumRows();
00042 numSources += hduRowNum;
00043 if (mInfo.isDetection() and hduRowNum > 0)
00044 {
00045 numSources += 1;
00046 mValidExts += 1;
00047 }
00048 }
00049
00050
00051 int numCols = mInfo.getNumAttributes();
00052 TableData<DataType>* data = new TableData<DataType>(numCols, numSources);
00053 data -> setNumExts(mValidExts);
00054
00055
00056 int firstRow = 0;
00057 int row1 = 0;
00058 for (int hduNo = 2; hduNo <= fcat.getNumHdus(); ++hduNo)
00059 {
00060 fcat.movabsHdu(hduNo);
00061
00062 int row2 = row1 + fcat.getNumRows();
00063 if (row2 != row1)
00064 {
00065 for (int rowNo = row1; rowNo < row2; ++rowNo)
00066 {
00067 insertFitsExtensionHeader(rowNo, fcat, mInfo, *data);
00068 }
00069
00070 insertFitsColumns(firstRow, fcat, mInfo, *data);
00071 firstRow += fcat.getNumRows();
00072 row1 = row2;
00073 }
00074 }
00075
00076 insertExtNum(fcat, mInfo, *data);
00077
00078 return data;
00079 }
00080
00081 private:
00082 TableInfo mInfo;
00083 };
00084
00085 #endif
00086
00087
00088
00089