QGIS API Documentation  3.6.0-Noosa (5873452)
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, // <=
46  opOR
47  };
48 
50  {
61  };
62 
64  QgsRasterMatrix() = default;
65 
67  QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue ) SIP_SKIP;
68  QgsRasterMatrix( const QgsRasterMatrix &m );
69  ~QgsRasterMatrix();
70 
72  bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
73  double number() const { return mData[0]; }
74 
79  double *data() { return mData; } SIP_SKIP
80 
85  double *takeData() SIP_SKIP;
86 
87  void setData( int cols, int rows, double *data, double nodataValue );
88 
89  int nColumns() const { return mColumns; }
90  int nRows() const { return mRows; }
91 
92  double nodataValue() const { return mNodataValue; }
93  void setNodataValue( double d ) { mNodataValue = d; }
94 
95  QgsRasterMatrix &operator=( const QgsRasterMatrix &m );
97  bool add( const QgsRasterMatrix &other );
99  bool subtract( const QgsRasterMatrix &other );
100  bool multiply( const QgsRasterMatrix &other );
101  bool divide( const QgsRasterMatrix &other );
102  bool power( const QgsRasterMatrix &other );
103  bool equal( const QgsRasterMatrix &other );
104  bool notEqual( const QgsRasterMatrix &other );
105  bool greaterThan( const QgsRasterMatrix &other );
106  bool lesserThan( const QgsRasterMatrix &other );
107  bool greaterEqual( const QgsRasterMatrix &other );
108  bool lesserEqual( const QgsRasterMatrix &other );
109  bool logicalAnd( const QgsRasterMatrix &other );
110  bool logicalOr( const QgsRasterMatrix &other );
111 
112  bool squareRoot();
113  bool sinus();
114  bool asinus();
115  bool cosinus();
116  bool acosinus();
117  bool tangens();
118  bool atangens();
119  bool changeSign();
120  bool log();
121  bool log10();
122 
123  private:
124  int mColumns = 0;
125  int mRows = 0;
126  double *mData = nullptr;
127  double mNodataValue = -1;
128 
130  bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
131  double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
132 
133  /*sqrt, std::sin, std::cos, tan, asin, acos, atan*/
134  bool oneArgumentOperation( OneArgOperator op );
135  bool testPowerValidity( double base, double power ) const;
136 };
137 
138 #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:119
int nColumns() const
double number() const
double * data()
Returns data array (but not ownership)