QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrastercalculator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrastercalculator.h - description
3  ---------------------
4  begin : September 28th, 2010
5  copyright : (C) 2010 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSRASTERCALCULATOR_H
19 #define QGSRASTERCALCULATOR_H
20 
21 #include "qgsfield.h"
22 #include "qgsrectangle.h"
23 #include <QString>
24 #include <QVector>
25 #include "gdal.h"
26 
27 class QgsRasterLayer;
28 class QProgressDialog;
29 
30 
31 struct ANALYSIS_EXPORT QgsRasterCalculatorEntry
32 {
33  QString ref; //name
34  QgsRasterLayer* raster; //pointer to rasterlayer
35  int bandNumber; //raster band number
36 };
37 
39 class ANALYSIS_EXPORT QgsRasterCalculator
40 {
41  public:
42  QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
43  const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
45 
49  int processCalculation( QProgressDialog* p = 0 );
50 
51  private:
52  //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
54 
57  GDALDriverH openOutputDriver();
58 
61  GDALDatasetH openOutputFile( GDALDriverH outputDriver );
62 
74  void readRasterPart( double* targetGeotransform,
75  int xOffset, int yOffset,
76  int nCols, int nRows,
77  double* sourceTransform,
78  GDALRasterBandH sourceBand,
79  float* rasterBuffer );
80 
82  bool transformationsEqual( double* t1, double* t2 ) const;
83 
86  void outputGeoTransform( double* transform ) const;
87 
88  QString mFormulaString;
89  QString mOutputFile;
90  QString mOutputFormat;
91 
98 
99  /***/
100  QVector<QgsRasterCalculatorEntry> mRasterEntries;
101 };
102 
103 #endif // QGSRASTERCALCULATOR_H