QGIS API Documentation  2.17.0-Master (dfeb663)
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 
24 class ANALYSIS_EXPORT QgsRasterMatrix
25 {
26  public:
27 
29  {
35  opEQ, // =
36  opNE, // != resp. <>
37  opGT, // >
38  opLT, // <
39  opGE, // >=
40  opLE, // <=
42  opOR
43  };
44 
46  {
57  };
58 
62  QgsRasterMatrix( int nCols, int nRows, double* data, double nodataValue );
63  QgsRasterMatrix( const QgsRasterMatrix& m );
64  ~QgsRasterMatrix();
65 
67  bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
68  double number() const { return mData[0]; }
69 
71  double* data() { return mData; }
74  double* takeData();
76 
77  void setData( int cols, int rows, double* data, double nodataValue );
78 
79  int nColumns() const { return mColumns; }
80  int nRows() const { return mRows; }
81 
82  double nodataValue() const { return mNodataValue; }
83  void setNodataValue( double d ) { mNodataValue = d; }
84 
85  QgsRasterMatrix& operator=( const QgsRasterMatrix& m );
87  bool add( const QgsRasterMatrix& other );
89  bool subtract( const QgsRasterMatrix& other );
90  bool multiply( const QgsRasterMatrix& other );
91  bool divide( const QgsRasterMatrix& other );
92  bool power( const QgsRasterMatrix& other );
93  bool equal( const QgsRasterMatrix& other );
94  bool notEqual( const QgsRasterMatrix& other );
95  bool greaterThan( const QgsRasterMatrix& other );
96  bool lesserThan( const QgsRasterMatrix& other );
97  bool greaterEqual( const QgsRasterMatrix& other );
98  bool lesserEqual( const QgsRasterMatrix& other );
99  bool logicalAnd( const QgsRasterMatrix& other );
100  bool logicalOr( const QgsRasterMatrix& other );
101 
102  bool squareRoot();
103  bool sinus();
104  bool asinus();
105  bool cosinus();
106  bool acosinus();
107  bool tangens();
108  bool atangens();
109  bool changeSign();
110  bool log();
111  bool log10();
112 
113  private:
114  int mColumns;
115  int mRows;
116  double* mData;
117  double mNodataValue;
118 
120  bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix& other );
121  double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
122 
123  /*sqrt, sin, cos, tan, asin, acos, atan*/
124  bool oneArgumentOperation( OneArgOperator op );
125  bool testPowerValidity( double base, double power ) const;
126 };
127 
128 #endif // QGSRASTERMATRIX_H
bool isNumber() const
Returns true if matrix is 1x1 (=scalar number)
void setNodataValue(double d)
double nodataValue() const
int nRows() const
int nColumns() const
double ANALYSIS_EXPORT power(double a, int b)
Power function for integer coefficients.
double number() const