-
-
Notifications
You must be signed in to change notification settings - Fork 294
/
c_max.c
44 lines (34 loc) · 865 Bytes
/
c_max.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
#include <grass/gis.h>
#include <grass/raster.h>
void c_max(DCELL * result, DCELL * values, int n, const void *closure)
{
DCELL max;
int i;
Rast_set_d_null_value(&max, 1);
for (i = 0; i < n; i++) {
if (Rast_is_d_null_value(&values[i]))
continue;
if (Rast_is_d_null_value(&max) || max < values[i])
max = values[i];
}
if (Rast_is_d_null_value(&max))
Rast_set_d_null_value(result, 1);
else
*result = max;
}
void w_max(DCELL * result, DCELL(*values)[2], int n, const void *closure)
{
DCELL max;
int i;
Rast_set_d_null_value(&max, 1);
for (i = 0; i < n; i++) {
if (Rast_is_d_null_value(&values[i][0]))
continue;
if (Rast_is_d_null_value(&max) || max < values[i][0])
max = values[i][0];
}
if (Rast_is_d_null_value(&max))
Rast_set_d_null_value(result, 1);
else
*result = max;
}