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