GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
xand2.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
and2(a,b,c,...) = a && b && c && ...
8
9
Differs from and() in that the boolean axioms:
10
11
false && x == false
12
x && false == false
13
14
hold even when x is null.
15
****************************************************************/
16
17
int
f_and2
(
int
argc,
const
int
*argt,
void
**args)
18
{
19
CELL
*res = args[0];
20
CELL
**argz = (
CELL
**) args;
21
int
i, j;
22
23
if
(argc < 1)
24
return
E_ARG_LO
;
25
26
if
(argt[0] !=
CELL_TYPE
)
27
return
E_RES_TYPE
;
28
29
for
(i = 1; i <= argc; i++)
30
if
(argt[i] !=
CELL_TYPE
)
31
return
E_ARG_TYPE
;
32
33
for
(i = 0; i <
columns
; i++) {
34
res[i] = 1;
35
for
(j = 1; j <= argc; j++) {
36
if
(!
IS_NULL_C
(&argz[j][i]) && !argz[j][i]) {
37
res[i] = 0;
38
break
;
39
}
40
if
(
IS_NULL_C
(&argz[j][i]))
41
SET_NULL_C
(&res[i]);
42
}
43
}
44
45
return
0;
46
}
CELL_TYPE
#define CELL_TYPE
Definition:
raster.h:11
SET_NULL_C
#define SET_NULL_C(x)
Definition:
calc.h:32
E_ARG_TYPE
Definition:
calc.h:14
IS_NULL_C
#define IS_NULL_C(x)
Definition:
calc.h:28
columns
int columns
Definition:
calc.c:12
raster.h
gis.h
f_and2
int f_and2(int argc, const int *argt, void **args)
Definition:
xand2.c:17
E_ARG_LO
Definition:
calc.h:12
CELL
int CELL
Definition:
gis.h:602
E_RES_TYPE
Definition:
calc.h:15
calc.h
lib
calc
xand2.c
Generated on Mon May 31 2021 05:21:32 for GRASS GIS 7 Programmer's Manual by
1.8.13