67 put_raster_row(fd, buf, data_type, 0);
115static void write_data(
int fd,
int row,
unsigned char *buf,
int n)
122 _(
"Error writing uncompressed FP data for row %d of <%s>: %s"), row,
126static void write_data_compressed(
int fd,
int row,
unsigned char *buf,
int n,
134 _(
"Error writing compressed FP data for row %d of <%s>: %s"), row,
138static void set_file_pointer(
int fd,
int row)
143 if (
fcb->row_ptr[row] == -1) {
155 for (i = 0; i < n; i++) {
175 for (i = 0; i < n; i++) {
191static void put_fp_data(
int fd,
char *
null_buf,
const void *
rast,
int row,
196 int size =
fcb->nbytes *
fcb->cellhd.cols;
208 set_file_pointer(fd, row);
216 write_data_compressed(fd, row,
work_buf, n,
fcb->cellhd.compressed);
230 for (i = 0; i < n; i++) {
252 for (k = len - 1; k >= 0; k--) {
265static int count_bytes(
const unsigned char *
wk,
int n,
int len)
269 for (i = 0; i < len - 1; i++)
270 for (
j = 0;
j < n;
j++)
271 if (
wk[
j * len + i] != 0)
277static void trim_bytes(
unsigned char *
wk,
int n,
int slen,
int trim)
279 unsigned char *
wk2 =
wk;
282 for (i = 0; i < n; i++) {
290static int same(
const unsigned char *x,
const unsigned char *y,
int n)
292 return (
memcmp(x, y, n) == 0);
295static int count_run(
const unsigned char *src,
int n,
int nbytes)
297 const unsigned char *cur = src +
nbytes;
300 for (i = 1; i < n; i++) {
301 if (i == 255 || !same(cur, src,
nbytes))
310static int rle_compress(
unsigned char *dst,
unsigned char *src,
int n,
336static void put_data(
int fd,
char *
null_buf,
const CELL *cell,
int row,
int n,
355 set_file_pointer(fd, row);
363 int nbytes = count_bytes(
wk, n, len);
372 trim_bytes(
wk, n, len, len -
nbytes);
376 if (
fcb->cellhd.compressed == 1)
385 if (
fcb->cellhd.compressed == 1)
389 fcb->cellhd.compressed);
400 _(
"Error writing compressed data for row %d of <%s>: %s"),
407 _(
"Error writing compressed data for row %d of <%s>: %s"),
418 _(
"Error writing uncompressed data for row %d of <%s>: %s"),
425static void put_data_gdal(
int fd,
const void *
rast,
int row,
int n,
430 DCELL null_val =
fcb->gdal->null_val;
461 for (i = 0; i < n; i++) {
477 G_fatal_error(
_(
"Error writing data via GDAL for row %d of <%s>"), row,
481static void put_raster_data(
int fd,
char *
null_buf,
const void *
rast,
int row,
494static void put_null_value_row(
int fd,
const char *flags)
500 _(
"GDAL output doesn't support writing null rows separately"));
502 if (
fcb->null_fd < 0)
510static void write_null_bits_compressed(
const unsigned char *flags,
int row,
520 if (
fcb->null_row_ptr[row] == -1) {
535 (
unsigned int)res !=
nwrite)
537 _(
"Error writing compressed null data for row %d of <%s>: %s"),
541 if ((res =
write(
fcb->null_fd, flags, size)) < 0 ||
542 (
unsigned int)res != size)
544 _(
"Error writing compressed null data for row %d of <%s>: %s"),
564 int row =
fcb->null_cur_row++;
571 if (
fcb->null_row_ptr) {
572 write_null_bits_compressed(flags, row, size, fd);
576 offset = (
off_t)size * row;
581 if ((res =
write(
fcb->null_fd, flags, size)) < 0 ||
582 (
unsigned int)res != size)
587static void convert_and_write_if(
int fd,
const void *
vbuf)
594 for (i = 0; i <
fcb->cellhd.cols; i++)
598 p[i] = (
FCELL)buf[i];
603static void convert_and_write_df(
int fd,
const void *
vbuf)
610 for (i = 0; i <
fcb->cellhd.cols; i++)
614 p[i] = (
FCELL)buf[i];
619static void convert_and_write_id(
int fd,
const void *
vbuf)
626 for (i = 0; i <
fcb->cellhd.cols; i++)
630 p[i] = (
DCELL)buf[i];
635static void convert_and_write_fd(
int fd,
const void *
vbuf)
642 for (i = 0; i <
fcb->cellhd.cols; i++)
646 p[i] = (
DCELL)buf[i];
651static void convert_and_write_fi(
int fd,
const void *
vbuf)
658 for (i = 0; i <
fcb->cellhd.cols; i++)
667static void convert_and_write_di(
int fd,
const void *
vbuf)
674 for (i = 0; i <
fcb->cellhd.cols; i++)
696static void put_raster_row(
int fd,
const void *buf,
RASTER_MAP_TYPE data_type,
700 {
NULL, convert_and_write_if, convert_and_write_id},
701 {convert_and_write_fi,
NULL, convert_and_write_fd},
702 {convert_and_write_di, convert_and_write_df,
NULL}};
706 switch (
fcb->open_mode) {
708 G_fatal_error(
_(
"put_raster_row: raster map <%s> not open for write - "
717 _(
"put_raster_row: unopened file descriptor - request ignored"));
721 if (
fcb->map_type != data_type) {
729 put_raster_data(fd,
null_buf, buf,
fcb->cur_row,
fcb->cellhd.cols,
734 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)