-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraster.c
70 lines (62 loc) · 1.55 KB
/
raster.c
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
#include <grass/raster.h>
#include "global.h"
void set(struct raster_map *buf, int row, int col, double value)
{
switch (buf->type) {
case CELL_TYPE:
buf->map.c[row][col] = (CELL) value;
break;
case FCELL_TYPE:
buf->map.f[row][col] = (FCELL) value;
break;
case DCELL_TYPE:
buf->map.d[row][col] = (DCELL) value;
break;
}
}
double get(struct raster_map *buf, int row, int col)
{
double value = 0;
switch (buf->type) {
case CELL_TYPE:
value = (double)buf->map.c[row][col];
break;
case FCELL_TYPE:
value = (double)buf->map.f[row][col];
break;
case DCELL_TYPE:
value = buf->map.d[row][col];
break;
}
return value;
}
int is_null(struct raster_map *buf, int row, int col)
{
int is_null_value = 0;
switch (buf->type) {
case CELL_TYPE:
is_null_value = Rast_is_c_null_value(&buf->map.c[row][col]);
break;
case FCELL_TYPE:
is_null_value = Rast_is_f_null_value(&buf->map.f[row][col]);
break;
case DCELL_TYPE:
is_null_value = Rast_is_d_null_value(&buf->map.d[row][col]);
break;
}
return is_null_value;
}
void set_null(struct raster_map *buf, int row, int col)
{
switch (buf->type) {
case CELL_TYPE:
Rast_set_c_null_value(&buf->map.c[row][col], 1);
break;
case FCELL_TYPE:
Rast_set_f_null_value(&buf->map.f[row][col], 1);
break;
case DCELL_TYPE:
Rast_set_d_null_value(&buf->map.d[row][col], 1);
break;
}
}