~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to vector/v.to.rast/raster.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <grass/gis.h>
2
 
#include <grass/Vect.h>
 
2
#include <grass/raster.h>
 
3
#include <grass/vector.h>
3
4
#include "local.h"
4
5
 
5
6
 
17
18
static DCELL dcat;
18
19
static int cur_x, cur_y;
19
20
static int format;
 
21
static int dense;
20
22
static CELL *cell;
21
23
static DCELL *dcell;
22
24
static char **null_flags;
31
33
static int (*dot) (int, int);
32
34
 
33
35
 
34
 
int begin_rasterization(int nrows, int f)
 
36
int begin_rasterization(int cache_mb, int f, int do_dense)
35
37
{
36
 
    int i, size;
 
38
    int i;
 
39
    double row_mb;
37
40
    int pages;
 
41
    size_t size;
 
42
 
 
43
    dense = (do_dense != 0);
38
44
 
39
45
    /* otherwise get complaints about window changes */
40
46
    G_suppress_warnings(1);
41
47
 
42
48
    format = f;
43
49
 
44
 
    max_rows = nrows;
45
 
    if (max_rows <= 0)
46
 
        max_rows = 512;
47
 
 
48
50
    G_get_set_window(&region);
49
51
    G_get_set_window(&page);
50
52
 
 
53
    row_mb = (double) region.cols * (sizeof(char) + Rast_cell_size(f)) /
 
54
             (1 << 20);
 
55
 
 
56
    max_rows = cache_mb / row_mb;
 
57
    if (max_rows < 1)
 
58
        max_rows = 4;
 
59
 
51
60
    pages = (region.rows + max_rows - 1) / max_rows;
52
61
 
53
62
    if (max_rows > region.rows)
54
63
        max_rows = region.rows;
55
64
 
56
 
    size = max_rows * region.cols;
 
65
    G_debug(1, "%d of %d rows are cached", max_rows, region.rows);
 
66
 
 
67
    size = (size_t) max_rows * region.cols;
57
68
    switch (format) {
58
 
    case USE_CELL:
 
69
    case CELL_TYPE:
59
70
        raster.cell =
60
71
            (CELL **) G_calloc(max_rows * sizeof(char), sizeof(CELL *));
61
72
        raster.cell[0] = (CELL *) G_calloc(size * sizeof(char), sizeof(CELL));
64
75
        dot = cell_dot;
65
76
        break;
66
77
 
67
 
    case USE_DCELL:
 
78
    case DCELL_TYPE:
68
79
        raster.dcell =
69
80
            (DCELL **) G_calloc(max_rows * sizeof(char), sizeof(DCELL *));
70
81
        raster.dcell[0] =
104
115
 
105
116
    /* zero the raster */
106
117
    switch (format) {
107
 
    case USE_CELL:
 
118
    case CELL_TYPE:
108
119
        for (i = 0; i < nrows; i++)
109
120
            for (j = 0; j < ncols; j++)
110
121
                raster.cell[i][j] = 0;
111
122
        break;
112
 
    case USE_DCELL:
 
123
    case DCELL_TYPE:
113
124
        for (i = 0; i < nrows; i++)
114
125
            for (j = 0; j < ncols; j++)
115
126
                raster.dcell[i][j] = 0;
126
137
    G_set_window(&page);
127
138
 
128
139
    /* configure the plot routines */
129
 
    G_setup_plot(-0.5, page.rows - 0.5, -0.5, page.cols - 0.5, move, cont);
 
140
    if (dense)
 
141
        setup_plot(0, page.rows, 0, page.cols, dot);
 
142
    else
 
143
        G_setup_plot(-0.5, page.rows - 0.5, -0.5, page.cols - 0.5, move, cont);
130
144
 
131
145
    return 0;
132
146
}
139
153
    for (i = 0; i < page.rows; i++, at_row++) {
140
154
        G_percent(i, page.rows, 2);
141
155
        switch (format) {
142
 
        case USE_CELL:
 
156
        case CELL_TYPE:
143
157
            cell = raster.cell[i];
144
158
 
145
159
            /* insert the NULL values */
146
 
            G_insert_c_null_values(cell, null_flags[i], page.cols);
147
 
            if (G_put_c_raster_row(fd, cell) < 0)
148
 
                return -1;
 
160
            Rast_insert_c_null_values(cell, null_flags[i], page.cols);
 
161
            Rast_put_c_row(fd, cell);
149
162
            break;
150
 
        case USE_DCELL:
 
163
        case DCELL_TYPE:
151
164
            dcell = raster.dcell[i];
152
165
 
153
166
            /* insert the NULL values */
154
 
            G_insert_d_null_values(dcell, null_flags[i], page.cols);
155
 
            if (G_put_d_raster_row(fd, dcell) < 0)
156
 
                return -1;
 
167
            Rast_insert_d_null_values(dcell, null_flags[i], page.cols);
 
168
            Rast_put_d_row(fd, dcell);
157
169
            break;
158
170
        }
159
171
    }