QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsrastermatrix.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrastermatrix.h
3  -----------------
4  begin : 2010-10-23
5  copyright : (C) 20010 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
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 QGSRASTERMATRIX_H
19 #define QGSRASTERMATRIX_H
20 
21 #include "qgis_analysis.h"
22 #include "qgis_sip.h"
23 
29 class ANALYSIS_EXPORT QgsRasterMatrix
30 {
31  public:
32 
34  {
40  opEQ, // =
41  opNE, // != resp. <>
42  opGT, // >
43  opLT, // <
44  opGE, // >=
45  opLE, // <=
49  opMAX
50  };
51 
53  {
65  };
66 
68  QgsRasterMatrix() = default;
69 
71  QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue ) SIP_SKIP;
72  QgsRasterMatrix( const QgsRasterMatrix &m );
73  ~QgsRasterMatrix();
74 
76  bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
77  double number() const { return mData[0]; }
78 
83  double *data() { return mData; } SIP_SKIP
84 
89  double *takeData() SIP_SKIP;
90 
91  void setData( int cols, int rows, double *data, double nodataValue );
92 
93  int nColumns() const { return mColumns; }
94  int nRows() const { return mRows; }
95 
96  double nodataValue() const { return mNodataValue; }
97  void setNodataValue( double d ) { mNodataValue = d; }
98 
99  QgsRasterMatrix &operator=( const QgsRasterMatrix &m );
101  bool add( const QgsRasterMatrix &other );
103  bool subtract( const QgsRasterMatrix &other );
104  bool multiply( const QgsRasterMatrix &other );
105  bool divide( const QgsRasterMatrix &other );
106  bool power( const QgsRasterMatrix &other );
107  bool equal( const QgsRasterMatrix &other );
108  bool notEqual( const QgsRasterMatrix &other );
109  bool greaterThan( const QgsRasterMatrix &other );
110  bool lesserThan( const QgsRasterMatrix &other );
111  bool greaterEqual( const QgsRasterMatrix &other );
112  bool lesserEqual( const QgsRasterMatrix &other );
113  bool logicalAnd( const QgsRasterMatrix &other );
114  bool logicalOr( const QgsRasterMatrix &other );
115 
121  bool max( const QgsRasterMatrix &other );
122 
128  bool min( const QgsRasterMatrix &other );
129 
130  bool squareRoot();
131  bool sinus();
132  bool asinus();
133  bool cosinus();
134  bool acosinus();
135  bool tangens();
136  bool atangens();
137  bool changeSign();
138  bool log();
139  bool log10();
140 
146  bool absoluteValue();
147 
148  private:
149  int mColumns = 0;
150  int mRows = 0;
151  double *mData = nullptr;
152  double mNodataValue = -1;
153 
155  bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
156  double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
157 
158  /*sqrt, std::sin, std::cos, tan, asin, acos, atan*/
159  bool oneArgumentOperation( OneArgOperator op );
160  bool testPowerValidity( double base, double power ) const;
161 };
162 
163 #endif // QGSRASTERMATRIX_H
QgsRasterMatrix::opMINUS
@ opMINUS
Definition: qgsrastermatrix.h:36
QgsRasterMatrix::isNumber
bool isNumber() const
Returns true if matrix is 1x1 (=scalar number)
Definition: qgsrastermatrix.h:76
QgsRasterMatrix::number
double number() const
Definition: qgsrastermatrix.h:77
QgsRasterMatrix::opLE
@ opLE
Definition: qgsrastermatrix.h:45
QgsRasterMatrix::opLOG
@ opLOG
Definition: qgsrastermatrix.h:62
QgsRasterMatrix::opNE
@ opNE
Definition: qgsrastermatrix.h:41
QgsRasterMatrix::data
double * data()
Returns data array (but not ownership)
Definition: qgsrastermatrix.h:83
QgsRasterMatrix::nRows
int nRows() const
Definition: qgsrastermatrix.h:94
QgsRasterMatrix::opAND
@ opAND
Definition: qgsrastermatrix.h:46
QgsRasterMatrix::opASIN
@ opASIN
Definition: qgsrastermatrix.h:58
QgsRasterMatrix::setNodataValue
void setNodataValue(double d)
Definition: qgsrastermatrix.h:97
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsRasterMatrix::opSIN
@ opSIN
Definition: qgsrastermatrix.h:55
QgsRasterMatrix::opMIN
@ opMIN
Definition: qgsrastermatrix.h:48
qgis_sip.h
QgsRasterMatrix::opCOS
@ opCOS
Definition: qgsrastermatrix.h:56
QgsRasterMatrix::opSIGN
@ opSIGN
Definition: qgsrastermatrix.h:61
QgsRasterMatrix::nodataValue
double nodataValue() const
Definition: qgsrastermatrix.h:96
QgsRasterMatrix::opSQRT
@ opSQRT
Definition: qgsrastermatrix.h:54
QgsRasterMatrix
Represents a matrix in a raster calculator operation.
Definition: qgsrastermatrix.h:29
QgsRasterMatrix::opGE
@ opGE
Definition: qgsrastermatrix.h:44
QgsRasterMatrix::opDIV
@ opDIV
Definition: qgsrastermatrix.h:38
QgsRasterMatrix::opPLUS
@ opPLUS
Definition: qgsrastermatrix.h:35
QgsRasterMatrix::opLT
@ opLT
Definition: qgsrastermatrix.h:43
QgsRasterMatrix::opACOS
@ opACOS
Definition: qgsrastermatrix.h:59
QgsRasterMatrix::opABS
@ opABS
Definition: qgsrastermatrix.h:64
QgsRasterMatrix::opGT
@ opGT
Definition: qgsrastermatrix.h:42
QgsRasterMatrix::opEQ
@ opEQ
Definition: qgsrastermatrix.h:40
QgsRasterMatrix::opTAN
@ opTAN
Definition: qgsrastermatrix.h:57
QgsRasterMatrix::TwoArgOperator
TwoArgOperator
Definition: qgsrastermatrix.h:33
QgsRasterMatrix::opLOG10
@ opLOG10
Definition: qgsrastermatrix.h:63
QgsRasterMatrix::opATAN
@ opATAN
Definition: qgsrastermatrix.h:60
QgsRasterMatrix::opPOW
@ opPOW
Definition: qgsrastermatrix.h:39
QgsRasterMatrix::OneArgOperator
OneArgOperator
Definition: qgsrastermatrix.h:52
QgsRasterMatrix::opOR
@ opOR
Definition: qgsrastermatrix.h:47
QgsRasterMatrix::opMUL
@ opMUL
Definition: qgsrastermatrix.h:37