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

« back to all changes in this revision

Viewing changes to lib/gis/init_map.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
 
 
2
 
/*--------------------------------------------------------------------------*/
3
 
 
4
 
/* inititializes the random file with descriptor "fd" with "nofRows" rows
5
 
   of zero values columns. each row consists of "nofCols" columns. 
6
 
   assumes that the file is rewound and empty.
7
 
 
8
 
   returns 1 if successful and 0 for any kind of error. */
9
 
 
10
 
#include "G.h"
11
 
 
12
 
/*--------------------------------------------------------------------------*/
13
 
 
14
 
int G__random_d_initialize_0(int fd, int nofRows, int nofCols)
15
 
{
16
 
    struct fileinfo *fcb = &G__.fileinfo[fd];
17
 
    int row, col;
18
 
    double zeroVal, *zeroValP;
19
 
    register XDR *xdrs;
20
 
 
21
 
    xdrs = &fcb->xdrstream;     /* xdr stream is initialized to write into */
22
 
    xdr_setpos(xdrs, 0);        /* G__.work_buf in 'opencell.c' */
23
 
 
24
 
    zeroVal = 0;
25
 
    zeroValP = &zeroVal;
26
 
 
27
 
    for (col = nofCols; col--;)
28
 
        if (!xdr_double(xdrs, zeroValP)) {
29
 
            G_warning
30
 
                ("G_random_d_initialize_0: xdr_double failed for index %d.\n",
31
 
                 col);
32
 
            return -1;
33
 
        }
34
 
 
35
 
    for (row = 0; row < nofRows; row++)
36
 
        if (G__write_data(fd, row, nofCols) == -1) {
37
 
            G_warning("G_random_d_initialize_0: write failed in row %d.\n",
38
 
                      row);
39
 
            return -1;
40
 
        }
41
 
 
42
 
    return 1;
43
 
}
44
 
 
45
 
/*--------------------------------------------------------------------------*/
46
 
 
47
 
/* inititializes the random file with descriptor "fd" with "nofRows" rows
48
 
   of zero values columns. each row consists of "nofCols" columns. 
49
 
   assumes that the file is rewound and empty.
50
 
 
51
 
   returns 1 if successful and 0 for any kind of error. */
52
 
 
53
 
 
54
 
int G__random_f_initialize_0(int fd, int nofRows, int nofCols)
55
 
{
56
 
    struct fileinfo *fcb = &G__.fileinfo[fd];
57
 
    int row, col;
58
 
    float zeroVal, *zeroValP;
59
 
    register XDR *xdrs;
60
 
 
61
 
 
62
 
    xdrs = &fcb->xdrstream;     /* xdr stream is initialized to write into */
63
 
    xdr_setpos(xdrs, 0);        /* G__.work_buf in 'opencell.c' */
64
 
 
65
 
    zeroVal = 0;
66
 
    zeroValP = &zeroVal;
67
 
 
68
 
    for (col = nofCols; col--;)
69
 
        if (!xdr_float(xdrs, zeroValP)) {
70
 
            G_warning
71
 
                ("G_random_f_initialize_0: xdr_float failed for index %d.\n",
72
 
                 col);
73
 
            return 0;
74
 
        }
75
 
 
76
 
    for (row = 0; row < nofRows; row++)
77
 
        if (G__write_data(fd, row, nofCols) == -1) {
78
 
            G_warning("G_random_f_initialize_0: write failed in row %d.\n",
79
 
                      row);
80
 
            return 0;
81
 
        }
82
 
 
83
 
    return 1;
84
 
}
85
 
 
86
 
/*--------------------------------------------------------------------------*/