QGIS API Documentation  2.99.0-Master (9fdd060)
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 QgsFeedback;
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 
48 class ANALYSIS_EXPORT QgsRasterCalculator
49 {
50  public:
51 
53  enum Result
54  {
55  Success = 0,
56  CreateOutputError = 1,
57  InputLayerError = 2,
58  Canceled = 3,
59  ParserError = 4,
60  MemoryError = 5,
61  };
62 
73  QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
74  const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries );
75 
88  QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
89  const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries );
90 
97  //TODO QGIS 3.0 - return QgsRasterCalculator::Result
98  int processCalculation( QgsFeedback *feedback = nullptr );
99 
100  private:
101  //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
102  QgsRasterCalculator() = delete;
103 
107  GDALDriverH openOutputDriver();
108 
112  GDALDatasetH openOutputFile( GDALDriverH outputDriver );
113 
117  void outputGeoTransform( double *transform ) const;
118 
119  QString mFormulaString;
120  QString mOutputFile;
121  QString mOutputFormat;
122 
124  QgsRectangle mOutputRectangle;
125  QgsCoordinateReferenceSystem mOutputCrs;
126 
128  int mNumOutputColumns = 0;
130  int mNumOutputRows = 0;
131 
132  /***/
133  QVector<QgsRasterCalculatorEntry> mRasterEntries;
134 };
135 
136 #endif // QGSRASTERCALCULATOR_H
A rectangle specified with double values.
Definition: qgsrectangle.h:39
Raster calculator class.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Definition: qgsfeedback.h:44
void * GDALDatasetH
Result
Result of the calculation.
This class represents a coordinate reference system (CRS).