66 put_raster_row(fd, buf, data_type, 0);
114static void write_data(
int fd,
int row,
unsigned char *buf,
int n)
121 _(
"Error writing uncompressed FP data for row %d of <%s>: %s"), row,
125static void write_data_compressed(
int fd,
int row,
unsigned char *buf,
int n,
133 _(
"Error writing compressed FP data for row %d of <%s>: %s"), row,
137static void set_file_pointer(
int fd,
int row)
142 if (
fcb->row_ptr[row] == -1) {
154 for (i = 0; i < n; i++) {
174 for (i = 0; i < n; i++) {
190static void put_fp_data(
int fd,
char *
null_buf,
const void *
rast,
int row,
195 int size =
fcb->nbytes *
fcb->cellhd.cols;
207 set_file_pointer(fd, row);
215 write_data_compressed(fd, row,
work_buf, n,
fcb->cellhd.compressed);
229 for (i = 0; i < n; i++) {
251 for (k = len - 1; k >= 0; k--) {
264static int count_bytes(
const unsigned char *
wk,
int n,
int len)
268 for (i = 0; i < len - 1; i++)
269 for (
j = 0;
j < n;
j++)
270 if (
wk[
j * len + i] != 0)
276static void trim_bytes(
unsigned char *
wk,
int n,
int slen,
int trim)
278 unsigned char *
wk2 =
wk;
281 for (i = 0; i < n; i++) {
289static int same(
const unsigned char *x,
const unsigned char *y,
int n)
291 return (
memcmp(x, y, n) == 0);
294static int count_run(
const unsigned char *src,
int n,
int nbytes)
296 const unsigned char *cur = src +
nbytes;
299 for (i = 1; i < n; i++) {
300 if (i == 255 || !same(cur, src,
nbytes))
309static int rle_compress(
unsigned char *dst,
unsigned char *src,
int n,
335static void put_data(
int fd,
char *
null_buf,
const CELL *cell,
int row,
int n,
354 set_file_pointer(fd, row);
362 int nbytes = count_bytes(
wk, n, len);
371 trim_bytes(
wk, n, len, len -
nbytes);
375 if (
fcb->cellhd.compressed == 1)
384 if (
fcb->cellhd.compressed == 1)
388 fcb->cellhd.compressed);
399 _(
"Error writing compressed data for row %d of <%s>: %s"),
406 _(
"Error writing compressed data for row %d of <%s>: %s"),
417 _(
"Error writing uncompressed data for row %d of <%s>: %s"),
424static void put_data_gdal(
int fd,
const void *
rast,
int row,
int n,
429 DCELL null_val =
fcb->gdal->null_val;
460 for (i = 0; i < n; i++) {
476 G_fatal_error(
_(
"Error writing data via GDAL for row %d of <%s>"), row,
480static void put_raster_data(
int fd,
char *
null_buf,
const void *
rast,
int row,
493static void put_null_value_row(
int fd,
const char *flags)
499 _(
"GDAL output doesn't support writing null rows separately"));
501 if (
fcb->null_fd < 0)
509static void write_null_bits_compressed(
const unsigned char *flags,
int row,
525 if (
fcb->null_row_ptr[row] == -1) {
543 _(
"Error writing compressed null data for row %d of <%s>: %s"),
547 if ((res =
write(
fcb->null_fd, flags, size)) < 0 || (
size_t)res != size)
549 _(
"Error writing compressed null data for row %d of <%s>: %s"),
569 int row =
fcb->null_cur_row++;
576 if (
fcb->null_row_ptr) {
577 write_null_bits_compressed(flags, row, size, fd);
581 offset = (
off_t)size * row;
586 if ((res =
write(
fcb->null_fd, flags, size)) < 0 || (
size_t)res != size)
591static void convert_and_write_if(
int fd,
const void *
vbuf)
598 for (i = 0; i <
fcb->cellhd.cols; i++)
602 p[i] = (
FCELL)buf[i];
607static void convert_and_write_df(
int fd,
const void *
vbuf)
614 for (i = 0; i <
fcb->cellhd.cols; i++)
618 p[i] = (
FCELL)buf[i];
623static void convert_and_write_id(
int fd,
const void *
vbuf)
630 for (i = 0; i <
fcb->cellhd.cols; i++)
634 p[i] = (
DCELL)buf[i];
639static void convert_and_write_fd(
int fd,
const void *
vbuf)
646 for (i = 0; i <
fcb->cellhd.cols; i++)
650 p[i] = (
DCELL)buf[i];
655static void convert_and_write_fi(
int fd,
const void *
vbuf)
662 for (i = 0; i <
fcb->cellhd.cols; i++)
671static void convert_and_write_di(
int fd,
const void *
vbuf)
678 for (i = 0; i <
fcb->cellhd.cols; i++)
700static void put_raster_row(
int fd,
const void *buf,
RASTER_MAP_TYPE data_type,
704 {
NULL, convert_and_write_if, convert_and_write_id},
705 {convert_and_write_fi,
NULL, convert_and_write_fd},
706 {convert_and_write_di, convert_and_write_df,
NULL}};
710 switch (
fcb->open_mode) {
712 G_fatal_error(
_(
"put_raster_row: raster map <%s> not open for write - "
721 _(
"put_raster_row: unopened file descriptor - request ignored"));
725 if (
fcb->map_type != data_type) {
733 put_raster_data(fd,
null_buf, buf,
fcb->cur_row,
fcb->cellhd.cols,
738 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)