QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
41 class ANALYSIS_EXPORT QgsRasterCalculator
42 {
43  public:
44 
46  enum Result
47  {
48  Success = 0,
49  CreateOutputError = 1,
50  InputLayerError = 2,
51  Cancelled = 3,
52  ParserError = 4,
53  MemoryError = 5,
54  };
55 
65  QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
66  const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
67 
79  QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
80  const QgsRectangle& outputExtent, const QgsCoordinateReferenceSystem& outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
81 
85  //TODO QGIS 3.0 - return QgsRasterCalculator::Result
86  int processCalculation( QProgressDialog* p = nullptr );
87 
88  private:
89  //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
91 
94  GDALDriverH openOutputDriver();
95 
98  GDALDatasetH openOutputFile( GDALDriverH outputDriver );
99 
102  void outputGeoTransform( double* transform ) const;
103 
104  QString mFormulaString;
105  QString mOutputFile;
106  QString mOutputFormat;
107 
109  QgsRectangle mOutputRectangle;
110  QgsCoordinateReferenceSystem mOutputCrs;
111 
113  int mNumOutputColumns;
115  int mNumOutputRows;
116 
117  /***/
118  QVector<QgsRasterCalculatorEntry> mRasterEntries;
119 };
120 
121 #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)