GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-bea8435a9e
c_max.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 #include <grass/raster.h>
3 
4 void c_max(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
5 {
6  DCELL max;
7  int i;
8 
10 
11  for (i = 0; i < n; i++) {
12  if (Rast_is_d_null_value(&values[i]))
13  continue;
14 
15  if (Rast_is_d_null_value(&max) || max < values[i])
16  max = values[i];
17  }
18 
20  Rast_set_d_null_value(result, 1);
21  else
22  *result = max;
23 }
24 
25 void w_max(DCELL *result, DCELL (*values)[2], int n, const void *closure UNUSED)
26 {
27  DCELL max;
28  int i;
29 
31 
32  for (i = 0; i < n; i++) {
33  if (Rast_is_d_null_value(&values[i][0]))
34  continue;
35 
36  if (Rast_is_d_null_value(&max) || max < values[i][0])
37  max = values[i][0];
38  }
39 
41  Rast_set_d_null_value(result, 1);
42  else
43  *result = max;
44 }
void c_max(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
Definition: c_max.c:4
void w_max(DCELL *result, DCELL(*values)[2], int n, const void *closure UNUSED)
Definition: c_max.c:25
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
Definition: null_val.c:153
#define Rast_is_d_null_value(dcellVal)
Definition: defs/raster.h:408
#define max(x, y)
Definition: draw2.c:30
double DCELL
Definition: gis.h:629
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Definition: gis.h:47