65 put_raster_row(fd, buf, data_type, 0);
113static void write_data(
int fd,
int row,
unsigned char *buf,
int n)
120 _(
"Error writing uncompressed FP data for row %d of <%s>: %s"), row,
124static void write_data_compressed(
int fd,
int row,
unsigned char *buf,
int n,
132 _(
"Error writing compressed FP data for row %d of <%s>: %s"), row,
136static void set_file_pointer(
int fd,
int row)
141 if (
fcb->row_ptr[row] == -1) {
153 for (i = 0; i < n; i++) {
173 for (i = 0; i < n; i++) {
189static void put_fp_data(
int fd,
char *
null_buf,
const void *
rast,
int row,
194 int size =
fcb->nbytes *
fcb->cellhd.cols;
206 set_file_pointer(fd, row);
214 write_data_compressed(fd, row,
work_buf, n,
fcb->cellhd.compressed);
228 for (i = 0; i < n; i++) {
250 for (k = len - 1; k >= 0; k--) {
263static int count_bytes(
const unsigned char *
wk,
int n,
int len)
267 for (i = 0; i < len - 1; i++)
268 for (
j = 0;
j < n;
j++)
269 if (
wk[
j * len + i] != 0)
275static void trim_bytes(
unsigned char *
wk,
int n,
int slen,
int trim)
277 unsigned char *
wk2 =
wk;
280 for (i = 0; i < n; i++) {
288static int same(
const unsigned char *x,
const unsigned char *y,
int n)
290 return (
memcmp(x, y, n) == 0);
293static int count_run(
const unsigned char *src,
int n,
int nbytes)
295 const unsigned char *cur = src +
nbytes;
298 for (i = 1; i < n; i++) {
299 if (i == 255 || !same(cur, src,
nbytes))
308static int rle_compress(
unsigned char *dst,
unsigned char *src,
int n,
334static void put_data(
int fd,
char *
null_buf,
const CELL *cell,
int row,
int n,
353 set_file_pointer(fd, row);
361 int nbytes = count_bytes(
wk, n, len);
370 trim_bytes(
wk, n, len, len -
nbytes);
374 if (
fcb->cellhd.compressed == 1)
383 if (
fcb->cellhd.compressed == 1)
387 fcb->cellhd.compressed);
398 _(
"Error writing compressed data for row %d of <%s>: %s"),
405 _(
"Error writing compressed data for row %d of <%s>: %s"),
416 _(
"Error writing uncompressed data for row %d of <%s>: %s"),
423static void put_data_gdal(
int fd,
const void *
rast,
int row,
int n,
428 DCELL null_val =
fcb->gdal->null_val;
459 for (i = 0; i < n; i++) {
475 G_fatal_error(
_(
"Error writing data via GDAL for row %d of <%s>"), row,
479static void put_raster_data(
int fd,
char *
null_buf,
const void *
rast,
int row,
492static void put_null_value_row(
int fd,
const char *flags)
498 _(
"GDAL output doesn't support writing null rows separately"));
500 if (
fcb->null_fd < 0)
508static void write_null_bits_compressed(
const unsigned char *flags,
int row,
518 if (
fcb->null_row_ptr[row] == -1) {
533 (
unsigned int)res !=
nwrite)
535 _(
"Error writing compressed null data for row %d of <%s>: %s"),
539 if ((res =
write(
fcb->null_fd, flags, size)) < 0 ||
540 (
unsigned int)res != size)
542 _(
"Error writing compressed null data for row %d of <%s>: %s"),
562 int row =
fcb->null_cur_row++;
569 if (
fcb->null_row_ptr) {
570 write_null_bits_compressed(flags, row, size, fd);
574 offset = (
off_t)size * row;
579 if ((res =
write(
fcb->null_fd, flags, size)) < 0 ||
580 (
unsigned int)res != size)
585static void convert_and_write_if(
int fd,
const void *
vbuf)
592 for (i = 0; i <
fcb->cellhd.cols; i++)
596 p[i] = (
FCELL)buf[i];
601static void convert_and_write_df(
int fd,
const void *
vbuf)
608 for (i = 0; i <
fcb->cellhd.cols; i++)
612 p[i] = (
FCELL)buf[i];
617static void convert_and_write_id(
int fd,
const void *
vbuf)
624 for (i = 0; i <
fcb->cellhd.cols; i++)
628 p[i] = (
DCELL)buf[i];
633static void convert_and_write_fd(
int fd,
const void *
vbuf)
640 for (i = 0; i <
fcb->cellhd.cols; i++)
644 p[i] = (
DCELL)buf[i];
649static void convert_and_write_fi(
int fd,
const void *
vbuf)
656 for (i = 0; i <
fcb->cellhd.cols; i++)
665static void convert_and_write_di(
int fd,
const void *
vbuf)
672 for (i = 0; i <
fcb->cellhd.cols; i++)
694static void put_raster_row(
int fd,
const void *buf,
RASTER_MAP_TYPE data_type,
698 {
NULL, convert_and_write_if, convert_and_write_id},
699 {convert_and_write_fi,
NULL, convert_and_write_fd},
700 {convert_and_write_di, convert_and_write_df,
NULL}};
704 switch (
fcb->open_mode) {
706 G_fatal_error(
_(
"put_raster_row: raster map <%s> not open for write - "
715 _(
"put_raster_row: unopened file descriptor - request ignored"));
719 if (
fcb->map_type != data_type) {
727 put_raster_data(fd,
null_buf, buf,
fcb->cur_row,
fcb->cellhd.cols,
732 if (
fcb->want_histogram)
#define OPEN_NEW_COMPRESSED
#define OPEN_NEW_UNCOMPRESSED
AMI_err name(char **stream_name)
struct compressor_list compressor[]
void G_xdr_put_float(void *, const float *)
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
int G_compress(unsigned char *, int, unsigned char *, int, int)
void G_xdr_put_double(void *, const double *)
int G_write_compressed(int, unsigned char *, int, int)
#define G_incr_void_ptr(ptr, size)
int G_compress_bound(int, int)
int Rast_is_null_value(const void *, RASTER_MAP_TYPE)
To check if a raster value is set to NULL.
void Rast__row_update_range(const CELL *, int, struct Range *, int)
Update range structure based on raster row.
int Rast__null_bitstream_size(int)
Determines null bitstream size.
#define Rast_is_f_null_value(fcellVal)
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
void Rast_set_f_null_value(FCELL *, int)
To set a number of FCELL raster values to NULL.
void Rast__convert_01_flags(const char *, unsigned char *, int)
?
void Rast_set_d_value(void *, DCELL, RASTER_MAP_TYPE)
Places a DCELL raster value.
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
int Rast_update_cell_stats(const CELL *, int, struct Cell_stats *)
Add data to cell stats.
size_t Rast_cell_size(RASTER_MAP_TYPE)
Returns size of a raster cell in bytes.
#define Rast_is_d_null_value(dcellVal)
#define Rast_is_c_null_value(cellVal)
void Rast_row_update_fp_range(const void *, int, struct FPRange *, RASTER_MAP_TYPE)
Update range structure based on raster row (floating-point)
Header file for msvc/fcntl.c.
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.
void Rast_put_d_row(int fd, const DCELL *buf)
Writes the next row for dcell file (DCELL version)
void Rast_put_row(int fd, const void *buf, RASTER_MAP_TYPE data_type)
Writes the next row for cell/fcell/dcell file.
void Rast__write_null_bits(int fd, const unsigned char *flags)
Write null data.
void Rast_put_f_row(int fd, const FCELL *buf)
Writes the next row for fcell file (FCELL version)
void Rast_put_c_row(int fd, const CELL *buf)
Writes the next row for cell file (CELL version)
struct fileinfo * fileinfo
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)