GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r73122
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
c_maxx.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 #include <grass/raster.h>
3 
4 void c_maxx(DCELL * result, DCELL * values, int n, const void *closure)
5 {
6  DCELL max, maxx;
7  int i;
8 
9  Rast_set_d_null_value(&max, 1);
10  Rast_set_d_null_value(&maxx, 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(&max) || max < values[i]) {
17  max = values[i];
18  maxx = i;
19  }
20  }
21 
22  if (Rast_is_d_null_value(&maxx))
23  Rast_set_d_null_value(result, 1);
24  else
25  *result = maxx;
26 }
double DCELL
Definition: gis.h:581
#define max(x, y)
Definition: draw2.c:32
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
void c_maxx(DCELL *result, DCELL *values, int n, const void *closure)
Definition: c_maxx.c:4
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