QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 "qgsconfig.h"
22
23#include <gdal.h>
24
25#include "qgis_analysis.h"
26#include "qgsogrutils.h"
27
28#include <QString>
29
30class QgsFeedback;
31
40class ANALYSIS_EXPORT QgsNineCellFilter
41{
42 public:
44 enum class Result : int
45 {
46 Success = 0,
47 InputLayerError = 1,
48 DriverError = 2,
49 CreateOutputError = 3,
50 InputBandError = 4,
51 OutputBandError = 5,
52 RasterSizeError = 6,
53 Canceled = 7,
54 };
55
57 QgsNineCellFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
58 virtual ~QgsNineCellFilter() = default;
59
65 Result processRaster( QgsFeedback *feedback = nullptr );
66
67 double cellSizeX() const { return mCellSizeX; }
68 void setCellSizeX( double size ) { mCellSizeX = size; }
69 double cellSizeY() const { return mCellSizeY; }
70 void setCellSizeY( double size ) { mCellSizeY = size; }
71
72 double zFactor() const { return mZFactor; }
73 void setZFactor( double factor ) { mZFactor = factor; }
74
75 double inputNodataValue() const { return mInputNodataValue; }
76 void setInputNodataValue( double value ) { mInputNodataValue = value; }
77 double outputNodataValue() const { return mOutputNodataValue; }
78 void setOutputNodataValue( double value ) { mOutputNodataValue = value; }
79
86 void setCreationOptions( const QStringList &options ) { mCreationOptions = options; }
87
94 QStringList creationOptions() const { return mCreationOptions; }
95
114 virtual float processNineCellWindow( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 ) = 0;
115
116 private:
117 //default constructor forbidden. We need input file, output file and format obligatory
118 QgsNineCellFilter() = delete;
119
121 gdal::dataset_unique_ptr openInputFile( int &nCellsX, int &nCellsY );
122
127 GDALDriverH openOutputDriver();
128
133 gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
134
140 Result processRasterCPU( QgsFeedback *feedback = nullptr );
141
142#ifdef HAVE_OPENCL
143
150 Result processRasterGPU( const QString &source, QgsFeedback *feedback = nullptr );
151
157 virtual void addExtraRasterParams( std::vector<float> &params )
158 {
159 Q_UNUSED( params )
160 }
161
162 virtual const QString openClProgramBaseName() const
163 {
164 return QString();
165 }
166
167#endif
168
169 protected:
170 QString mInputFile;
171 QString mOutputFile;
173 QStringList mCreationOptions;
174
175 double mCellSizeX = -1.0;
176 double mCellSizeY = -1.0;
178 double mInputNodataValue = -1.0;
180 double mOutputNodataValue = -9999.0;
182 double mZFactor = 1.0;
183};
184
185#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.
QgsNineCellFilter(const QString &inputFile, const QString &outputFile, const QString &outputFormat)
Constructor that takes input file, output file and output format (GDAL string).
double mOutputNodataValue
The nodata value of the output layer.
double cellSizeX() const
virtual ~QgsNineCellFilter()=default
void setCellSizeX(double size)
double mInputNodataValue
The nodata value of the input layer.
void setCreationOptions(const QStringList &options)
Sets a list of data source creation options to use when creating the output raster file.
void setOutputNodataValue(double value)
void setInputNodataValue(double value)
void setZFactor(double factor)
Result processRaster(QgsFeedback *feedback=nullptr)
Starts the calculation, reads from mInputFile and stores the result in mOutputFile.
void setCellSizeY(double size)
double inputNodataValue() const
double mZFactor
Scale factor for z-value if x-/y- units are different to z-units (111120 for degree->meters and 37040...
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