QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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
bool isNumber() const
Returns true if matrix is 1x1 (=scalar number)
void setNodataValue(double d)
double nodataValue() const
int nRows() const
#define SIP_SKIP
Definition: qgis_sip.h:126
int nColumns() const
double number() const
double * data()
Returns data array (but not ownership)