|
@@ -1,7 +1,6 @@
|
|
#include <grass/gis.h>
|
|
#include <grass/gis.h>
|
|
#include <grass/raster.h>
|
|
#include <grass/raster.h>
|
|
#include <grass/vector.h>
|
|
#include <grass/vector.h>
|
|
-#include <grass/glocale.h>
|
|
|
|
#include "local.h"
|
|
#include "local.h"
|
|
|
|
|
|
|
|
|
|
@@ -36,9 +35,10 @@ static int (*dot) (int, int);
|
|
|
|
|
|
int begin_rasterization(int cache_mb, int f, int do_dense)
|
|
int begin_rasterization(int cache_mb, int f, int do_dense)
|
|
{
|
|
{
|
|
- int i, size, nrows;
|
|
|
|
|
|
+ int i;
|
|
double row_mb;
|
|
double row_mb;
|
|
int pages;
|
|
int pages;
|
|
|
|
+ size_t size;
|
|
|
|
|
|
dense = (do_dense != 0);
|
|
dense = (do_dense != 0);
|
|
|
|
|
|
@@ -50,35 +50,23 @@ int begin_rasterization(int cache_mb, int f, int do_dense)
|
|
G_get_set_window(®ion);
|
|
G_get_set_window(®ion);
|
|
G_get_set_window(&page);
|
|
G_get_set_window(&page);
|
|
|
|
|
|
- switch (format) {
|
|
|
|
- case USE_CELL:
|
|
|
|
- row_mb = (double) region.cols * (sizeof(char) + sizeof(CELL)) /
|
|
|
|
- (1 << 20);
|
|
|
|
- break;
|
|
|
|
|
|
+ row_mb = (double) region.cols * (sizeof(char) + Rast_cell_size(f)) /
|
|
|
|
+ (1 << 20);
|
|
|
|
|
|
- case USE_DCELL:
|
|
|
|
- row_mb = (double) region.cols * (sizeof(char) + sizeof(DCELL)) /
|
|
|
|
- (1 << 20);
|
|
|
|
- dot = dcell_dot;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- nrows = cache_mb / row_mb;
|
|
|
|
- if (nrows < 1)
|
|
|
|
- nrows = 1;
|
|
|
|
-
|
|
|
|
- max_rows = nrows;
|
|
|
|
- if (max_rows <= 0)
|
|
|
|
- max_rows = 512;
|
|
|
|
|
|
+ max_rows = cache_mb / row_mb;
|
|
|
|
+ if (max_rows < 1)
|
|
|
|
+ max_rows = 4;
|
|
|
|
|
|
pages = (region.rows + max_rows - 1) / max_rows;
|
|
pages = (region.rows + max_rows - 1) / max_rows;
|
|
|
|
|
|
if (max_rows > region.rows)
|
|
if (max_rows > region.rows)
|
|
max_rows = region.rows;
|
|
max_rows = region.rows;
|
|
|
|
|
|
- size = max_rows * region.cols;
|
|
|
|
|
|
+ G_debug(0, "%d of %d rows are cached", max_rows, region.rows);
|
|
|
|
+
|
|
|
|
+ size = (size_t) max_rows * region.cols;
|
|
switch (format) {
|
|
switch (format) {
|
|
- case USE_CELL:
|
|
|
|
|
|
+ case CELL_TYPE:
|
|
raster.cell =
|
|
raster.cell =
|
|
(CELL **) G_calloc(max_rows * sizeof(char), sizeof(CELL *));
|
|
(CELL **) G_calloc(max_rows * sizeof(char), sizeof(CELL *));
|
|
raster.cell[0] = (CELL *) G_calloc(size * sizeof(char), sizeof(CELL));
|
|
raster.cell[0] = (CELL *) G_calloc(size * sizeof(char), sizeof(CELL));
|
|
@@ -87,7 +75,7 @@ int begin_rasterization(int cache_mb, int f, int do_dense)
|
|
dot = cell_dot;
|
|
dot = cell_dot;
|
|
break;
|
|
break;
|
|
|
|
|
|
- case USE_DCELL:
|
|
|
|
|
|
+ case DCELL_TYPE:
|
|
raster.dcell =
|
|
raster.dcell =
|
|
(DCELL **) G_calloc(max_rows * sizeof(char), sizeof(DCELL *));
|
|
(DCELL **) G_calloc(max_rows * sizeof(char), sizeof(DCELL *));
|
|
raster.dcell[0] =
|
|
raster.dcell[0] =
|
|
@@ -127,12 +115,12 @@ static int configure_plot(void)
|
|
|
|
|
|
/* zero the raster */
|
|
/* zero the raster */
|
|
switch (format) {
|
|
switch (format) {
|
|
- case USE_CELL:
|
|
|
|
|
|
+ case CELL_TYPE:
|
|
for (i = 0; i < nrows; i++)
|
|
for (i = 0; i < nrows; i++)
|
|
for (j = 0; j < ncols; j++)
|
|
for (j = 0; j < ncols; j++)
|
|
raster.cell[i][j] = 0;
|
|
raster.cell[i][j] = 0;
|
|
break;
|
|
break;
|
|
- case USE_DCELL:
|
|
|
|
|
|
+ case DCELL_TYPE:
|
|
for (i = 0; i < nrows; i++)
|
|
for (i = 0; i < nrows; i++)
|
|
for (j = 0; j < ncols; j++)
|
|
for (j = 0; j < ncols; j++)
|
|
raster.dcell[i][j] = 0;
|
|
raster.dcell[i][j] = 0;
|
|
@@ -165,14 +153,14 @@ int output_raster(int fd)
|
|
for (i = 0; i < page.rows; i++, at_row++) {
|
|
for (i = 0; i < page.rows; i++, at_row++) {
|
|
G_percent(i, page.rows, 2);
|
|
G_percent(i, page.rows, 2);
|
|
switch (format) {
|
|
switch (format) {
|
|
- case USE_CELL:
|
|
|
|
|
|
+ case CELL_TYPE:
|
|
cell = raster.cell[i];
|
|
cell = raster.cell[i];
|
|
|
|
|
|
/* insert the NULL values */
|
|
/* insert the NULL values */
|
|
Rast_insert_c_null_values(cell, null_flags[i], page.cols);
|
|
Rast_insert_c_null_values(cell, null_flags[i], page.cols);
|
|
Rast_put_c_row(fd, cell);
|
|
Rast_put_c_row(fd, cell);
|
|
break;
|
|
break;
|
|
- case USE_DCELL:
|
|
|
|
|
|
+ case DCELL_TYPE:
|
|
dcell = raster.dcell[i];
|
|
dcell = raster.dcell[i];
|
|
|
|
|
|
/* insert the NULL values */
|
|
/* insert the NULL values */
|