QGIS API Documentation 3.43.0-Master (0bee5d6404c)
qgsninecellfilter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsninecellfilter.h - description
3 -------------------
4 begin : August 6th, 2009
5 copyright : (C) 2009 by Marco Hugentobler
6 email : marco dot hugentobler at karto dot baug dot ethz 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 QGSNINECELLFILTER_H
19#define QGSNINECELLFILTER_H
20
21#include <QString>
22#include "gdal.h"
23#include "qgis_analysis.h"
24#include "qgsogrutils.h"
25#include "qgsconfig.h"
26
27class QgsFeedback;
28
37class ANALYSIS_EXPORT QgsNineCellFilter
38{
39 public:
41 enum class Result : int
42 {
43 Success = 0,
44 InputLayerError = 1,
45 DriverError = 2,
46 CreateOutputError = 3,
47 InputBandError = 4,
48 OutputBandError = 5,
49 RasterSizeError = 6,
50 Canceled = 7,
51 };
52
54 QgsNineCellFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
55 virtual ~QgsNineCellFilter() = default;
56
62 Result processRaster( QgsFeedback *feedback = nullptr );
63
64 double cellSizeX() const { return mCellSizeX; }
65 void setCellSizeX( double size ) { mCellSizeX = size; }
66 double cellSizeY() const { return mCellSizeY; }
67 void setCellSizeY( double size ) { mCellSizeY = size; }
68
69 double zFactor() const { return mZFactor; }
70 void setZFactor( double factor ) { mZFactor = factor; }
71
72 double inputNodataValue() const { return mInputNodataValue; }
73 void setInputNodataValue( double value ) { mInputNodataValue = value; }
74 double outputNodataValue() const { return mOutputNodataValue; }
75 void setOutputNodataValue( double value ) { mOutputNodataValue = value; }
76
83 void setCreationOptions( const QStringList &list ) { mCreationOptions = list; }
84
91 QStringList creationOptions() const { return mCreationOptions; }
92
111 virtual float processNineCellWindow( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 ) = 0;
112
113 private:
114 //default constructor forbidden. We need input file, output file and format obligatory
115 QgsNineCellFilter() = delete;
116
118 gdal::dataset_unique_ptr openInputFile( int &nCellsX, int &nCellsY );
119
124 GDALDriverH openOutputDriver();
125
130 gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
131
137 Result processRasterCPU( QgsFeedback *feedback = nullptr );
138
139#ifdef HAVE_OPENCL
140
147 Result processRasterGPU( const QString &source, QgsFeedback *feedback = nullptr );
148
154 virtual void addExtraRasterParams( std::vector<float> &params )
155 {
156 Q_UNUSED( params )
157 }
158
159 virtual const QString openClProgramBaseName() const
160 {
161 return QString();
162 }
163
164#endif
165
166 protected:
167 QString mInputFile;
168 QString mOutputFile;
170 QStringList mCreationOptions;
171
172 double mCellSizeX = -1.0;
173 double mCellSizeY = -1.0;
175 double mInputNodataValue = -1.0;
177 double mOutputNodataValue = -9999.0;
179 double mZFactor = 1.0;
180};
181
182#endif // QGSNINECELLFILTER_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Base class for raster analysis methods that work with a 3x3 cell filter and calculate the value of ea...
QStringList creationOptions() const
Returns the list of data source creation options which will be used when creating the output raster f...
QStringList mCreationOptions
virtual float processNineCellWindow(float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33)=0
Calculates output value from nine input values.
Result
Result of the calculation.
double cellSizeX() const
virtual ~QgsNineCellFilter()=default
void setCellSizeX(double size)
void setOutputNodataValue(double value)
void setCreationOptions(const QStringList &list)
Sets a list of data source creation options to use when creating the output raster file.
void setInputNodataValue(double value)
void setZFactor(double factor)
void setCellSizeY(double size)
double inputNodataValue() const
double cellSizeY() const
double zFactor() const
double outputNodataValue() const
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
void * GDALDatasetH