QGIS API Documentation  2.99.0-Master (ef89a62)
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 "qgsrectangle.h"
23 #include <QString>
24 #include <QVector>
25 #include "gdal.h"
26 #include "qgis_analysis.h"
27 
28 class QgsRasterLayer;
29 class QProgressDialog;
30 
31 
32 struct ANALYSIS_EXPORT QgsRasterCalculatorEntry
33 {
34 #ifdef SIP_RUN
35  % TypeHeaderCode
36 #include <qgsrastercalculator.h>
37  % End
38 #endif
39 
40  QString ref; //name
41  QgsRasterLayer *raster; //pointer to rasterlayer
42  int bandNumber; //raster band number
43 };
44 
47 class ANALYSIS_EXPORT QgsRasterCalculator
48 {
49  public:
50 
52  enum Result
53  {
54  Success = 0,
55  CreateOutputError = 1,
56  InputLayerError = 2,
57  Canceled = 3,
58  ParserError = 4,
59  MemoryError = 5,
60  };
61 
71  QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
72  const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries );
73 
85  QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
86  const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries );
87 
91  //TODO QGIS 3.0 - return QgsRasterCalculator::Result
92  int processCalculation( QProgressDialog *p = nullptr );
93 
94  private:
95  //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
97 
100  GDALDriverH openOutputDriver();
101 
104  GDALDatasetH openOutputFile( GDALDriverH outputDriver );
105 
108  void outputGeoTransform( double *transform ) const;
109 
110  QString mFormulaString;
111  QString mOutputFile;
112  QString mOutputFormat;
113 
115  QgsRectangle mOutputRectangle;
116  QgsCoordinateReferenceSystem mOutputCrs;
117 
119  int mNumOutputColumns;
121  int mNumOutputRows;
122 
123  /***/
124  QVector<QgsRasterCalculatorEntry> mRasterEntries;
125 };
126 
127 #endif // QGSRASTERCALCULATOR_H
A rectangle specified with double values.
Definition: qgsrectangle.h:38
Raster calculator class.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void * GDALDatasetH
Result
Result of the calculation.
This class represents a coordinate reference system (CRS).