QGIS API Documentation 3.39.0-Master (3aed037ce22)
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
67 QgsRasterMatrix() = default;
68
73 QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue ) SIP_SKIP;
76
78 bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
79 double number() const { return mData[0]; }
80
85 double *data() { return mData; } SIP_SKIP
86
91 double *takeData() SIP_SKIP;
92
93 void setData( int cols, int rows, double *data, double nodataValue );
94
95 int nColumns() const { return mColumns; }
96 int nRows() const { return mRows; }
97
98 double nodataValue() const { return mNodataValue; }
99 void setNodataValue( double d ) { mNodataValue = d; }
100
101 QgsRasterMatrix &operator=( const QgsRasterMatrix &m );
103 bool add( const QgsRasterMatrix &other );
105 bool subtract( const QgsRasterMatrix &other );
106 bool multiply( const QgsRasterMatrix &other );
107 bool divide( const QgsRasterMatrix &other );
108 bool power( const QgsRasterMatrix &other );
109 bool equal( const QgsRasterMatrix &other );
110 bool notEqual( const QgsRasterMatrix &other );
111 bool greaterThan( const QgsRasterMatrix &other );
112 bool lesserThan( const QgsRasterMatrix &other );
113 bool greaterEqual( const QgsRasterMatrix &other );
114 bool lesserEqual( const QgsRasterMatrix &other );
115 bool logicalAnd( const QgsRasterMatrix &other );
116 bool logicalOr( const QgsRasterMatrix &other );
117
123 bool max( const QgsRasterMatrix &other );
124
130 bool min( const QgsRasterMatrix &other );
131
132 bool squareRoot();
133 bool sinus();
134 bool asinus();
135 bool cosinus();
136 bool acosinus();
137 bool tangens();
138 bool atangens();
139 bool changeSign();
140 bool log();
141 bool log10();
142
148 bool absoluteValue();
149
150 private:
151 int mColumns = 0;
152 int mRows = 0;
153 double *mData = nullptr;
154 double mNodataValue = -1;
155
157 bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
158 double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
159
160 /*sqrt, std::sin, std::cos, tan, asin, acos, atan*/
161 bool oneArgumentOperation( OneArgOperator op );
162 bool testPowerValidity( double base, double power ) const;
163};
164
165#endif // QGSRASTERMATRIX_H
Represents a matrix in a raster calculator operation.
QgsRasterMatrix()=default
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