QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
27 class QgsFeedback;
28 
37 class 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 
82  virtual float processNineCellWindow( float *x11, float *x21, float *x31,
83  float *x12, float *x22, float *x32,
84  float *x13, float *x23, float *x33 ) = 0;
85 
86  private:
87  //default constructor forbidden. We need input file, output file and format obligatory
88  QgsNineCellFilter() = delete;
89 
91  gdal::dataset_unique_ptr openInputFile( int &nCellsX, int &nCellsY );
92 
97  GDALDriverH openOutputDriver();
98 
103  gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
104 
110  int processRasterCPU( QgsFeedback *feedback = nullptr );
111 
112 #ifdef HAVE_OPENCL
113 
120  int processRasterGPU( const QString &source, QgsFeedback *feedback = nullptr );
121 
127  virtual void addExtraRasterParams( std::vector<float> &params )
128  {
129  Q_UNUSED( params )
130  }
131 
132  virtual const QString openClProgramBaseName() const
133  {
134  return QString();
135  }
136 
137 #endif
138 
139  protected:
140 
141  QString mInputFile;
142  QString mOutputFile;
143  QString mOutputFormat;
144 
145  double mCellSizeX = -1.0;
146  double mCellSizeY = -1.0;
148  float mInputNodataValue = -1.0;
150  float mOutputNodataValue = -1.0;
152  double mZFactor = 1.0;
153 };
154 
155 #endif // QGSNINECELLFILTER_H
QgsNineCellFilter::setZFactor
void setZFactor(double factor)
Definition: qgsninecellfilter.h:57
QgsNineCellFilter::setCellSizeY
void setCellSizeY(double size)
Definition: qgsninecellfilter.h:54
qgsogrutils.h
QgsNineCellFilter
Base class for raster analysis methods that work with a 3x3 cell filter and calculate the value of ea...
Definition: qgsninecellfilter.h:37
QgsNineCellFilter::mInputFile
QString mInputFile
Definition: qgsninecellfilter.h:141
QgsNineCellFilter::setCellSizeX
void setCellSizeX(double size)
Definition: qgsninecellfilter.h:52
QgsNineCellFilter::setInputNodataValue
void setInputNodataValue(double value)
Definition: qgsninecellfilter.h:60
gdal::dataset_unique_ptr
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
Definition: qgsogrutils.h:139
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsNineCellFilter::mOutputFormat
QString mOutputFormat
Definition: qgsninecellfilter.h:143
QgsNineCellFilter::inputNodataValue
double inputNodataValue() const
Definition: qgsninecellfilter.h:59
QgsNineCellFilter::mOutputFile
QString mOutputFile
Definition: qgsninecellfilter.h:142
QgsNineCellFilter::outputNodataValue
double outputNodataValue() const
Definition: qgsninecellfilter.h:61
QgsNineCellFilter::cellSizeX
double cellSizeX() const
Definition: qgsninecellfilter.h:51
QgsNineCellFilter::cellSizeY
double cellSizeY() const
Definition: qgsninecellfilter.h:53
QgsNineCellFilter::zFactor
double zFactor() const
Definition: qgsninecellfilter.h:56
QgsNineCellFilter::setOutputNodataValue
void setOutputNodataValue(double value)
Definition: qgsninecellfilter.h:62
GDALDatasetH
void * GDALDatasetH
Definition: qgsalignraster.h:28