GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-d6dec75dd4
xisnull.c
Go to the documentation of this file.
1
#include <
grass/gis.h
>
2
#include <
grass/raster.h
>
3
#include <
grass/calc.h
>
4
5
/**********************************************************************
6
isnull(x)
7
return 1 if x is null, 0 otherwise
8
**********************************************************************/
9
10
int
f_isnull
(
int
argc,
const
int
*argt,
void
**args)
11
{
12
int
*res = args[0];
13
int
i;
14
15
if
(argc < 1)
16
return
E_ARG_LO
;
17
if
(argc > 1)
18
return
E_ARG_HI
;
19
20
if
(argt[0] !=
CELL_TYPE
)
21
return
E_RES_TYPE
;
22
23
switch
(argt[1]) {
24
case
CELL_TYPE
: {
25
CELL
*arg1 = args[1];
26
27
for
(i = 0; i <
columns
; i++)
28
res[i] =
IS_NULL_C
(&arg1[i]) ? 1 : 0;
29
return
0;
30
}
31
case
FCELL_TYPE
: {
32
FCELL
*arg1 = args[1];
33
34
for
(i = 0; i <
columns
; i++)
35
res[i] =
IS_NULL_F
(&arg1[i]) ? 1 : 0;
36
return
0;
37
}
38
case
DCELL_TYPE
: {
39
DCELL
*arg1 = args[1];
40
41
for
(i = 0; i <
columns
; i++)
42
res[i] =
IS_NULL_D
(&arg1[i]) ? 1 : 0;
43
return
0;
44
}
45
default
:
46
return
E_INV_TYPE
;
47
}
48
}
49
50
int
c_isnull
(
int
argc,
int
*argt)
51
{
52
if
(argc < 1)
53
return
E_ARG_LO
;
54
if
(argc > 1)
55
return
E_ARG_HI
;
56
57
argt[0] =
CELL_TYPE
;
58
59
return
0;
60
}
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
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
f_isnull
int f_isnull(int argc, const int *argt, void **args)
Definition:
xisnull.c:10
c_isnull
int c_isnull(int argc, int *argt)
Definition:
xisnull.c:50
lib
calc
xisnull.c
Generated on Sun Dec 22 2024 07:38:22 for GRASS GIS 8 Programmer's Manual by
1.9.1