GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
xeval.c
Go to the documentation of this file.
1 
2 #include <grass/gis.h>
3 #include <grass/raster.h>
4 #include <grass/calc.h>
5 
6 /**********************************************************************
7 eval(..,..,..,x) = x
8 
9  return last argument
10 **********************************************************************/
11 
12 int f_eval(int argc, const int *argt, void **args)
13 {
14  int i;
15 
16  if (argc < 1)
17  return E_ARG_LO;
18 
19  if (argt[0] != argt[argc])
20  return E_RES_TYPE;
21 
22  switch (argt[argc]) {
23  case CELL_TYPE:
24  {
25  CELL *res = args[0];
26  CELL *arg1 = args[argc];
27 
28  for (i = 0; i < columns; i++)
29  if (IS_NULL_C(&arg1[i]))
30  SET_NULL_C(&res[i]);
31  else
32  res[i] = arg1[i];
33 
34  return 0;
35  }
36  case FCELL_TYPE:
37  {
38  FCELL *res = args[0];
39  FCELL *arg1 = args[argc];
40 
41  for (i = 0; i < columns; i++)
42  if (IS_NULL_F(&arg1[i]))
43  SET_NULL_F(&res[i]);
44  else
45  res[i] = arg1[i];
46  return 0;
47  }
48  case DCELL_TYPE:
49  {
50  DCELL *res = args[0];
51  DCELL *arg1 = args[argc];
52 
53  for (i = 0; i < columns; i++)
54  if (IS_NULL_D(&arg1[i]))
55  SET_NULL_D(&res[i]);
56  else
57  res[i] = arg1[i];
58  return 0;
59  }
60  default:
61  return E_INV_TYPE;
62  }
63 }
64 
65 int c_eval(int argc, int *argt)
66 {
67  if (argc < 1)
68  return E_ARG_LO;
69 
70  argt[0] = argt[argc];
71 
72  return 0;
73 }
#define CELL_TYPE
Definition: raster.h:11
#define SET_NULL_C(x)
Definition: calc.h:32
double DCELL
Definition: gis.h:603
int c_eval(int argc, int *argt)
Definition: xeval.c:65
#define IS_NULL_F(x)
Definition: calc.h:29
#define IS_NULL_C(x)
Definition: calc.h:28
int columns
Definition: calc.c:12
#define DCELL_TYPE
Definition: raster.h:13
Definition: calc.h:12
float FCELL
Definition: gis.h:604
#define IS_NULL_D(x)
Definition: calc.h:30
int CELL
Definition: gis.h:602
#define FCELL_TYPE
Definition: raster.h:12
#define SET_NULL_F(x)
Definition: calc.h:33
#define SET_NULL_D(x)
Definition: calc.h:34
int f_eval(int argc, const int *argt, void **args)
Definition: xeval.c:12