-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDEM.h
60 lines (54 loc) · 1.05 KB
/
DEM.h
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
#ifndef DEM_HEADER_H
#define DEM_HEADER_H
#include <string>
#include <algorithm>
#include <fstream>
#include <queue>
#include <functional>
#define NO_DATA_VALUE -9999.0f
/*
* reverse flow direction
* 2 4 8
* 1 0 16
* 128 64 32
*/
static unsigned char inverse[8] = {16, 32, 64, 128, 1, 2, 4, 8};
/*
* flow direction
* 32 64 128
* 16 0 1
* 8 4 2
*/
static unsigned char dir[8] = {1, 2, 4, 8, 16, 32, 64, 128};
class DEM
{
protected:
float* pDem;
int width, height;
public:
DEM()
{
pDem=NULL;
}
~DEM()
{
delete[] pDem;
}
bool Allocate();
void freeMem();
void initialElementsNodata();
float asFloat(int row,int col) const;
void Set_Value(int row,int col, float z);
bool is_NoData(int row, int col) const;
void Assign_NoData();
int Get_NY() const;
int Get_NX() const;
float* getDEMdata() const;
void SetHeight(int height);
void SetWidth(int width);
void readDEM(const std::string& filePath);
bool is_InGrid(int row, int col) const;
float getLength(unsigned int dir);
unsigned char computeDirection(int row, int col, float spill);
};
#endif