QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
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
29class ANALYSIS_EXPORT QgsRasterMatrix
30{
31 public:
32
34 {
40 opEQ, // =
41 opNE, // != resp. <>
42 opGT, // >
43 opLT, // <
44 opGE, // >=
45 opLE, // <=
49 opMAX
50 };
51
66
68 QgsRasterMatrix() = default;
69
71 QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue ) SIP_SKIP;
74
76 bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
77 double number() const { return mData[0]; }
78
83 double *data() { return mData; } SIP_SKIP
84
89 double *takeData() SIP_SKIP;
90
91 void setData( int cols, int rows, double *data, double nodataValue );
92
93 int nColumns() const { return mColumns; }
94 int nRows() const { return mRows; }
95
96 double nodataValue() const { return mNodataValue; }
97 void setNodataValue( double d ) { mNodataValue = d; }
98
99 QgsRasterMatrix &operator=( const QgsRasterMatrix &m );
101 bool add( const QgsRasterMatrix &other );
103 bool subtract( const QgsRasterMatrix &other );
104 bool multiply( const QgsRasterMatrix &other );
105 bool divide( const QgsRasterMatrix &other );
106 bool power( const QgsRasterMatrix &other );
107 bool equal( const QgsRasterMatrix &other );
108 bool notEqual( const QgsRasterMatrix &other );
109 bool greaterThan( const QgsRasterMatrix &other );
110 bool lesserThan( const QgsRasterMatrix &other );
111 bool greaterEqual( const QgsRasterMatrix &other );
112 bool lesserEqual( const QgsRasterMatrix &other );
113 bool logicalAnd( const QgsRasterMatrix &other );
114 bool logicalOr( const QgsRasterMatrix &other );
115
121 bool max( const QgsRasterMatrix &other );
122
128 bool min( const QgsRasterMatrix &other );
129
130 bool squareRoot();
131 bool sinus();
132 bool asinus();
133 bool cosinus();
134 bool acosinus();
135 bool tangens();
136 bool atangens();
137 bool changeSign();
138 bool log();
139 bool log10();
140
146 bool absoluteValue();
147
148 private:
149 int mColumns = 0;
150 int mRows = 0;
151 double *mData = nullptr;
152 double mNodataValue = -1;
153
155 bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
156 double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
157
158 /*sqrt, std::sin, std::cos, tan, asin, acos, atan*/
159 bool oneArgumentOperation( OneArgOperator op );
160 bool testPowerValidity( double base, double power ) const;
161};
162
163#endif // QGSRASTERMATRIX_H
Represents a matrix in a raster calculator operation.
QgsRasterMatrix()=default
Takes ownership of data array.
bool isNumber() const
Returns true if matrix is 1x1 (=scalar number)
int nRows() const
void setNodataValue(double d)
double * data()
Returns data array (but not ownership)
double nodataValue() const
double number() const
#define SIP_SKIP
Definition qgis_sip.h:126