QGIS API Documentation  2.99.0-Master (7d4f81d)
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 
27 class ANALYSIS_EXPORT QgsRasterMatrix
28 {
29  public:
30 
32  {
38  opEQ, // =
39  opNE, // != resp. <>
40  opGT, // >
41  opLT, // <
42  opGE, // >=
43  opLE, // <=
45  opOR
46  };
47 
49  {
60  };
61 
64 
66  QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue ) SIP_SKIP;
67  QgsRasterMatrix( const QgsRasterMatrix &m );
68  ~QgsRasterMatrix();
69 
71  bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
72  double number() const { return mData[0]; }
73 
76  double *data() { return mData; } SIP_SKIP
79  double *takeData() SIP_SKIP;
80 
81  void setData( int cols, int rows, double *data, double nodataValue );
82 
83  int nColumns() const { return mColumns; }
84  int nRows() const { return mRows; }
85 
86  double nodataValue() const { return mNodataValue; }
87  void setNodataValue( double d ) { mNodataValue = d; }
88 
89  QgsRasterMatrix &operator=( const QgsRasterMatrix &m );
91  bool add( const QgsRasterMatrix &other );
93  bool subtract( const QgsRasterMatrix &other );
94  bool multiply( const QgsRasterMatrix &other );
95  bool divide( const QgsRasterMatrix &other );
96  bool power( const QgsRasterMatrix &other );
97  bool equal( const QgsRasterMatrix &other );
98  bool notEqual( const QgsRasterMatrix &other );
99  bool greaterThan( const QgsRasterMatrix &other );
100  bool lesserThan( const QgsRasterMatrix &other );
101  bool greaterEqual( const QgsRasterMatrix &other );
102  bool lesserEqual( const QgsRasterMatrix &other );
103  bool logicalAnd( const QgsRasterMatrix &other );
104  bool logicalOr( const QgsRasterMatrix &other );
105 
106  bool squareRoot();
107  bool sinus();
108  bool asinus();
109  bool cosinus();
110  bool acosinus();
111  bool tangens();
112  bool atangens();
113  bool changeSign();
114  bool log();
115  bool log10();
116 
117  private:
118  int mColumns;
119  int mRows;
120  double *mData = nullptr;
121  double mNodataValue;
122 
124  bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
125  double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
126 
127  /*sqrt, sin, cos, tan, asin, acos, atan*/
128  bool oneArgumentOperation( OneArgOperator op );
129  bool testPowerValidity( double base, double power ) const;
130 };
131 
132 #endif // QGSRASTERMATRIX_H
bool isNumber() const
Returns true if matrix is 1x1 (=scalar number)
double ANALYSIS_EXPORT power(double a, int b)
Power function for integer coefficients.
Definition: MathUtils.cc:468
void setNodataValue(double d)
double nodataValue() const
int nRows() const
#define SIP_SKIP
Definition: qgis_sip.h:119
int nColumns() const
double number() const
double * data()
Returns data array (but not ownership)