GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-d6dec75dd4
xdouble.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
/**********************************************************************
8
double(x)
9
converts x to double
10
**********************************************************************/
11
12
int
f_double
(
int
argc,
const
int
*argt,
void
**args)
13
{
14
DCELL
*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] !=
DCELL_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_D
(&res[i]);
32
else
33
res[i] = (
DCELL
)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_D
(&res[i]);
42
else
43
res[i] = (
DCELL
)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_D
(&res[i]);
52
else
53
res[i] = (
DCELL
)arg1[i];
54
return
0;
55
}
56
default
:
57
return
E_INV_TYPE
;
58
}
59
}
60
61
int
c_double
(
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] =
DCELL_TYPE
;
69
/* argt[1] = argt[1]; */
70
71
return
0;
72
}
calc.h
E_INV_TYPE
@ E_INV_TYPE
Definition:
calc.h:15
E_RES_TYPE
@ E_RES_TYPE
Definition:
calc.h:14
E_ARG_HI
@ E_ARG_HI
Definition:
calc.h:12
E_ARG_LO
@ E_ARG_LO
Definition:
calc.h:11
IS_NULL_C
#define IS_NULL_C(x)
Definition:
calc.h:26
SET_NULL_D
#define SET_NULL_D(x)
Definition:
calc.h:32
columns
int columns
Definition:
calc.c:11
IS_NULL_F
#define IS_NULL_F(x)
Definition:
calc.h:27
IS_NULL_D
#define IS_NULL_D(x)
Definition:
calc.h:28
gis.h
FCELL
float FCELL
Definition:
gis.h:630
DCELL
double DCELL
Definition:
gis.h:629
CELL
int CELL
Definition:
gis.h:628
raster.h
FCELL_TYPE
#define FCELL_TYPE
Definition:
raster.h:12
DCELL_TYPE
#define DCELL_TYPE
Definition:
raster.h:13
CELL_TYPE
#define CELL_TYPE
Definition:
raster.h:11
c_double
int c_double(int argc, int *argt)
Definition:
xdouble.c:61
f_double
int f_double(int argc, const int *argt, void **args)
Definition:
xdouble.c:12
lib
calc
xdouble.c
Generated on Sun Dec 22 2024 07:38:22 for GRASS GIS 8 Programmer's Manual by
1.9.1