QGIS API Documentation 4.3.0-Master (45633be667c)
Loading...
Searching...
No Matches
qgsalgorithmchannelnetwork.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmchannelnetwork.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 QGSALGORITHMCHANNELNETWORK_H
19#define QGSALGORITHMCHANNELNETWORK_H
20
21
22#include "qgis_sip.h"
23#include "qgsalgorithmd8base.h"
25
26#define SIP_NO_FILE
27
29
33class QgsChannelNetworkAlgorithmBase : public QgsD8AnalysisAlgorithmBase
34{
35 public:
36 QgsChannelNetworkAlgorithmBase() = default;
37
38 QStringList tags() const override;
39
40 protected:
41 void addCommonParameters();
42
43 enum class NodeType
44 {
45 Spring = 1,
46 Junction = 2,
47 Outlet = 3,
48 Mouth = 4,
49 };
50
51 void extractChannelNetwork(
52 const QgsRasterBlock *demBlock,
53 const std::vector<int8_t> &d8Directions,
54 const std::vector<int16_t> &strahlerOrders,
55 int width,
56 int height,
57 const QgsRectangle &extent,
59 int threshold,
60 bool subbasins,
61 QgsFeatureSink *channelSink,
62 QgsFeatureSink *basinSink,
63 QgsFeatureSink *junctionSink,
64 QgsProcessingFeedback *feedback,
65 const QVariantMap &parameters
66 );
67
68 static QgsFields channelFields();
69 static QgsFields basinFields();
70 static QgsFields junctionFields();
71
72 std::unique_ptr<QgsRasterInterface> mDemInterface;
73 int mLayerWidth = 0;
74 int mLayerHeight = 0;
75 double mCellSizeX = 0.0;
76 double mCellSizeY = 0.0;
77 QgsRectangle mExtent;
79};
80
84class QgsChannelNetworkFromDemAlgorithm : public QgsChannelNetworkAlgorithmBase
85{
86 public:
87 QgsChannelNetworkFromDemAlgorithm() = default;
88
89 QString name() const override;
90 QString displayName() const override;
91 QString shortDescription() const override;
92 QString shortHelpString() const override;
93 QgsProcessingAlgorithm *createInstance() const override;
94
95 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
96
97 protected:
98 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
99 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
100};
101
105class QgsChannelNetworkFromFlowDirAndOrderAlgorithm : public QgsChannelNetworkAlgorithmBase
106{
107 public:
108 QgsChannelNetworkFromFlowDirAndOrderAlgorithm() = default;
109
110 QString name() const override;
111 QString displayName() const override;
112 QString shortDescription() const override;
113 QString shortHelpString() const override;
114 QgsProcessingAlgorithm *createInstance() const override;
115
116 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
117
118 protected:
119 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
120 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
121
122 private:
123 std::unique_ptr<QgsRasterInterface> mFlowDirInterface;
124 std::unique_ptr<QgsRasterInterface> mStrahlerInterface;
125};
126
128
129#endif // QGSALGORITHMCHANNELNETWORK_H
Represents a coordinate reference system (CRS).
An interface for objects which accept features via addFeature(s) methods.
Container of fields for a vector layer.
Definition qgsfields.h:45
Base class for providing feedback from a processing algorithm.
Raster data container.
A rectangle specified with double values.