QGIS API Documentation  2.99.0-Master (7fe5405)
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 
26 class ANALYSIS_EXPORT QgsRasterMatrix
27 {
28  public:
29 
31  {
37  opEQ, // =
38  opNE, // != resp. <>
39  opGT, // >
40  opLT, // <
41  opGE, // >=
42  opLE, // <=
44  opOR
45  };
46 
48  {
59  };
60 
64  QgsRasterMatrix( int nCols, int nRows, double* data, double nodataValue );
65  QgsRasterMatrix( const QgsRasterMatrix& m );
66  ~QgsRasterMatrix();
67 
69  bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
70  double number() const { return mData[0]; }
71 
74  double* data() { return mData; }
77  double* takeData();
78 
79  void setData( int cols, int rows, double* data, double nodataValue );
80 
81  int nColumns() const { return mColumns; }
82  int nRows() const { return mRows; }
83 
84  double nodataValue() const { return mNodataValue; }
85  void setNodataValue( double d ) { mNodataValue = d; }
86 
87  QgsRasterMatrix& operator=( const QgsRasterMatrix& m );
89  bool add( const QgsRasterMatrix& other );
91  bool subtract( const QgsRasterMatrix& other );
92  bool multiply( const QgsRasterMatrix& other );
93  bool divide( const QgsRasterMatrix& other );
94  bool power( const QgsRasterMatrix& other );
95  bool equal( const QgsRasterMatrix& other );
96  bool notEqual( const QgsRasterMatrix& other );
97  bool greaterThan( const QgsRasterMatrix& other );
98  bool lesserThan( const QgsRasterMatrix& other );
99  bool greaterEqual( const QgsRasterMatrix& other );
100  bool lesserEqual( const QgsRasterMatrix& other );
101  bool logicalAnd( const QgsRasterMatrix& other );
102  bool logicalOr( const QgsRasterMatrix& other );
103 
104  bool squareRoot();
105  bool sinus();
106  bool asinus();
107  bool cosinus();
108  bool acosinus();
109  bool tangens();
110  bool atangens();
111  bool changeSign();
112  bool log();
113  bool log10();
114 
115  private:
116  int mColumns;
117  int mRows;
118  double* mData;
119  double mNodataValue;
120 
122  bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix& other );
123  double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
124 
125  /*sqrt, sin, cos, tan, asin, acos, atan*/
126  bool oneArgumentOperation( OneArgOperator op );
127  bool testPowerValidity( double base, double power ) const;
128 };
129 
130 #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
int nColumns() const
double number() const
double * data()
Returns data array (but not ownership)