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