GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
c_min.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 #include <grass/raster.h>
3 
4 void c_min(DCELL * result, DCELL * values, int n, const void *closure)
5 {
6  DCELL min;
7  int i;
8 
9  Rast_set_d_null_value(&min, 1);
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(&min) || min > values[i])
16  min = values[i];
17  }
18 
19  if (Rast_is_d_null_value(&min))
20  Rast_set_d_null_value(result, 1);
21  else
22  *result = min;
23 }
24 
25 void w_min(DCELL * result, DCELL(*values)[2], int n, const void *closure)
26 {
27  DCELL min;
28  int i;
29 
30  Rast_set_d_null_value(&min, 1);
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(&min) || min > values[i][0])
37  min = values[i][0];
38  }
39 
40  if (Rast_is_d_null_value(&min))
41  Rast_set_d_null_value(result, 1);
42  else
43  *result = min;
44 }
#define min(x, y)
Definition: draw2.c:31
double DCELL
Definition: gis.h:581
void c_min(DCELL *result, DCELL *values, int n, const void *closure)
Definition: c_min.c:4
void w_min(DCELL *result, DCELL(*values)[2], int n, const void *closure)
Definition: c_min.c:25
void Rast_set_d_null_value(DCELL *dcellVals, int numVals)
To set a number of DCELL raster values to NULL.
Definition: null_val.c:155
int Rast_is_d_null_value(const DCELL *dcellVal)
To check if a DCELL raster value is set to NULL.
Definition: null_val.c:261