QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
33 {
39 opEQ, // =
40 opNE, // != resp. <>
41 opGT, // >
42 opLT, // <
43 opGE, // >=
44 opLE, // <=
48 opMAX
49 };
50
65
66 QgsRasterMatrix() = default;
67
72 QgsRasterMatrix( int nCols, int nRows, double *data, double nodataValue ) SIP_SKIP;
75
77 bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
78 double number() const { return mData[0]; }
79
84 double *data() SIP_SKIP { return mData; }
85
90 double *takeData() SIP_SKIP;
91
92 void setData( int cols, int rows, double *data, double nodataValue );
93
94 int nColumns() const { return mColumns; }
95 int nRows() const { return mRows; }
96
97 double nodataValue() const { return mNodataValue; }
98 void setNodataValue( double d ) { mNodataValue = d; }
99
100 QgsRasterMatrix &operator=( const QgsRasterMatrix &m );
102 bool add( const QgsRasterMatrix &other );
104 bool subtract( const QgsRasterMatrix &other );
105 bool multiply( const QgsRasterMatrix &other );
106 bool divide( const QgsRasterMatrix &other );
107 bool power( const QgsRasterMatrix &other );
108 bool equal( const QgsRasterMatrix &other );
109 bool notEqual( const QgsRasterMatrix &other );
110 bool greaterThan( const QgsRasterMatrix &other );
111 bool lesserThan( const QgsRasterMatrix &other );
112 bool greaterEqual( const QgsRasterMatrix &other );
113 bool lesserEqual( const QgsRasterMatrix &other );
114 bool logicalAnd( const QgsRasterMatrix &other );
115 bool logicalOr( const QgsRasterMatrix &other );
116
122 bool max( const QgsRasterMatrix &other );
123
129 bool min( const QgsRasterMatrix &other );
130
131 bool squareRoot();
132 bool sinus();
133 bool asinus();
134 bool cosinus();
135 bool acosinus();
136 bool tangens();
137 bool atangens();
138 bool changeSign();
139 bool log();
140 bool log10();
141
147 bool absoluteValue();
148
149 private:
150 int mColumns = 0;
151 int mRows = 0;
152 double *mData = nullptr;
153 double mNodataValue = -1;
154
156 bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
157 double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;
158
159 /*sqrt, std::sin, std::cos, tan, asin, acos, atan*/
160 bool oneArgumentOperation( OneArgOperator op );
161 bool testPowerValidity( double base, double power ) const;
162};
163
164#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