26static int compute_window_row(
int fd,
int row,
int *
cellRow)
34 G_fatal_error(
_(
"Reading raster map <%s@%s> request for row %d is "
40 f = row *
fcb->C1 +
fcb->C2;
53static void do_reclass_int(
int fd,
void *cell,
int null_is_zero)
69 if (c[i] <
min || c[i] >
max) {
84static void read_data_fp_compressed(
int fd,
int row,
unsigned char *
data_buf,
96 _(
"Error seeking fp raster data file for row %d of <%s>: %s"), row,
102 fcb->cellhd.compressed);
104 G_fatal_error(
_(
"Error uncompressing fp raster data for row %d of "
105 "<%s>: error code %d"),
109static void rle_decompress(
unsigned char *dst,
const unsigned char *src,
115 for (i = 0; i <
pairs; i++) {
128static void read_data_compressed(
int fd,
int row,
unsigned char *
data_buf,
136 unsigned char *cmp, *
cmp2;
141 _(
"Error seeking raster data file for row %d of <%s>: %s"), row,
148 G_fatal_error(
_(
"Error reading raster data for row %d of <%s>: %s"),
156 if (
fcb->cellhd.compressed > 0) {
166 if (
fcb->cellhd.compressed < 0 || (
size_t)
readamount < bufsize) {
167 if (
fcb->cellhd.compressed == 1)
171 fcb->cellhd.compressed)) < 0 ||
172 (
unsigned int)n != bufsize) {
174 _(
"Error uncompressing raster data for row %d of <%s>"),
185static void read_data_uncompressed(
int fd,
int row,
unsigned char *
data_buf,
194 G_fatal_error(
_(
"Error reading raster data for row %d of <%s>"), row,
198 G_fatal_error(
_(
"Error reading raster data for row %d of <%s>"), row,
202static void read_data_gdal(
int fd,
int row,
unsigned char *
data_buf,
211 if (
fcb->gdal->vflip)
212 row =
fcb->cellhd.rows - 1 - row;
219 1, buf,
fcb->cellhd.cols, 1,
fcb->gdal->type, 0, 0);
221 if (
fcb->gdal->hflip) {
224 for (i = 0; i <
fcb->cellhd.cols; i++)
226 buf + (
fcb->cellhd.cols - 1 - i) *
fcb->cur_nbytes,
233 _(
"Error reading raster data via GDAL for row %d of <%s>"), row,
237static void read_data(
int fd,
int row,
unsigned char *
data_buf,
int *
nbytes)
246 if (!
fcb->cellhd.compressed)
264 for (i = 0; i < n; i++) {
265 const unsigned char *d;
282 if (
big && (*d & 0x80)) {
300static void cell_values_float(
int fd,
const unsigned char *
data G_UNUSED,
309 for (i = 0; i < n; i++) {
319static void cell_values_double(
int fd,
const unsigned char *
data G_UNUSED,
324 const double *
work_buf = (
const double *)
fcb->data;
328 for (i = 0; i < n; i++) {
338static void gdal_values_int(
int fd,
const unsigned char *
data,
344 const unsigned char *d;
348 for (i = 0; i < n; i++) {
361 switch (
fcb->gdal->type) {
390static void gdal_values_float(
int fd
G_UNUSED,
const unsigned char *
data,
395 const float *d = (
const float *)
data;
399 for (i = 0; i < n; i++) {
410 c[i] = d[
cmap[i] - 1];
416static void gdal_values_double(
int fd
G_UNUSED,
const unsigned char *
data,
421 const double *d = (
const double *)
data;
425 for (i = 0; i < n; i++) {
436 c[i] = d[
cmap[i] - 1];
451static void transfer_to_cell_XX(
int fd,
void *cell)
455 int) = {cell_values_int, cell_values_float, cell_values_double};
458 int) = {gdal_values_int, gdal_values_float, gdal_values_double};
463 fcb->cur_nbytes, cell,
467 fcb->cur_nbytes, cell,
471static void transfer_to_cell_fi(
int fd,
void *cell)
481 (
fcb->col_map[i] == 0)
488static void transfer_to_cell_di(
int fd,
void *cell)
498 (
fcb->col_map[i] == 0)
505static void transfer_to_cell_if(
int fd,
void *cell)
518static void transfer_to_cell_df(
int fd,
void *cell)
531static void transfer_to_cell_id(
int fd,
void *cell)
544static void transfer_to_cell_fd(
int fd,
void *cell)
561static int get_map_row_nomask(
int fd,
void *
rast,
int row,
565 {transfer_to_cell_XX, transfer_to_cell_if, transfer_to_cell_id},
566 {transfer_to_cell_fi, transfer_to_cell_XX, transfer_to_cell_fd},
567 {transfer_to_cell_di, transfer_to_cell_df, transfer_to_cell_XX}};
586 if (
r !=
fcb->cur_row) {
588 read_data(fd,
fcb->cur_row,
fcb->data, &
fcb->cur_nbytes);
596static void get_map_row_no_reclass(
int fd,
void *
rast,
int row,
600 get_map_row_nomask(fd,
rast, row, data_type);
626 if (!
fcb->reclass_flag)
676 get_map_row(fd, buf, row, data_type, 0, 0);
768 get_map_row(fd, buf, row, data_type, 0, 1);
832static int read_null_bits_compressed(
int null_fd,
unsigned char *flags,
int row,
837 off_t t2 =
fcb->null_row_ptr[row + 1];
844 _(
"Error seeking compressed null data for row %d of <%s>"), row,
849 (
unsigned int)res != size) {
851 _(
"Error reading compressed null data for row %d of <%s>"), row,
863 _(
"Error reading compressed null data for row %d of <%s>"), row,
869 G_fatal_error(
_(
"Error uncompressing null data for row %d of <%s>"),
882 int cols =
fcb->cellhd.cols;
887 if (compute_window_row(fd, row, &R) <= 0) {
897 if (
fcb->null_row_ptr)
898 return read_null_bits_compressed(
null_fd, flags, R, size, fd);
900 offset = (
off_t)size * R;
911#define check_null_bit(flags, bit_num) \
912 ((flags)[(bit_num) >> 3] & ((unsigned char)0x80 >> ((bit_num) & 7)) ? 1 : 0)
914static void get_null_value_row_nomask(
int fd,
char *flags,
int row)
920 G_warning(
_(
"Reading raster map <%s@%s> request for row %d is outside "
934 if (row !=
fcb->null_cur_row) {
936 fcb->null_cur_row = -1;
956 fcb->null_cur_row = row;
961 if (!
fcb->col_map[
j])
970static void get_null_value_row_gdal(
int fd,
char *flags,
int row)
984 flags[i] = !
fcb->col_map[i] ||
tmp_buf[i] ==
fcb->gdal->null_val ||
994static void embed_mask(
char *flags,
int row)
1021static void get_null_value_row(
int fd,
char *flags,
int row,
int with_mask)
1026 get_null_value_row_gdal(fd, flags, row);
1028 get_null_value_row_nomask(fd, flags, row);
1031 embed_mask(flags, row);
1087 if (!
fcb->reclass_flag)
1088 get_null_value_row(fd, flags, row, 1);
AMI_err name(char **stream_name)
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
int G_expand(unsigned char *, int, unsigned char *, int, int)
void G_xdr_get_float(float *, const void *)
int G_lz4_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
int G_read_compressed(int, int, unsigned char *, int, int)
void G_xdr_get_double(double *, const void *)
#define G_incr_void_ptr(ptr, size)
int Rast_is_null_value(const void *, RASTER_MAP_TYPE)
To check if a raster value is set to NULL.
int Rast__null_bitstream_size(int)
Determines null bitstream size.
CELL Rast_quant_get_cell_value(struct Quant *, DCELL)
Returns a CELL category for the floating-point value based on the quantization rules in q....
int Rast_get_vrt_row(int, void *, int, RASTER_MAP_TYPE)
void Rast_zero_input_buf(void *, RASTER_MAP_TYPE)
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
size_t Rast_cell_size(RASTER_MAP_TYPE)
Returns size of a raster cell in bytes.
void Rast_set_c_value(void *, CELL, RASTER_MAP_TYPE)
Places a CELL raster value.
void Rast__set_null_value(void *, int, int, RASTER_MAP_TYPE)
To set one or more raster values to null.
void Rast__init_null_bits(unsigned char *, int)
?
#define Rast_is_c_null_value(cellVal)
DCELL * Rast_allocate_d_input_buf(void)
CPLErr Rast_gdal_raster_IO(GDALRasterBandH band, GDALRWFlag rw_flag, int x_off, int y_off, int x_size, int y_size, void *buffer, int buf_x_size, int buf_y_size, GDALDataType buf_type, int pixel_size, int line_size)
Input/output function for GDAL links.
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
void Rast_get_c_row_nomask(int fd, CELL *buf, int row)
Read raster row without masking (CELL type)
#define check_null_bit(flags, bit_num)
void Rast_get_null_value_row(int fd, char *flags, int row)
Read or simulate null value row.
void Rast_get_f_row_nomask(int fd, FCELL *buf, int row)
Read raster row without masking (FCELL type)
void Rast_get_row_nomask(int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
Read raster row without masking.
void Rast_get_d_row_nomask(int fd, DCELL *buf, int row)
Read raster row without masking (DCELL type)
void Rast_get_d_row(int fd, DCELL *buf, int row)
Get raster row (DCELL type)
void Rast_get_c_row(int fd, CELL *buf, int row)
Get raster row (CELL type)
void Rast_get_f_row(int fd, FCELL *buf, int row)
Get raster row (FCELL type)
void Rast_get_row(int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
Get raster row.
int Rast__read_null_bits(int fd, int row, unsigned char *flags)
struct fileinfo * fileinfo
struct Cell_head rd_window
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)