QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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 QString group() const final;
36 QString groupId() const final;
37 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) final;
38
39 protected:
44 virtual void addAlgorithmParams() = 0;
45
46 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
47
51 virtual bool _prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) = 0;
52
56 virtual QVector<QgsReclassifyUtils::RasterClass> createClasses(
57 QgsReclassifyUtils::RasterClass::BoundsType boundsType,
58 const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback
59 ) = 0;
60
61 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
62
63 std::unique_ptr<QgsRasterInterface> mInterface;
64
66 double mNoDataValue = -9999;
67 int mBand = 1;
68 QgsRectangle mExtent;
70 double mRasterUnitsPerPixelX = 0;
71 double mRasterUnitsPerPixelY = 0;
72 int mNbCellsXProvider = 0;
73 int mNbCellsYProvider = 0;
74 QgsReclassifyUtils::RasterClass::BoundsType mBoundsType = QgsReclassifyUtils::RasterClass::IncludeMax;
75 bool mUseNoDataForMissingValues = false;
76};
77
81class QgsReclassifyByLayerAlgorithm : public QgsReclassifyAlgorithmBase
82{
83 public:
84 QgsReclassifyByLayerAlgorithm() = default;
85 QString name() const override;
86 QString displayName() const override;
87 QStringList tags() const override;
88 QString shortHelpString() const override;
89 QgsReclassifyByLayerAlgorithm *createInstance() const override SIP_FACTORY;
90
91 protected:
92 void addAlgorithmParams() override;
93 bool _prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
94 QVector<QgsReclassifyUtils::RasterClass> createClasses(
95 QgsReclassifyUtils::RasterClass::BoundsType boundsType,
96 const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback
97 ) override;
98
99 private:
100 int mMinFieldIdx = -1;
101 int mMaxFieldIdx = -1;
102 int mValueFieldIdx = -1;
103 QgsFeatureIterator mTableIterator;
104};
105
109class QgsReclassifyByTableAlgorithm : public QgsReclassifyAlgorithmBase
110{
111 public:
112 QgsReclassifyByTableAlgorithm() = default;
113 QString name() const override;
114 QString displayName() const override;
115 QStringList tags() const override;
116 QString shortHelpString() const override;
117 QgsReclassifyByTableAlgorithm *createInstance() const override SIP_FACTORY;
118
119 protected:
120 void addAlgorithmParams() override;
121 bool _prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
122 QVector<QgsReclassifyUtils::RasterClass> createClasses( QgsReclassifyUtils::RasterClass::BoundsType boundsType, const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
123};
124
126
127#endif // QGSALGORITHMRECLASSIFYBYLAYER_H
DataType
Raster data types.
Definition qgis.h:351
@ 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 bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Prepares the algorithm to run using the specified parameters.
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)=0
Runs the algorithm 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.
#define SIP_FACTORY
Definition qgis_sip.h:76