QGIS API Documentation  2.14.0-Essen
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"
24 #include <QString>
25 #include <QVector>
26 #include "gdal.h"
27 
28 class QgsRasterLayer;
29 class QProgressDialog;
30 
31 
32 struct ANALYSIS_EXPORT QgsRasterCalculatorEntry
33 {
34  QString ref; //name
35  QgsRasterLayer* raster; //pointer to rasterlayer
36  int bandNumber; //raster band number
37 };
38 
40 class ANALYSIS_EXPORT QgsRasterCalculator
41 {
42  public:
43 
45  enum Result
46  {
47  Success = 0,
48  CreateOutputError = 1,
49  InputLayerError = 2,
50  Cancelled = 3,
51  ParserError = 4,
52  MemoryError = 5,
53  };
54 
64  QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
65  const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
66 
78  QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
79  const QgsRectangle& outputExtent, const QgsCoordinateReferenceSystem& outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
80 
84  //TODO QGIS 3.0 - return QgsRasterCalculator::Result
85  int processCalculation( QProgressDialog* p = nullptr );
86 
87  private:
88  //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
90 
93  GDALDriverH openOutputDriver();
94 
97  GDALDatasetH openOutputFile( GDALDriverH outputDriver );
98 
101  void outputGeoTransform( double* transform ) const;
102 
103  QString mFormulaString;
104  QString mOutputFile;
105  QString mOutputFormat;
106 
108  QgsRectangle mOutputRectangle;
109  QgsCoordinateReferenceSystem mOutputCrs;
110 
112  int mNumOutputColumns;
114  int mNumOutputRows;
115 
116  /***/
117  QVector<QgsRasterCalculatorEntry> mRasterEntries;
118 };
119 
120 #endif // QGSRASTERCALCULATOR_H
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Raster calculator class.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void * GDALDatasetH
Result
Result of the calculation.
Class for storing a coordinate reference system (CRS)