GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_range.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 
3 void c_range(DCELL * result, DCELL * values, int n, const void *closure)
4 {
5  DCELL min, max;
6  int i;
7 
8  G_set_d_null_value(&min, 1);
9  G_set_d_null_value(&max, 1);
10 
11  for (i = 0; i < n; i++) {
12  if (G_is_d_null_value(&values[i]))
13  continue;
14 
15  if (G_is_d_null_value(&min) || min > values[i])
16  min = values[i];
17 
18  if (G_is_d_null_value(&max) || max < values[i])
19  max = values[i];
20  }
21 
22  if (G_is_d_null_value(&min) || G_is_d_null_value(&max))
23  G_set_d_null_value(result, 1);
24  else
25  *result = max - min;
26 }
#define min(x, y)
Definition: draw2.c:68
void G_set_d_null_value(DCELL *dcellVals, int numVals)
Definition: null_val.c:176
#define max(x, y)
Definition: draw2.c:69
void c_range(DCELL *result, DCELL *values, int n, const void *closure)
Definition: c_range.c:3
int G_is_d_null_value(const DCELL *dcellVal)
Returns 1 if dcell is NULL, 0 otherwise. This will test if the value dcell is a NaN. Same test as in G_is_f_null_value().
Definition: null_val.c:306
int n
Definition: dataquad.c:291