QGIS API Documentation  3.2.0-Bonn (bc43194)
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 #include "qgsogrutils.h"
28 
29 class QgsRasterLayer;
30 class QgsFeedback;
31 
32 
33 struct ANALYSIS_EXPORT QgsRasterCalculatorEntry
34 {
35 #ifdef SIP_RUN
36  % TypeHeaderCode
37 #include <qgsrastercalculator.h>
38  % End
39 #endif
40 
41  QString ref; //name
42  QgsRasterLayer *raster; //pointer to rasterlayer
43  int bandNumber; //raster band number
44 };
45 
49 class ANALYSIS_EXPORT QgsRasterCalculator
50 {
51  public:
52 
54  enum Result
55  {
56  Success = 0,
57  CreateOutputError = 1,
58  InputLayerError = 2,
59  Canceled = 3,
60  ParserError = 4,
61  MemoryError = 5,
62  };
63 
74  QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
75  const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries );
76 
89  QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
90  const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries );
91 
98  //TODO QGIS 3.0 - return QgsRasterCalculator::Result
99  int processCalculation( QgsFeedback *feedback = nullptr );
100 
101  private:
102  //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
103  QgsRasterCalculator() = delete;
104 
108  GDALDriverH openOutputDriver();
109 
113  gdal::dataset_unique_ptr openOutputFile( GDALDriverH outputDriver );
114 
118  void outputGeoTransform( double *transform ) const;
119 
120  QString mFormulaString;
121  QString mOutputFile;
122  QString mOutputFormat;
123 
125  QgsRectangle mOutputRectangle;
126  QgsCoordinateReferenceSystem mOutputCrs;
127 
129  int mNumOutputColumns = 0;
131  int mNumOutputRows = 0;
132 
133  /***/
134  QVector<QgsRasterCalculatorEntry> mRasterEntries;
135 };
136 
137 #endif // QGSRASTERCALCULATOR_H
A rectangle specified with double values.
Definition: qgsrectangle.h:40
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
Result
Result of the calculation.
This class represents a coordinate reference system (CRS).
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
Definition: qgsogrutils.h:134