QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
28 class ANALYSIS_EXPORT QgsRasterMatrix
29 {
30  public:
31 
33  {
39  opEQ, // =
40  opNE, // != resp. <>
41  opGT, // >
42  opLT, // <
43  opGE, // >=
44  opLE, // <=
48  opMAX
49  };
50 
52  {
64  };
65 
67  QgsRasterMatrix() = default;
68 
70  QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue ) SIP_SKIP;
71  QgsRasterMatrix( const QgsRasterMatrix &m );
72  ~QgsRasterMatrix();
73 
75  bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
76  double number() const { return mData[0]; }
77 
82  double *data() { return mData; } SIP_SKIP
83 
88  double *takeData() SIP_SKIP;
89 
90  void setData( int cols, int rows, double *data, double nodataValue );
91 
92  int nColumns() const { return mColumns; }
93  int nRows() const { return mRows; }
94 
95  double nodataValue() const { return mNodataValue; }
96  void setNodataValue( double d ) { mNodataValue = d; }
97 
98  QgsRasterMatrix &operator=( const QgsRasterMatrix &m );
100  bool add( const QgsRasterMatrix &other );
102  bool subtract( const QgsRasterMatrix &other );
103  bool multiply( const QgsRasterMatrix &other );
104  bool divide( const QgsRasterMatrix &other );
105  bool power( const QgsRasterMatrix &other );
106  bool equal( const QgsRasterMatrix &other );
107  bool notEqual( const QgsRasterMatrix &other );
108  bool greaterThan( const QgsRasterMatrix &other );
109  bool lesserThan( const QgsRasterMatrix &other );
110  bool greaterEqual( const QgsRasterMatrix &other );
111  bool lesserEqual( const QgsRasterMatrix &other );
112  bool logicalAnd( const QgsRasterMatrix &other );
113  bool logicalOr( const QgsRasterMatrix &other );
114 
120  bool max( const QgsRasterMatrix &other );
121 
127  bool min( const QgsRasterMatrix &other );
128 
129  bool squareRoot();
130  bool sinus();
131  bool asinus();
132  bool cosinus();
133  bool acosinus();
134  bool tangens();
135  bool atangens();
136  bool changeSign();
137  bool log();
138  bool log10();
139 
145  bool absoluteValue();
146 
147  private:
148  int mColumns = 0;
149  int mRows = 0;
150  double *mData = nullptr;
151  double mNodataValue = -1;
152 
154  bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
155  double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
156 
157  /*sqrt, std::sin, std::cos, tan, asin, acos, atan*/
158  bool oneArgumentOperation( OneArgOperator op );
159  bool testPowerValidity( double base, double power ) const;
160 };
161 
162 #endif // QGSRASTERMATRIX_H
QgsRasterMatrix::opMINUS
@ opMINUS
Definition: qgsrastermatrix.h:35
QgsRasterMatrix::isNumber
bool isNumber() const
Returns true if matrix is 1x1 (=scalar number)
Definition: qgsrastermatrix.h:75
QgsRasterMatrix::number
double number() const
Definition: qgsrastermatrix.h:76
QgsRasterMatrix::opLE
@ opLE
Definition: qgsrastermatrix.h:44
QgsRasterMatrix::opLOG
@ opLOG
Definition: qgsrastermatrix.h:61
QgsRasterMatrix::opNE
@ opNE
Definition: qgsrastermatrix.h:40
QgsRasterMatrix::data
double * data()
Returns data array (but not ownership)
Definition: qgsrastermatrix.h:82
QgsRasterMatrix::nRows
int nRows() const
Definition: qgsrastermatrix.h:93
QgsRasterMatrix::opAND
@ opAND
Definition: qgsrastermatrix.h:45
QgsRasterMatrix::opASIN
@ opASIN
Definition: qgsrastermatrix.h:57
QgsRasterMatrix::setNodataValue
void setNodataValue(double d)
Definition: qgsrastermatrix.h:96
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsRasterMatrix::opSIN
@ opSIN
Definition: qgsrastermatrix.h:54
QgsRasterMatrix::opMIN
@ opMIN
Definition: qgsrastermatrix.h:47
qgis_sip.h
QgsRasterMatrix::opCOS
@ opCOS
Definition: qgsrastermatrix.h:55
QgsRasterMatrix::opSIGN
@ opSIGN
Definition: qgsrastermatrix.h:60
QgsRasterMatrix::nodataValue
double nodataValue() const
Definition: qgsrastermatrix.h:95
QgsRasterMatrix::opSQRT
@ opSQRT
Definition: qgsrastermatrix.h:53
QgsRasterMatrix::QgsRasterMatrix
QgsRasterMatrix()=default
Takes ownership of data array.
QgsRasterMatrix
Definition: qgsrastermatrix.h:29
QgsRasterMatrix::opGE
@ opGE
Definition: qgsrastermatrix.h:43
QgsRasterMatrix::opDIV
@ opDIV
Definition: qgsrastermatrix.h:37
QgsRasterMatrix::opPLUS
@ opPLUS
Definition: qgsrastermatrix.h:34
QgsRasterMatrix::opLT
@ opLT
Definition: qgsrastermatrix.h:42
QgsRasterMatrix::opACOS
@ opACOS
Definition: qgsrastermatrix.h:58
QgsRasterMatrix::opABS
@ opABS
Definition: qgsrastermatrix.h:63
QgsRasterMatrix::opGT
@ opGT
Definition: qgsrastermatrix.h:41
QgsRasterMatrix::opEQ
@ opEQ
Definition: qgsrastermatrix.h:39
QgsRasterMatrix::opTAN
@ opTAN
Definition: qgsrastermatrix.h:56
QgsRasterMatrix::TwoArgOperator
TwoArgOperator
Definition: qgsrastermatrix.h:33
QgsRasterMatrix::opLOG10
@ opLOG10
Definition: qgsrastermatrix.h:62
QgsRasterMatrix::opATAN
@ opATAN
Definition: qgsrastermatrix.h:59
QgsRasterMatrix::opPOW
@ opPOW
Definition: qgsrastermatrix.h:38
QgsRasterMatrix::OneArgOperator
OneArgOperator
Definition: qgsrastermatrix.h:52
QgsRasterMatrix::opOR
@ opOR
Definition: qgsrastermatrix.h:46
QgsRasterMatrix::opMUL
@ opMUL
Definition: qgsrastermatrix.h:36