QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsalgorithmreclassifybylayer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmreclassifybylayer.h
3 ---------------------
4 begin : June, 2018
5 copyright : (C) 2018 by Nyall Dawson
6 email : nyall dot dawson 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 QGSALGORITHMRECLASSIFYBYLAYER_H
19#define QGSALGORITHMRECLASSIFYBYLAYER_H
20
21#define SIP_NO_FILE
22
23#include "qgis_sip.h"
25#include "qgsreclassifyutils.h"
26
28
32class QgsReclassifyAlgorithmBase : public QgsProcessingAlgorithm
33{
34 public:
35
36 QString group() const final;
37 QString groupId() const final;
38 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) final;
39
40 protected:
41
46 virtual void addAlgorithmParams() = 0;
47
48 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
49
53 virtual bool _prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) = 0;
54
58 virtual QVector< QgsReclassifyUtils::RasterClass > createClasses(
59 QgsReclassifyUtils::RasterClass::BoundsType boundsType,
60 const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) = 0;
61
62 QVariantMap processAlgorithm( const QVariantMap &parameters,
63 QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
64
65 std::unique_ptr< QgsRasterInterface > mInterface;
66
68 double mNoDataValue = -9999;
69 int mBand = 1;
70 QgsRectangle mExtent;
72 double mRasterUnitsPerPixelX = 0;
73 double mRasterUnitsPerPixelY = 0;
74 int mNbCellsXProvider = 0;
75 int mNbCellsYProvider = 0;
76 QgsReclassifyUtils::RasterClass::BoundsType mBoundsType = QgsReclassifyUtils::RasterClass::IncludeMax;
77 bool mUseNoDataForMissingValues = false;
78};
79
83class QgsReclassifyByLayerAlgorithm : public QgsReclassifyAlgorithmBase
84{
85
86 public:
87
88 QgsReclassifyByLayerAlgorithm() = default;
89 QString name() const override;
90 QString displayName() const override;
91 QStringList tags() const override;
92 QString shortHelpString() const override;
93 QgsReclassifyByLayerAlgorithm *createInstance() const override SIP_FACTORY;
94
95 protected:
96 void addAlgorithmParams() override;
97 bool _prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
98 QVector< QgsReclassifyUtils::RasterClass > createClasses(
99 QgsReclassifyUtils::RasterClass::BoundsType boundsType,
100 const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
101
102 private:
103 int mMinFieldIdx = -1;
104 int mMaxFieldIdx = -1;
105 int mValueFieldIdx = -1;
106 QgsFeatureIterator mTableIterator;
107
108};
109
113class QgsReclassifyByTableAlgorithm : public QgsReclassifyAlgorithmBase
114{
115
116 public:
117
118 QgsReclassifyByTableAlgorithm() = default;
119 QString name() const override;
120 QString displayName() const override;
121 QStringList tags() const override;
122 QString shortHelpString() const override;
123 QgsReclassifyByTableAlgorithm *createInstance() const override SIP_FACTORY;
124
125 protected:
126
127 void addAlgorithmParams() override;
128 bool _prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
129 QVector< QgsReclassifyUtils::RasterClass > createClasses( QgsReclassifyUtils::RasterClass::BoundsType boundsType,
130 const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
131
132};
133
135
136#endif // QGSALGORITHMRECLASSIFYBYLAYER_H
137
138
DataType
Raster data types.
Definition: qgis.h:129
@ Float32
Thirty two bit floating point (float)
This class represents a coordinate reference system (CRS).
Wrapper for iterator of features from vector data provider or vector layer.
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