Quantum GIS API Documentation
1.7.4
|
00001 /*************************************************************************** 00002 qgsrastercalculator.h - description 00003 --------------------- 00004 begin : September 28th, 2010 00005 copyright : (C) 2010 by Marco Hugentobler 00006 email : marco dot hugentobler at sourcepole dot ch 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef QGSRASTERCALCULATOR_H 00019 #define QGSRASTERCALCULATOR_H 00020 00021 #include "qgsfield.h" 00022 #include "qgsrectangle.h" 00023 #include <QString> 00024 #include <QVector> 00025 #include "gdal.h" 00026 00027 class QgsRasterLayer; 00028 class QProgressDialog; 00029 00030 00031 struct ANALYSIS_EXPORT QgsRasterCalculatorEntry 00032 { 00033 QString ref; //name 00034 QgsRasterLayer* raster; //pointer to rasterlayer 00035 int bandNumber; //raster band number 00036 }; 00037 00039 class ANALYSIS_EXPORT QgsRasterCalculator 00040 { 00041 public: 00042 QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat, 00043 const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries ); 00044 ~QgsRasterCalculator(); 00045 00049 int processCalculation( QProgressDialog* p = 0 ); 00050 00051 private: 00052 //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory 00053 QgsRasterCalculator(); 00054 00057 GDALDriverH openOutputDriver(); 00058 00061 GDALDatasetH openOutputFile( GDALDriverH outputDriver ); 00062 00074 void readRasterPart( double* targetGeotransform, 00075 int xOffset, int yOffset, 00076 int nCols, int nRows, 00077 double* sourceTransform, 00078 GDALRasterBandH sourceBand, 00079 float* rasterBuffer ); 00080 00082 bool transformationsEqual( double* t1, double* t2 ) const; 00083 00086 void outputGeoTransform( double* transform ) const; 00087 00088 QString mFormulaString; 00089 QString mOutputFile; 00090 QString mOutputFormat; 00091 00093 QgsRectangle mOutputRectangle; 00095 int mNumOutputColumns; 00097 int mNumOutputRows; 00098 00099 /***/ 00100 QVector<QgsRasterCalculatorEntry> mRasterEntries; 00101 }; 00102 00103 #endif // QGSRASTERCALCULATOR_H