-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathRasterMatrix.h
More file actions
127 lines (110 loc) · 3.67 KB
/
RasterMatrix.h
File metadata and controls
127 lines (110 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once
// Adapted from RasterMatrix.h
/***************************************************************************
begin : 2010-10-23
copyright : (C) 20010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
enum TwoArgOperator
{
opPLUS,
opMINUS,
opMUL,
opDIV,
opPOW,
opEQ, // =
opNE, // != resp. <>
opGT, // >
opLT, // <
opGE, // >=
opLE, // <=
opAND,
opOR,
opNONE,
};
enum OneArgOperator
{
opSQRT,
opSIN,
opCOS,
opTAN,
opASIN,
opACOS,
opATAN,
opSIGN
};
class RasterMatrix
{
public:
/**Takes ownership of data array*/
RasterMatrix();
//! @note note available in python bindings
RasterMatrix( int nCols, int nRows, float* data, double nodataValue );
RasterMatrix( const RasterMatrix& m );
~RasterMatrix()
{
if (mData != NULL)
delete[] mData;
}
/**Returns true if matrix is 1x1 (=scalar number)*/
bool isNumber() const { return ( mColumns == 1 && mRows == 1 ); }
double number() const { return mData[0]; }
/**Returns data array (but not ownership)*/
//! @note not available in python bindings
float* data() { return mData; }
/**Returns data and ownership. Sets data and nrows, ncols of this matrix to 0*/
//! @note not available in python bindings
float* takeData();
void setData( int cols, int rows, float* data, double nodataValue );
int nColumns() const { return mColumns; }
int nRows() const { return mRows; }
size_t GetBufferSize()
{
return mColumns * mRows * sizeof(float);
}
double nodataValue() const { return mNodataValue; }
void setNodataValue( double d ) { mNodataValue = d; }
RasterMatrix* RasterMatrix::Clone(bool memCopyData);
RasterMatrix& operator=( const RasterMatrix& m );
/**Adds another matrix to this one*/
bool add( const RasterMatrix& other );
/**Subtracts another matrix from this one*/
bool subtract( const RasterMatrix& other );
bool multiply( const RasterMatrix& other );
bool divide( const RasterMatrix& other );
bool power( const RasterMatrix& other );
bool equal( const RasterMatrix& other );
bool notEqual( const RasterMatrix& other );
bool greaterThan( const RasterMatrix& other );
bool lesserThan( const RasterMatrix& other );
bool greaterEqual( const RasterMatrix& other );
bool lesserEqual( const RasterMatrix& other );
bool logicalAnd( const RasterMatrix& other );
bool logicalOr( const RasterMatrix& other );
bool squareRoot();
bool sinus();
bool asinus();
bool cosinus();
bool acosinus();
bool tangens();
bool atangens();
bool changeSign();
/**+,-,*,/,^,<,>,<=,>=,=,!=, and, or*/
bool twoArgumentOperation( TwoArgOperator op, const RasterMatrix& other );
private:
int mColumns;
int mRows;
double mNodataValue;
float* mData;
/*sqrt, sin, cos, tan, asin, acos, atan*/
bool oneArgumentOperation( OneArgOperator op );
bool testPowerValidity( double base, double power );
};