QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
30 class QgsRasterBlock;
31 class QgsRasterMatrix;
32 
38 class ANALYSIS_EXPORT QgsRasterCalcNode
39 {
40  public:
42  enum Type
43  {
44  tOperator = 1,
48  tFunction
49  };
50 
52  enum Operator
53  {
66  opEQ, // =
67  opNE,
68  opGT, // >
69  opLT, // <
70  opGE, // >=
71  opLE, // <=
74  opSIGN, // change sign
81  };
82 
86  QgsRasterCalcNode() = default;
87 
88  QgsRasterCalcNode( double number );
90  QgsRasterCalcNode( Operator op, QgsRasterCalcNode *left, QgsRasterCalcNode *right );
92  QgsRasterCalcNode( QString functionName, QVector <QgsRasterCalcNode *> functionArgs );
93  QgsRasterCalcNode( const QString &rasterName );
95 
97  QgsRasterCalcNode( const QgsRasterCalcNode &rh ) = delete;
99  QgsRasterCalcNode &operator=( 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 
116  bool calculate( QMap<QString, QgsRasterBlock * > &rasterData, QgsRasterMatrix &result, int row = -1 ) const SIP_SKIP;
117 
123  QString toString( bool cStyle = false ) const;
124 
129  QList<const QgsRasterCalcNode *> findNodes( const QgsRasterCalcNode::Type type ) const;
130 
131  static QgsRasterCalcNode *parseRasterCalcString( const QString &str, QString &parserErrorMsg ) SIP_FACTORY;
132 
138  QStringList referencedLayerNames( );
139 
144  QStringList cleanRasterReferences();
145 
146  private:
147 #ifdef SIP_RUN
149 #endif
150 
155  QgsRasterMatrix evaluateFunction( const QVector<QgsRasterMatrix *> &matrixVector, QgsRasterMatrix &result ) const;
156 
157  Type mType = tNumber;
158  QgsRasterCalcNode *mLeft = nullptr;
159  QgsRasterCalcNode *mRight = nullptr;
160  double mNumber = 0;
161  QString mRasterName;
162  QgsRasterMatrix *mMatrix = nullptr;
163  Operator mOperator = opNONE;
164  //added for the conditional statement
165  QString mFunctionName;
166  QVector <QgsRasterCalcNode *> mFunctionArgs;
167 };
168 
169 
170 #endif // QGSRASTERCALCNODE_H
QgsRasterCalcNode::opACOS
@ opACOS
Definition: qgsrastercalcnode.h:64
QgsRasterCalcNode::opASIN
@ opASIN
Definition: qgsrastercalcnode.h:63
QgsRasterCalcNode::tNumber
@ tNumber
Definition: qgsrastercalcnode.h:45
QgsRasterCalcNode::tMatrix
@ tMatrix
Definition: qgsrastercalcnode.h:47
QgsRasterCalcNode
Represents a node in a raster calculator.
Definition: qgsrastercalcnode.h:38
QgsRasterCalcNode::opSIGN
@ opSIGN
Definition: qgsrastercalcnode.h:74
qgis.h
QgsRasterCalcNode::tRasterRef
@ tRasterRef
Definition: qgsrastercalcnode.h:46
QgsRasterCalcNode::opMUL
@ opMUL
Definition: qgsrastercalcnode.h:56
QgsRasterCalcNode::Operator
Operator
possible operators
Definition: qgsrastercalcnode.h:52
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsRasterCalcNode::opPLUS
@ opPLUS
Definition: qgsrastercalcnode.h:54
QgsRasterCalcNode::opSIN
@ opSIN
Definition: qgsrastercalcnode.h:60
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsRasterCalcNode::opNE
@ opNE
Definition: qgsrastercalcnode.h:67
QgsRasterCalcNode::opGE
@ opGE
Definition: qgsrastercalcnode.h:70
QgsRasterCalcNode::type
Type type() const
Definition: qgsrastercalcnode.h:101
QgsRasterCalcNode::opTAN
@ opTAN
Definition: qgsrastercalcnode.h:62
QgsRasterCalcNode::opGT
@ opGT
=
Definition: qgsrastercalcnode.h:68
qgis_sip.h
QgsRasterCalcNode::opLOG10
@ opLOG10
Definition: qgsrastercalcnode.h:76
QgsRasterCalcNode::opNONE
@ opNONE
Definition: qgsrastercalcnode.h:80
QgsRasterCalcNode::Type
Type
defines possible types of node
Definition: qgsrastercalcnode.h:42
QgsRasterMatrix
Represents a matrix in a raster calculator operation.
Definition: qgsrastermatrix.h:29
QgsRasterCalcNode::opLE
@ opLE
Definition: qgsrastercalcnode.h:71
QgsRasterCalcNode::setRight
void setRight(QgsRasterCalcNode *right)
Definition: qgsrastercalcnode.h:105
QgsRasterCalcNode::opEQ
@ opEQ
Definition: qgsrastercalcnode.h:66
QgsRasterCalcNode::opATAN
@ opATAN
Definition: qgsrastercalcnode.h:65
QgsRasterCalcNode::opDIV
@ opDIV
Definition: qgsrastercalcnode.h:57
str
#define str(x)
Definition: qgis.cpp:37
QgsRasterCalcNode::opSQRT
@ opSQRT
Definition: qgsrastercalcnode.h:59
QgsRasterCalcNode::opLOG
@ opLOG
Definition: qgsrastercalcnode.h:75
QgsRasterCalcNode::opMIN
@ opMIN
Definition: qgsrastercalcnode.h:79
QgsRasterCalcNode::opCOS
@ opCOS
Definition: qgsrastercalcnode.h:61
QgsRasterCalcNode::opOR
@ opOR
Definition: qgsrastercalcnode.h:73
QgsRasterCalcNode::opMAX
@ opMAX
Definition: qgsrastercalcnode.h:78
QgsRasterCalcNode::opLT
@ opLT
Definition: qgsrastercalcnode.h:69
QgsRasterCalcNode::setLeft
void setLeft(QgsRasterCalcNode *left)
Definition: qgsrastercalcnode.h:104
QgsRasterCalcNode::opMINUS
@ opMINUS
Definition: qgsrastercalcnode.h:55
QgsRasterCalcNode::opABS
@ opABS
Definition: qgsrastercalcnode.h:77
QgsRasterCalcNode::opPOW
@ opPOW
Definition: qgsrastercalcnode.h:58
QgsRasterBlock
Raster data container.
Definition: qgsrasterblock.h:36
QgsRasterCalcNode::opAND
@ opAND
Definition: qgsrastercalcnode.h:72