QGIS API Documentation  3.2.0-Bonn (bc43194)
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 class QgsFeedback;
26 
33 class ANALYSIS_EXPORT QgsNineCellFilter
34 {
35  public:
37  QgsNineCellFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
38  virtual ~QgsNineCellFilter() = default;
39 
44  int processRaster( QgsFeedback *feedback = nullptr );
45 
46  double cellSizeX() const { return mCellSizeX; }
47  void setCellSizeX( double size ) { mCellSizeX = size; }
48  double cellSizeY() const { return mCellSizeY; }
49  void setCellSizeY( double size ) { mCellSizeY = size; }
50 
51  double zFactor() const { return mZFactor; }
52  void setZFactor( double factor ) { mZFactor = factor; }
53 
54  double inputNodataValue() const { return mInputNodataValue; }
55  void setInputNodataValue( double value ) { mInputNodataValue = value; }
56  double outputNodataValue() const { return mOutputNodataValue; }
57  void setOutputNodataValue( double value ) { mOutputNodataValue = value; }
58 
62  virtual float processNineCellWindow( float *x11, float *x21, float *x31,
63  float *x12, float *x22, float *x32,
64  float *x13, float *x23, float *x33 ) = 0;
65 
66  private:
67  //default constructor forbidden. We need input file, output file and format obligatory
68  QgsNineCellFilter() = delete;
69 
71  gdal::dataset_unique_ptr openInputFile( int &nCellsX, int &nCellsY );
72 
76  GDALDriverH openOutputDriver();
77 
81  gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
82 
83  protected:
84 
85  QString mInputFile;
86  QString mOutputFile;
87  QString mOutputFormat;
88 
89  double mCellSizeX = -1.0;
90  double mCellSizeY = -1.0;
92  float mInputNodataValue = -1.0;
94  float mOutputNodataValue = -1.0;
96  double mZFactor = 1.0;
97 };
98 
99 #endif // QGSNINECELLFILTER_H
void setZFactor(double factor)
void setCellSizeY(double size)
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Definition: qgsfeedback.h:44
void setInputNodataValue(double value)
double inputNodataValue() const
void setCellSizeX(double size)
void * GDALDatasetH
double cellSizeX() const
double outputNodataValue() const
double zFactor() const
void setOutputNodataValue(double value)
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
Definition: qgsogrutils.h:134
double cellSizeY() const
Base class for raster analysis methods that work with a 3x3 cell filter and calculate the value of ea...