~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to raster/r.mapcalc/xand2.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
#include <grass/gis.h>
 
3
#include <grass/raster.h>
3
4
#include "globals.h"
4
5
#include "expression.h"
5
6
#include "func_proto.h"
6
7
 
7
8
/****************************************************************
8
 
and2(a,b) = a && b
 
9
and2(a,b,c,...) = a && b && c && ...
9
10
 
10
11
Differs from and() in that the boolean axioms:
11
12
 
18
19
int f_and2(int argc, const int *argt, void **args)
19
20
{
20
21
    CELL *res = args[0];
21
 
    CELL *arg1 = args[1];
22
 
    CELL *arg2 = args[2];
23
 
    int i;
 
22
    CELL **argz = (CELL **) args;
 
23
    int i, j;
24
24
 
25
 
    if (argc < 2)
 
25
    if (argc < 1)
26
26
        return E_ARG_LO;
27
 
    if (argc > 2)
28
 
        return E_ARG_HI;
29
 
 
30
 
    if (argt[1] != CELL_TYPE || argt[2] != CELL_TYPE)
31
 
        return E_ARG_TYPE;
32
27
 
33
28
    if (argt[0] != CELL_TYPE)
34
29
        return E_RES_TYPE;
35
30
 
 
31
    for (i = 1; i <= argc; i++)
 
32
        if (argt[i] != CELL_TYPE)
 
33
            return E_ARG_TYPE;
 
34
 
36
35
    for (i = 0; i < columns; i++) {
37
 
        if (!IS_NULL_C(&arg1[i]) && !arg1[i])
38
 
            res[i] = 0;
39
 
        else if (!IS_NULL_C(&arg2[i]) && !arg2[i])
40
 
            res[i] = 0;
41
 
        else if (IS_NULL_C(&arg1[i]) || IS_NULL_C(&arg2[i]))
42
 
            SET_NULL_C(&res[i]);
43
 
        else
44
 
            res[i] = 1;
 
36
        res[i] = 1;
 
37
        for (j = 1; j <= argc; j++) {
 
38
            if (!IS_NULL_C(&argz[j][i]) && !argz[j][i]) {
 
39
                res[i] = 0;
 
40
                break;
 
41
            }
 
42
            if (IS_NULL_C(&argz[j][i]))
 
43
                SET_NULL_C(&res[i]);
 
44
        }
45
45
    }
46
46
 
47
47
    return 0;