QGIS API Documentation  3.21.0-Master (56b4176581)
qgsalgorithmrasterfrequencybycomparisonoperator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsalgorithmrasterfrequencybycomparisonoperator.h
3  ---------------------
4  begin : June 2020
5  copyright : (C) 2020 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 QGSALGORITHMRASTERFREQUENCYBYCOMPARISON_H
19 #define QGSALGORITHMRASTERFREQUENCYBYCOMPARISON_H
20 
21 #define SIP_NO_FILE
22 
23 #include "qgis_sip.h"
24 #include "qgsapplication.h"
25 #include "qgsprocessingalgorithm.h"
26 #include "qgsrasterprojector.h"
27 #include "qgsrasteranalysisutils.h"
28 
30 
31 class QgsRasterFrequencyByComparisonOperatorBase : public QgsProcessingAlgorithm
32 {
33  public:
34  QgsRasterFrequencyByComparisonOperatorBase() = default;
35  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
36  QString group() const override;
37  QString groupId() const override;
38 
39  protected:
40  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
41  QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
42  virtual int applyComparisonOperator( double value, std::vector<double>cellValueStack ) = 0;
43 
44  private:
45  std::unique_ptr< QgsRasterInterface > mInputValueRasterInterface;
46  int mInputValueRasterBand;
47  std::vector< QgsRasterAnalysisUtils::RasterLogicInput > mInputs;
48  bool mIgnoreNoData;
49  double mNoDataValue = -9999;
50  int mLayerWidth;
51  int mLayerHeight;
52  QgsRectangle mExtent;
54  double mRasterUnitsPerPixelX;
55  double mRasterUnitsPerPixelY;
56 };
57 
58 class QgsRasterFrequencyByEqualOperatorAlgorithm : public QgsRasterFrequencyByComparisonOperatorBase
59 {
60  public:
61  QgsRasterFrequencyByEqualOperatorAlgorithm() = default;
62  QString name() const override;
63  QString displayName() const override;
64  QStringList tags() const override;
65  QString shortHelpString() const override;
66  QgsRasterFrequencyByEqualOperatorAlgorithm *createInstance() const override SIP_FACTORY;
67 
68  protected:
69  int applyComparisonOperator( double searchValue, std::vector<double>cellValueStack ) override;
70 };
71 
72 class QgsRasterFrequencyByGreaterThanOperatorAlgorithm : public QgsRasterFrequencyByComparisonOperatorBase
73 {
74  public:
75  QgsRasterFrequencyByGreaterThanOperatorAlgorithm() = default;
76  QString name() const override;
77  QString displayName() const override;
78  QStringList tags() const override;
79  QString shortHelpString() const override;
80  QgsRasterFrequencyByGreaterThanOperatorAlgorithm *createInstance() const override SIP_FACTORY;
81 
82  protected:
83  int applyComparisonOperator( double value, std::vector<double>cellValueStack ) override;
84 };
85 
86 class QgsRasterFrequencyByLessThanOperatorAlgorithm : public QgsRasterFrequencyByComparisonOperatorBase
87 {
88  public:
89  QgsRasterFrequencyByLessThanOperatorAlgorithm() = default;
90  QString name() const override;
91  QString displayName() const override;
92  QStringList tags() const override;
93  QString shortHelpString() const override;
94  QgsRasterFrequencyByLessThanOperatorAlgorithm *createInstance() const override SIP_FACTORY;
95 
96  protected:
97  int applyComparisonOperator( double value, std::vector<double>cellValueStack ) override;
98 };
99 
101 
102 #endif // QGSALGORITHMRASTERFREQUENCYBYCOMPARISON_H
103 
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.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
#define SIP_FACTORY
Definition: qgis_sip.h:76