QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
qgsrastercalcnode.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrastercalcnode.h
3 Node for raster calculator tree
4 --------------------
5 begin : 2010-10-23
6 copyright : (C) 20010 by Marco Hugentobler
7 email : marco dot hugentobler at sourcepole dot ch
8***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#ifndef QGSRASTERCALCNODE_H
20#define QGSRASTERCALCNODE_H
21
22#include <QMap>
23#include "qgis_sip.h"
24#include "qgis.h"
25#include <QString>
26#include "qgis_analysis.h"
27
28#include <QVector>
29
30class QgsRasterBlock;
31class QgsRasterMatrix;
32
38class ANALYSIS_EXPORT QgsRasterCalcNode
39{
40 public:
42 enum Type
43 {
44 tOperator = 1,
48 tFunction
49 };
50
82
86 QgsRasterCalcNode() = default;
87
88 QgsRasterCalcNode( double number );
92 QgsRasterCalcNode( QString functionName, QVector <QgsRasterCalcNode *> functionArgs );
93 QgsRasterCalcNode( const QString &rasterName );
95
97 QgsRasterCalcNode( const QgsRasterCalcNode &rh ) = delete;
100
101 Type type() const { return mType; }
102
103 //set left node
104 void setLeft( QgsRasterCalcNode *left ) { delete mLeft; mLeft = left; }
105 void setRight( QgsRasterCalcNode *right ) { delete mRight; mRight = right; }
106
115 bool calculate( QMap<QString, QgsRasterBlock * > &rasterData, QgsRasterMatrix &result, int row = -1 ) const SIP_SKIP;
116
122 QString toString( bool cStyle = false ) const;
123
128 QList<const QgsRasterCalcNode *> findNodes( const QgsRasterCalcNode::Type type ) const;
129
130 static QgsRasterCalcNode *parseRasterCalcString( const QString &str, QString &parserErrorMsg ) SIP_FACTORY;
131
137 QStringList referencedLayerNames( );
138
143 QStringList cleanRasterReferences();
144
145 private:
146#ifdef SIP_RUN
148#endif
149
154 QgsRasterMatrix evaluateFunction( const std::vector< std::unique_ptr< QgsRasterMatrix > > &matrixVector, QgsRasterMatrix &result ) const;
155
156 Type mType = tNumber;
157 QgsRasterCalcNode *mLeft = nullptr;
158 QgsRasterCalcNode *mRight = nullptr;
159 double mNumber = 0;
160 QString mRasterName;
161 QgsRasterMatrix *mMatrix = nullptr;
162 Operator mOperator = opNONE;
163 //added for the conditional statement
164 QString mFunctionName;
165 QVector <QgsRasterCalcNode *> mFunctionArgs;
166};
167
168
169#endif // QGSRASTERCALCNODE_H
Raster data container.
Represents a node in a raster calculator.
void setLeft(QgsRasterCalcNode *left)
Operator
possible operators
QgsRasterCalcNode()=default
Constructor for QgsRasterCalcNode.
QgsRasterCalcNode(const QgsRasterCalcNode &rh)=delete
QgsRasterCalcNode cannot be copied.
QgsRasterCalcNode & operator=(const QgsRasterCalcNode &rh)=delete
QgsRasterCalcNode cannot be copied.
void setRight(QgsRasterCalcNode *right)
Type
defines possible types of node
Represents a matrix in a raster calculator operation.
#define str(x)
Definition qgis.cpp:38
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_FACTORY
Definition qgis_sip.h:76