QGIS API Documentation 4.3.0-Master (45633be667c)
Loading...
Searching...
No Matches
qgsalgorithmupslopearea.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmupslopearea.h
3 ---------------------
4 begin : September 2026
5 copyright : (C) 2026 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 QGSALGORITHMUPSLOPEAREA_H
19#define QGSALGORITHMUPSLOPEAREA_H
20
21
22#include "qgis_sip.h"
24
25#define SIP_NO_FILE
26
28
35class QgsUpslopeAreaAlgorithmBase : public QgsProcessingAlgorithm
36{
37 public:
38 QgsUpslopeAreaAlgorithmBase() = default;
39
40 QString group() const override;
41 QString groupId() const override;
42 QStringList tags() const override;
43 QList<QgsAcademicReference> academicReferences() const override;
44 QList<QgsProcessingAlgorithm::ExternalLink> externalLinks() const override;
45
46 protected:
47 enum class Method : int
48 {
49 D8 = 0,
50 DInf = 1,
51 MFD = 2,
52 MDInf = 3,
53 MMDGFD = 4
54 };
55
56 void addCommonParameters();
57 bool prepareBase( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback );
58
59 // Core flow accumulation engine
60 bool calculateUpslopeArea( const std::vector<QgsPointXY> &targetPoints, QgsProcessingContext &context, QgsProcessingFeedback *feedback );
61
62 void computeCellValue( const QgsRasterBlock *demBlock, int col, int row, int cols, int rows, double cellSizeX, double cellSizeY, Method method, double converge, bool contour );
63 void computeD8( const QgsRasterBlock *demBlock, int col, int row, int cols, int rows, double cellSizeX, double cellSizeY );
64 void computeDInf( const QgsRasterBlock *demBlock, int col, int row, int cols, int rows, double cellSizeX, double cellSizeY );
65 void computeMFD( const QgsRasterBlock *demBlock, int col, int row, int cols, int rows, double cellSizeX, double cellSizeY, double converge, bool contour );
66 void computeMMDGFD( const QgsRasterBlock *demBlock, int col, int row, int cols, int rows, double cellSizeX, double cellSizeY, bool contour );
67 void computeMDInf( const QgsRasterBlock *demBlock, int col, int row, int cols, int rows, double cellSizeX, double cellSizeY, double converge );
68
69 std::unique_ptr<QgsRasterInterface> mDemProvider;
71 std::unique_ptr<QgsRasterInterface> mRouteProvider;
72
73 int mCols = 0;
74 int mRows = 0;
75 double mCellSizeX = 0.0;
76 double mCellSizeY = 0.0;
77 double mDemNoData = -9999.0;
78 double mRouteNoData = -9999.0;
79 QgsRectangle mExtent;
80
81 std::vector<double> mRouteData;
82 std::vector<double> mFlowData;
83
84 Method mMethod = Method::MFD;
85 double mConvergence = 1.1;
86 bool mMfdContour = false;
87 QString mOutputPath;
88 QString mOutputFormat;
89 QString mCreationOptions;
90 double mOutputNoData = -9999;
91};
92
97class QgsUpslopeAreaPointAlgorithm : public QgsUpslopeAreaAlgorithmBase
98{
99 public:
100 QgsUpslopeAreaPointAlgorithm();
101
102 QString name() const override;
103 QString displayName() const override;
104 QString shortDescription() const override;
105 QString shortHelpString() const override;
106 QgsProcessingAlgorithm *createInstance() const override;
107
108 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
109
110 protected:
111 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
112 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
113};
114
119class QgsUpslopeAreaLayerAlgorithm : public QgsUpslopeAreaAlgorithmBase
120{
121 public:
122 QgsUpslopeAreaLayerAlgorithm();
123
124 QString name() const override;
125 QString displayName() const override;
126 QString shortDescription() const override;
127 QString shortHelpString() const override;
128 QgsProcessingAlgorithm *createInstance() const override;
129
130 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
131
132 protected:
133 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
134 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
135};
136
138
139#endif // QGSALGORITHMUPSLOPEAREA_H
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 QStringList tags() const
Returns a list of tags which relate to the algorithm, and are used to assist users in searching for s...
virtual QList< QgsProcessingAlgorithm::ExternalLink > externalLinks() const
Returns a list of external links describing the algorithm's behavior or source.
virtual QList< QgsAcademicReference > academicReferences() const
Returns the list of academic references describing the logic and processes used by the algorithm.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
Raster data container.
A rectangle specified with double values.