QGIS API Documentation  2.9.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 class ANALYSIS_EXPORT QgsRasterMatrix
22 {
23  public:
24 
26  {
32  opEQ, // =
33  opNE, // != resp. <>
34  opGT, // >
35  opLT, // <
36  opGE, // >=
37  opLE, // <=
39  opOR
40  };
41 
43  {
54  };
55 
59  QgsRasterMatrix( int nCols, int nRows, float* data, double nodataValue );
60  QgsRasterMatrix( const QgsRasterMatrix& m );
61  ~QgsRasterMatrix();
62 
64  bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
65  double number() const { return mData[0]; }
66 
68  float* data() { return mData; }
71  float* takeData();
73 
74  void setData( int cols, int rows, float* data, double nodataValue );
75 
76  int nColumns() const { return mColumns; }
77  int nRows() const { return mRows; }
78 
79  double nodataValue() const { return mNodataValue; }
80  void setNodataValue( double d ) { mNodataValue = d; }
81 
82  QgsRasterMatrix& operator=( const QgsRasterMatrix& m );
84  bool add( const QgsRasterMatrix& other );
86  bool subtract( const QgsRasterMatrix& other );
87  bool multiply( const QgsRasterMatrix& other );
88  bool divide( const QgsRasterMatrix& other );
89  bool power( const QgsRasterMatrix& other );
90  bool equal( const QgsRasterMatrix& other );
91  bool notEqual( const QgsRasterMatrix& other );
92  bool greaterThan( const QgsRasterMatrix& other );
93  bool lesserThan( const QgsRasterMatrix& other );
94  bool greaterEqual( const QgsRasterMatrix& other );
95  bool lesserEqual( const QgsRasterMatrix& other );
96  bool logicalAnd( const QgsRasterMatrix& other );
97  bool logicalOr( const QgsRasterMatrix& other );
98 
99  bool squareRoot();
100  bool sinus();
101  bool asinus();
102  bool cosinus();
103  bool acosinus();
104  bool tangens();
105  bool atangens();
106  bool changeSign();
107  bool log();
108  bool log10();
109 
110  private:
111  int mColumns;
112  int mRows;
113  float* mData;
114  double mNodataValue;
115 
117  bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix& other );
118  /*sqrt, sin, cos, tan, asin, acos, atan*/
119  bool oneArgumentOperation( OneArgOperator op );
120  bool testPowerValidity( double base, double power );
121 };
122 
123 #endif // QGSRASTERMATRIX_H
void setNodataValue(double d)
int nColumns() const
double number() const
int nRows() const
bool isNumber() const
Returns true if matrix is 1x1 (=scalar number)
double ANALYSIS_EXPORT power(double a, int b)
power function for integer coefficients
double nodataValue() const