Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

omgclimatefilereader.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Tim Sutton   *
00003  *   tim@linfiniti.com   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef _OMGCLIMATEFILEREADER_H_
00021 #define _OMGCLIMATEFILEREADER_H_
00022 
00023 #include <QFile>
00024 #include <QString>
00025 #include <QVector>
00026 #include <QMap>
00027 #include <QTextStream>
00028 #include <fstream>
00029 #include <iostream>
00030 //other includes
00031 #include <gdal_priv.h>
00032 
00037 class OMG_LIB_EXPORT OmgClimateFileReader : public QObject
00038 {
00039   Q_OBJECT;
00040 
00041 public:
00042 
00043   //
00044   // Enumerators
00045   //
00049   enum FileType { GDAL,
00050     HADLEY_SRES,
00051     HADLEY_IS92,
00052     HADLEY_SRES_MEAN,
00053     IPCC_OBSERVED,
00054     VALDES,
00055     ECHAM4,
00056     CSIRO_MK2,
00057     NCAR_CSM_PCM,
00058     GFDL_R30,
00059     CGCM2,
00060     CCSR_AGCM_OGCM,
00061     CRU_CL1_MONTHLY };
00062 
00063 
00064   //
00065   //   Public methods
00066   //
00067 
00069   OmgClimateFileReader();
00070 
00072   OmgClimateFileReader(QString theFileName,FileType theFileType);
00073 
00075   ~OmgClimateFileReader();
00076 
00082   bool initialise(QString theFileNameString, FileType theFileType);
00083 
00089   float getElement();
00090 
00096   const long currentElementNo();
00097 
00102   const long currentRow();
00103 
00108   const long currentCol();
00109 
00110 
00115   const int headerLineCount();
00116 
00126   bool setActiveBlock( const unsigned int theBlockNo);
00127 
00134   const int activeBlock();
00135 
00136 
00141   const bool isAtMatrixEnd();
00142 
00143 
00148   const QString  filename();
00149 
00150 
00151 
00159   const OmgClimateFileReader::FileType getFileType();
00160 
00162   const long yDim();
00164   const long xDim();
00166   const int blockHeaderLineCount();
00168   QString getOmgClimateFileReaderInfo();
00170   const int blockStartPos();
00172   bool moveToHeader();
00174   const int blockCount();
00176   int getNumberOfBlocks();
00183   void printFirstCellInEachBlock();
00191   void printLastCellInEachBlock();
00197   void printBlockMarkers();
00201   void printBlock(int theBlock);
00202 signals:
00203   void error (QString theError);
00204   void message (QString theMessage);
00205 
00206 private:
00207 
00214   bool setFileType( const FileType theNewVal);
00228   QVector <int> getBlockMarkers(bool forceFlag=false);
00229 
00236   double readValue ( void *theData, GDALDataType theType, int theIndex );
00237 
00238   //
00239   //   Private attributes
00240   //
00242   static const unsigned int mMaxLineLength=100;
00244   unsigned int mXDim;
00246   unsigned int mYDim;
00248   FileType mFileType;
00250   QString mFileName;
00252   bool mEndOfMatrixFlag;
00254   int mActiveBlockNo;
00256   int mFileHeaderLines;
00258   unsigned int mCurrentColumn;
00260   unsigned int mCurrentRow;
00262   unsigned int mCurrentElementNo;
00264   std::ifstream  mTextStream;
00266   char mBuffer[mMaxLineLength];
00268   GDALDataset *  mGdalDataset;
00269 
00271   int mBlockHeaderLines;
00273   int mBlockStartPos;
00275   QVector <int> mBlockMarkersVector;
00276 
00277 
00278 };
00279 
00280 #endif

Generated on Mon Apr 28 15:08:15 2008 for openModellerDesktop by  doxygen 1.4.1-20050210