QGIS API Documentation 3.43.0-Master (c67cf405802)
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 QgsNineCellFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
42 virtual ~QgsNineCellFilter() = default;
43
49 int processRaster( QgsFeedback *feedback = nullptr );
50
51 double cellSizeX() const { return mCellSizeX; }
52 void setCellSizeX( double size ) { mCellSizeX = size; }
53 double cellSizeY() const { return mCellSizeY; }
54 void setCellSizeY( double size ) { mCellSizeY = size; }
55
56 double zFactor() const { return mZFactor; }
57 void setZFactor( double factor ) { mZFactor = factor; }
58
59 double inputNodataValue() const { return mInputNodataValue; }
60 void setInputNodataValue( double value ) { mInputNodataValue = value; }
61 double outputNodataValue() const { return mOutputNodataValue; }
62 void setOutputNodataValue( double value ) { mOutputNodataValue = value; }
63
70 void setCreationOptions( const QStringList &list ) { mCreationOptions = list; }
71
78 QStringList creationOptions() const { return mCreationOptions; }
79
98 virtual float processNineCellWindow( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 ) = 0;
99
100 private:
101 //default constructor forbidden. We need input file, output file and format obligatory
102 QgsNineCellFilter() = delete;
103
105 gdal::dataset_unique_ptr openInputFile( int &nCellsX, int &nCellsY );
106
111 GDALDriverH openOutputDriver();
112
117 gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
118
124 int processRasterCPU( QgsFeedback *feedback = nullptr );
125
126#ifdef HAVE_OPENCL
127
134 int processRasterGPU( const QString &source, QgsFeedback *feedback = nullptr );
135
141 virtual void addExtraRasterParams( std::vector<float> &params )
142 {
143 Q_UNUSED( params )
144 }
145
146 virtual const QString openClProgramBaseName() const
147 {
148 return QString();
149 }
150
151#endif
152
153 protected:
154 QString mInputFile;
155 QString mOutputFile;
157 QStringList mCreationOptions;
158
159 double mCellSizeX = -1.0;
160 double mCellSizeY = -1.0;
162 double mInputNodataValue = -1.0;
164 double mOutputNodataValue = -9999.0;
166 double mZFactor = 1.0;
167};
168
169#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.
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