QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
qgsalgorithmfuzzifyraster.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsalgorithmrasterlayeruniquevalues.h
3  ---------------------
4  begin : October 2019
5  copyright : (C) 2019 by Clemens Raffler
6  email : clemens dot raffler at gmail dot com
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 QGSFUZZIFYRASTERALGORITHM_H
19 #define QGSFUZZIFYRASTERALGORITHM_H
20 
21 #define SIP_NO_FILE
22 
23 #include "qgis_sip.h"
24 #include "qgsprocessingalgorithm.h"
25 #include "qgsapplication.h"
26 
28 
32 class QgsFuzzifyRasterAlgorithmBase : public QgsProcessingAlgorithm
33 {
34  public:
35  QString group() const final;
36  QString groupId() const final;
37  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) final;
38 
39  protected:
40 
45  virtual void addAlgorithmParams() = 0;
46 
47  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
48 
52  virtual bool prepareAlgorithmFuzzificationParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) = 0;
53 
57  QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
58 
62  virtual void fuzzify( QgsProcessingFeedback *feedback ) = 0;
63 
64  QgsRasterLayer *mInputRaster;
65  int mBand;
66  std::unique_ptr< QgsRasterInterface > mInterface;
67  QgsRectangle mExtent;
69  int mLayerWidth;
70  int mLayerHeight;
71  int mNbCellsXProvider = 0;
72  int mNbCellsYProvider = 0;
73 
75  const double mNoDataValue = -9999;
76  QgsRasterDataProvider *mDestinationRasterProvider;
77 };
78 
79 
80 
81 
82 class QgsFuzzifyRasterLinearMembershipAlgorithm : public QgsFuzzifyRasterAlgorithmBase
83 {
84 
85  public:
86  QgsFuzzifyRasterLinearMembershipAlgorithm() = default;
87  QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmFuzzifyLinear.svg" ) ); }
88  QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmFuzzifyLinear.svg" ) ); }
89  QString name() const override;
90  QString displayName() const override;
91  QStringList tags() const override;
92  QString shortHelpString() const override;
93  QgsFuzzifyRasterLinearMembershipAlgorithm *createInstance() const override SIP_FACTORY;
94 
95  protected:
96  void addAlgorithmParams() override;
97  bool prepareAlgorithmFuzzificationParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
98  void fuzzify( QgsProcessingFeedback *feedback ) override;
99 
100  private:
101  double mFuzzifyLowBound;
102  double mFuzzifyHighBound;
103 
104 };
105 
106 
107 class QgsFuzzifyRasterPowerMembershipAlgorithm : public QgsFuzzifyRasterAlgorithmBase
108 {
109 
110  public:
111  QgsFuzzifyRasterPowerMembershipAlgorithm() = default;
112  QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmFuzzifyPower.svg" ) ); }
113  QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmFuzzifyPower.svg" ) ); }
114  QString name() const override;
115  QString displayName() const override;
116  QStringList tags() const override;
117  QString shortHelpString() const override;
118  QgsFuzzifyRasterPowerMembershipAlgorithm *createInstance() const override SIP_FACTORY;
119 
120  protected:
121  void addAlgorithmParams() override;
122  bool prepareAlgorithmFuzzificationParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
123  void fuzzify( QgsProcessingFeedback *feedback ) override;
124 
125  private:
126  double mFuzzifyLowBound;
127  double mFuzzifyHighBound;
128  double mFuzzifyExponent;
129 
130 };
131 
132 
133 class QgsFuzzifyRasterLargeMembershipAlgorithm : public QgsFuzzifyRasterAlgorithmBase
134 {
135 
136  public:
137  QgsFuzzifyRasterLargeMembershipAlgorithm() = default;
138  QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmFuzzifyLarge.svg" ) ); }
139  QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmFuzzifyLarge.svg" ) ); }
140  QString name() const override;
141  QString displayName() const override;
142  QStringList tags() const override;
143  QString shortHelpString() const override;
144  QgsFuzzifyRasterLargeMembershipAlgorithm *createInstance() const override SIP_FACTORY;
145 
146  protected:
147  void addAlgorithmParams() override;
148  bool prepareAlgorithmFuzzificationParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
149  void fuzzify( QgsProcessingFeedback *feedback ) override;
150 
151  private:
152  double mFuzzifyMidpoint;
153  double mFuzzifySpread;
154 
155 };
156 
157 
158 class QgsFuzzifyRasterSmallMembershipAlgorithm : public QgsFuzzifyRasterAlgorithmBase
159 {
160 
161  public:
162  QgsFuzzifyRasterSmallMembershipAlgorithm() = default;
163  QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmFuzzifySmall.svg" ) ); }
164  QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmFuzzifySmall.svg" ) ); }
165  QString name() const override;
166  QString displayName() const override;
167  QStringList tags() const override;
168  QString shortHelpString() const override;
169  QgsFuzzifyRasterSmallMembershipAlgorithm *createInstance() const override SIP_FACTORY;
170 
171  protected:
172  void addAlgorithmParams() override;
173  bool prepareAlgorithmFuzzificationParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
174  void fuzzify( QgsProcessingFeedback *feedback ) override;
175 
176  private:
177  double mFuzzifyMidpoint;
178  double mFuzzifySpread;
179 
180 };
181 
182 
183 class QgsFuzzifyRasterGaussianMembershipAlgorithm : public QgsFuzzifyRasterAlgorithmBase
184 {
185 
186  public:
187  QgsFuzzifyRasterGaussianMembershipAlgorithm() = default;
188  QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmFuzzifyGaussian.svg" ) ); }
189  QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmFuzzifyGaussian.svg" ) ); }
190  QString name() const override;
191  QString displayName() const override;
192  QStringList tags() const override;
193  QString shortHelpString() const override;
194  QgsFuzzifyRasterGaussianMembershipAlgorithm *createInstance() const override SIP_FACTORY;
195 
196  protected:
197  void addAlgorithmParams() override;
198  bool prepareAlgorithmFuzzificationParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
199  void fuzzify( QgsProcessingFeedback *feedback ) override;
200 
201  private:
202  double mFuzzifyMidpoint;
203  double mFuzzifySpread;
204 
205 };
206 
207 
208 class QgsFuzzifyRasterNearMembershipAlgorithm : public QgsFuzzifyRasterAlgorithmBase
209 {
210 
211  public:
212  QgsFuzzifyRasterNearMembershipAlgorithm() = default;
213  QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmFuzzifyNear.svg" ) ); }
214  QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmFuzzifyNear.svg" ) ); }
215  QString name() const override;
216  QString displayName() const override;
217  QStringList tags() const override;
218  QString shortHelpString() const override;
219  QgsFuzzifyRasterNearMembershipAlgorithm *createInstance() const override SIP_FACTORY;
220 
221  protected:
222  void addAlgorithmParams() override;
223  bool prepareAlgorithmFuzzificationParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
224  void fuzzify( QgsProcessingFeedback *feedback ) override;
225 
226  private:
227  double mFuzzifyMidpoint;
228  double mFuzzifySpread;
229 
230 };
231 
232 
234 
235 #endif // QGSALGORITHMFUZZIFYRASTER_H
236 
237 
DataType
Raster data types.
Definition: qgis.h:120
@ Float32
Thirty two bit floating point (float)
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
This class represents a coordinate reference system (CRS).
Abstract base class for processing algorithms.
virtual QString group() const
Returns the name of the group this algorithm belongs to.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
virtual QVariantMap processAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)=0
Runs the algorithm using the specified parameters.
virtual bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Prepares the algorithm to run using the specified parameters.
virtual void initAlgorithm(const QVariantMap &configuration=QVariantMap())=0
Initializes the algorithm using the specified configuration.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
Base class for raster data providers.
Represents a raster layer.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
#define SIP_FACTORY
Definition: qgis_sip.h:76