|
@@ -22,7 +22,6 @@
|
|
|
#include <grass/raster.h>
|
|
|
#include <grass/glocale.h>
|
|
|
|
|
|
-#include "../gis/G.h"
|
|
|
#include "R.h"
|
|
|
|
|
|
static void embed_nulls(int, void *, int, RASTER_MAP_TYPE, int, int);
|
|
@@ -34,7 +33,7 @@ static int compute_window_row(int fd, int row, int *cellRow)
|
|
|
int r;
|
|
|
|
|
|
/* check for row in window */
|
|
|
- if (row < 0 || row >= G__.window.rows) {
|
|
|
+ if (row < 0 || row >= R__.rd_window.rows) {
|
|
|
G_fatal_error(_("Reading raster map <%s@%s> request for row %d is outside region"),
|
|
|
fcb->name, fcb->mapset, row);
|
|
|
}
|
|
@@ -62,7 +61,7 @@ static void do_reclass_int(int fd, void *cell, int null_is_zero)
|
|
|
CELL max = fcb->reclass.max;
|
|
|
int i;
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++) {
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++) {
|
|
|
if (Rast_is_c_null_value(&c[i])) {
|
|
|
if (null_is_zero)
|
|
|
c[i] = 0;
|
|
@@ -478,23 +477,23 @@ static void transfer_to_cell_XX(int fd, void *cell)
|
|
|
if (fcb->gdal)
|
|
|
(gdal_values_type[fcb->map_type]) (fd, fcb->data, fcb->col_map,
|
|
|
fcb->cur_nbytes, cell,
|
|
|
- G__.window.cols);
|
|
|
+ R__.rd_window.cols);
|
|
|
else
|
|
|
#endif
|
|
|
(cell_values_type[fcb->map_type]) (fd, fcb->data, fcb->col_map,
|
|
|
fcb->cur_nbytes, cell,
|
|
|
- G__.window.cols);
|
|
|
+ R__.rd_window.cols);
|
|
|
}
|
|
|
|
|
|
static void transfer_to_cell_fi(int fd, void *cell)
|
|
|
{
|
|
|
struct fileinfo *fcb = &R__.fileinfo[fd];
|
|
|
- FCELL *work_buf = G__alloca(G__.window.cols * sizeof(FCELL));
|
|
|
+ FCELL *work_buf = G__alloca(R__.rd_window.cols * sizeof(FCELL));
|
|
|
int i;
|
|
|
|
|
|
transfer_to_cell_XX(fd, work_buf);
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++)
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++)
|
|
|
((CELL *) cell)[i] = (fcb->col_map[i] == 0)
|
|
|
? 0 : Rast_quant_get_cell_value(&fcb->quant, work_buf[i]);
|
|
|
|
|
@@ -504,12 +503,12 @@ static void transfer_to_cell_fi(int fd, void *cell)
|
|
|
static void transfer_to_cell_di(int fd, void *cell)
|
|
|
{
|
|
|
struct fileinfo *fcb = &R__.fileinfo[fd];
|
|
|
- DCELL *work_buf = G__alloca(G__.window.cols * sizeof(DCELL));
|
|
|
+ DCELL *work_buf = G__alloca(R__.rd_window.cols * sizeof(DCELL));
|
|
|
int i;
|
|
|
|
|
|
transfer_to_cell_XX(fd, work_buf);
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++)
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++)
|
|
|
((CELL *) cell)[i] = (fcb->col_map[i] == 0)
|
|
|
? 0 : Rast_quant_get_cell_value(&fcb->quant, work_buf[i]);
|
|
|
|
|
@@ -518,12 +517,12 @@ static void transfer_to_cell_di(int fd, void *cell)
|
|
|
|
|
|
static void transfer_to_cell_if(int fd, void *cell)
|
|
|
{
|
|
|
- CELL *work_buf = G__alloca(G__.window.cols * sizeof(CELL));
|
|
|
+ CELL *work_buf = G__alloca(R__.rd_window.cols * sizeof(CELL));
|
|
|
int i;
|
|
|
|
|
|
transfer_to_cell_XX(fd, work_buf);
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++)
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++)
|
|
|
((FCELL *) cell)[i] = work_buf[i];
|
|
|
|
|
|
G__freea(work_buf);
|
|
@@ -531,12 +530,12 @@ static void transfer_to_cell_if(int fd, void *cell)
|
|
|
|
|
|
static void transfer_to_cell_df(int fd, void *cell)
|
|
|
{
|
|
|
- DCELL *work_buf = G__alloca(G__.window.cols * sizeof(DCELL));
|
|
|
+ DCELL *work_buf = G__alloca(R__.rd_window.cols * sizeof(DCELL));
|
|
|
int i;
|
|
|
|
|
|
transfer_to_cell_XX(fd, work_buf);
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++)
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++)
|
|
|
((FCELL *) cell)[i] = work_buf[i];
|
|
|
|
|
|
G__freea(work_buf);
|
|
@@ -544,12 +543,12 @@ static void transfer_to_cell_df(int fd, void *cell)
|
|
|
|
|
|
static void transfer_to_cell_id(int fd, void *cell)
|
|
|
{
|
|
|
- CELL *work_buf = G__alloca(G__.window.cols * sizeof(CELL));
|
|
|
+ CELL *work_buf = G__alloca(R__.rd_window.cols * sizeof(CELL));
|
|
|
int i;
|
|
|
|
|
|
transfer_to_cell_XX(fd, work_buf);
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++)
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++)
|
|
|
((DCELL *) cell)[i] = work_buf[i];
|
|
|
|
|
|
G__freea(work_buf);
|
|
@@ -557,12 +556,12 @@ static void transfer_to_cell_id(int fd, void *cell)
|
|
|
|
|
|
static void transfer_to_cell_fd(int fd, void *cell)
|
|
|
{
|
|
|
- FCELL *work_buf = G__alloca(G__.window.cols * sizeof(FCELL));
|
|
|
+ FCELL *work_buf = G__alloca(R__.rd_window.cols * sizeof(FCELL));
|
|
|
int i;
|
|
|
|
|
|
transfer_to_cell_XX(fd, work_buf);
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++)
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++)
|
|
|
((DCELL *) cell)[i] = work_buf[i];
|
|
|
|
|
|
G__freea(work_buf);
|
|
@@ -623,7 +622,7 @@ static void get_map_row(int fd, void *rast, int row, RASTER_MAP_TYPE data_type,
|
|
|
int i;
|
|
|
|
|
|
if (fcb->reclass_flag && data_type != CELL_TYPE) {
|
|
|
- temp_buf = G__alloca(G__.window.cols * sizeof(CELL));
|
|
|
+ temp_buf = G__alloca(R__.rd_window.cols * sizeof(CELL));
|
|
|
buf = temp_buf;
|
|
|
type = CELL_TYPE;
|
|
|
}
|
|
@@ -645,7 +644,7 @@ static void get_map_row(int fd, void *rast, int row, RASTER_MAP_TYPE data_type,
|
|
|
if (data_type == CELL_TYPE)
|
|
|
return;
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++) {
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++) {
|
|
|
Rast_set_c_value(rast, temp_buf[i], data_type);
|
|
|
rast = G_incr_void_ptr(rast, size);
|
|
|
}
|
|
@@ -879,10 +878,10 @@ static void get_null_value_row_nomask(int fd, char *flags, int row)
|
|
|
struct fileinfo *fcb = &R__.fileinfo[fd];
|
|
|
int j;
|
|
|
|
|
|
- if (row > G__.window.rows || row < 0) {
|
|
|
+ if (row > R__.rd_window.rows || row < 0) {
|
|
|
G_warning(_("Reading raster map <%s@%s> request for row %d is outside region"),
|
|
|
fcb->name, fcb->mapset, row);
|
|
|
- for (j = 0; j < G__.window.cols; j++)
|
|
|
+ for (j = 0; j < R__.rd_window.cols; j++)
|
|
|
flags[j] = 1;
|
|
|
return;
|
|
|
}
|
|
@@ -892,17 +891,17 @@ static void get_null_value_row_nomask(int fd, char *flags, int row)
|
|
|
fcb->null_cur_row = -1;
|
|
|
if (fcb->map_type == CELL_TYPE) {
|
|
|
/* If can't read null row, assume that all map 0's are nulls */
|
|
|
- CELL *mask_buf = G__alloca(G__.window.cols * sizeof(CELL));
|
|
|
+ CELL *mask_buf = G__alloca(R__.rd_window.cols * sizeof(CELL));
|
|
|
|
|
|
get_map_row_nomask(fd, mask_buf, row, CELL_TYPE);
|
|
|
- for (j = 0; j < G__.window.cols; j++)
|
|
|
+ for (j = 0; j < R__.rd_window.cols; j++)
|
|
|
flags[j] = (mask_buf[j] == 0);
|
|
|
|
|
|
G__freea(mask_buf);
|
|
|
}
|
|
|
else { /* fp map */
|
|
|
/* if can't read null row, assume that all data is valid */
|
|
|
- G_zero(flags, sizeof(char) * G__.window.cols);
|
|
|
+ G_zero(flags, sizeof(char) * R__.rd_window.cols);
|
|
|
/* the flags row is ready now */
|
|
|
}
|
|
|
|
|
@@ -913,7 +912,7 @@ static void get_null_value_row_nomask(int fd, char *flags, int row)
|
|
|
}
|
|
|
|
|
|
/* copy null row to flags row translated by window column mapping */
|
|
|
- for (j = 0; j < G__.window.cols; j++) {
|
|
|
+ for (j = 0; j < R__.rd_window.cols; j++) {
|
|
|
if (!fcb->col_map[j])
|
|
|
flags[j] = 1;
|
|
|
else
|
|
@@ -932,12 +931,12 @@ static void get_null_value_row_gdal(int fd, char *flags, int row)
|
|
|
int i;
|
|
|
|
|
|
if (get_map_row_nomask(fd, tmp_buf, row, DCELL_TYPE) <= 0) {
|
|
|
- memset(flags, 1, G__.window.cols);
|
|
|
+ memset(flags, 1, R__.rd_window.cols);
|
|
|
G_free(tmp_buf);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++)
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++)
|
|
|
/* note: using == won't work if the null value is NaN */
|
|
|
flags[i] = !fcb->col_map[i] ||
|
|
|
memcmp(&tmp_buf[i], &fcb->gdal->null_val, sizeof(DCELL)) == 0;
|
|
@@ -953,7 +952,7 @@ static void get_null_value_row_gdal(int fd, char *flags, int row)
|
|
|
|
|
|
static void embed_mask(char *flags, int row)
|
|
|
{
|
|
|
- CELL *mask_buf = G__alloca(G__.window.cols * sizeof(CELL));
|
|
|
+ CELL *mask_buf = G__alloca(R__.rd_window.cols * sizeof(CELL));
|
|
|
int i;
|
|
|
|
|
|
if (R__.auto_mask <= 0)
|
|
@@ -967,7 +966,7 @@ static void embed_mask(char *flags, int row)
|
|
|
if (R__.fileinfo[R__.mask_fd].reclass_flag)
|
|
|
do_reclass_int(R__.mask_fd, mask_buf, 1);
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++)
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++)
|
|
|
if (mask_buf[i] == 0)
|
|
|
flags[i] = 1;
|
|
|
|
|
@@ -1003,11 +1002,11 @@ static void embed_nulls(int fd, void *buf, int row, RASTER_MAP_TYPE map_type,
|
|
|
&& (R__.auto_mask <= 0 || !with_mask))
|
|
|
return;
|
|
|
|
|
|
- null_buf = G__alloca(G__.window.cols);
|
|
|
+ null_buf = G__alloca(R__.rd_window.cols);
|
|
|
|
|
|
get_null_value_row(fd, null_buf, row, with_mask);
|
|
|
|
|
|
- for (i = 0; i < G__.window.cols; i++) {
|
|
|
+ for (i = 0; i < R__.rd_window.cols; i++) {
|
|
|
/* also check for nulls which might be already embedded by quant
|
|
|
rules in case of fp map. */
|
|
|
if (null_buf[i] || Rast_is_null_value(buf, map_type)) {
|