QGIS API Documentation  2.99.0-Master (53aba61)
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 
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 
93  //TODO QGIS 3.0 - return QgsRasterCalculator::Result
94  int processCalculation( QgsFeedback *feedback = nullptr );
95 
96  private:
97  //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
99 
102  GDALDriverH openOutputDriver();
103 
106  GDALDatasetH openOutputFile( GDALDriverH outputDriver );
107 
110  void outputGeoTransform( double *transform ) const;
111 
112  QString mFormulaString;
113  QString mOutputFile;
114  QString mOutputFormat;
115 
117  QgsRectangle mOutputRectangle;
118  QgsCoordinateReferenceSystem mOutputCrs;
119 
121  int mNumOutputColumns;
123  int mNumOutputRows;
124 
125  /***/
126  QVector<QgsRasterCalculatorEntry> mRasterEntries;
127 };
128 
129 #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.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Definition: qgsfeedback.h:43
void * GDALDatasetH
Result
Result of the calculation.
This class represents a coordinate reference system (CRS).