GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-bea8435a9e
c_minx.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 #include <grass/raster.h>
3 
4 void c_minx(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
5 {
6  DCELL min, minx;
7  int i;
8 
10  Rast_set_d_null_value(&minx, 1);
11 
12  for (i = 0; i < n; i++) {
13  if (Rast_is_d_null_value(&values[i]))
14  continue;
15 
16  if (Rast_is_d_null_value(&min) || min > values[i]) {
17  min = values[i];
18  minx = i;
19  }
20  }
21 
22  if (Rast_is_d_null_value(&minx))
23  Rast_set_d_null_value(result, 1);
24  else
25  *result = minx;
26 }
void c_minx(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
Definition: c_minx.c:4
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 min(x, y)
Definition: draw2.c:29
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