GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
raster/put_row.c
Go to the documentation of this file.
1 /*!
2  \file lib/raster/put_row.c
3 
4  \brief Raster library - Put raster row
5 
6  (C) 2003-2009 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Original author CERL
12  */
13 
14 /**********************************************************************
15 
16  **********************************************************************/
17 
18 #include <string.h>
19 
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <unistd.h>
23 #include <fcntl.h>
24 #include <errno.h>
25 
26 #include <grass/config.h>
27 #include <grass/raster.h>
28 #include <grass/glocale.h>
29 
30 #include "R.h"
31 
32 static void put_raster_row(int, const void *, RASTER_MAP_TYPE, int);
33 
34 /*!
35  \brief Writes the next row for cell/fcell/dcell file
36 
37  Writes the next row for the cell file opened on 'fd' from 'buf' All
38  writes go into NEW files that exactly match the current window. The
39  file must have been opened with Rast_open_new() and be written
40  sequentially, ie no skipping rows.
41 
42  When the null values are embedded into the data, corresponding cells
43  are changed to 0's and the corresponding null value row is written
44  into null file.
45 
46  A map cannot be copied using Rast_get_row() and
47  Rast_put_row(). The former resamples the data of the original
48  map into a row buffer that matches the current window. The later
49  writes out rows associated with the window.
50 
51  Keeps track of the minimum and maximum cell value for use in
52  updating the range file upon close of the cell file. HOWEVER when
53  nulls are not embedded, the cells are considered 0's as far as
54  updating range is concerned, even if the corresponding cell is null
55  in the resulting null file, so programmer should be carefult to set
56  all the null values using Rast_set_null_value() or
57  G_insert_d_null_values() or G_insert_f_null_values().
58 
59  \param fd file descriptor where data is to be written
60  \param buf buffer holding data
61  \param data_type raster map type (CELL_TYPE, FCELL_TYPE, DCELL_TYPE)
62 
63  \return void
64  */
65 void Rast_put_row(int fd, const void *buf, RASTER_MAP_TYPE data_type)
66 {
67  put_raster_row(fd, buf, data_type, 0);
68 }
69 
70 /*!
71  \brief Writes the next row for cell file (CELL version)
72 
73  See Rast_put_row() for details.
74 
75  \param fd file descriptor where data is to be written
76  \param buf buffer holding data
77 
78  \return void
79  */
80 void Rast_put_c_row(int fd, const CELL * buf)
81 {
82  Rast_put_row(fd, buf, CELL_TYPE);
83 }
84 
85 /*!
86  \brief Writes the next row for fcell file (FCELL version)
87 
88  See Rast_put_row() for details.
89 
90  \param fd file descriptor where data is to be written
91  \param buf buffer holding data
92 
93  \return void
94  */
95 void Rast_put_f_row(int fd, const FCELL * buf)
96 {
97  Rast_put_row(fd, buf, FCELL_TYPE);
98 }
99 
100 /*!
101  \brief Writes the next row for dcell file (DCELL version)
102 
103  See Rast_put_row() for details.
104 
105  \param fd file descriptor where data is to be written
106  \param buf buffer holding data
107 
108  \return void
109  */
110 void Rast_put_d_row(int fd, const DCELL * buf)
111 {
112  Rast_put_row(fd, buf, DCELL_TYPE);
113 }
114 
115 static void write_data(int fd, int row, unsigned char *buf, int n)
116 {
117  struct fileinfo *fcb = &R__.fileinfo[fd];
118  ssize_t nwrite = fcb->nbytes * n;
119 
120  if (write(fcb->data_fd, buf, nwrite) != nwrite)
121  G_fatal_error(_("Error writing uncompressed FP data for row %d of <%s>: %s"),
122  row, fcb->name, strerror(errno));
123 }
124 
125 static void write_data_compressed(int fd, int row, unsigned char *buf, int n, int compressor)
126 {
127  struct fileinfo *fcb = &R__.fileinfo[fd];
128  int nwrite = fcb->nbytes * n;
129 
130  if (G_write_compressed(fcb->data_fd, buf, nwrite, compressor) < 0)
131  G_fatal_error(_("Error writing compressed FP data for row %d of <%s>: %s"),
132  row, fcb->name, strerror(errno));
133 }
134 
135 static void set_file_pointer(int fd, int row)
136 {
137  struct fileinfo *fcb = &R__.fileinfo[fd];
138 
139  fcb->row_ptr[row] = lseek(fcb->data_fd, 0L, SEEK_CUR);
140 }
141 
142 static void convert_float(float *work_buf, int size, char *null_buf,
143  const FCELL *rast, int row, int n)
144 {
145  int i;
146 
147  for (i = 0; i < n; i++) {
148  FCELL f;
149 
150  /* substitute embedded null vals by 0's */
151  if (Rast_is_f_null_value(&rast[i])) {
152  f = 0.;
153  null_buf[i] = 1;
154  }
155  else
156  f = rast[i];
157 
158  G_xdr_put_float(&work_buf[i], &f);
159  }
160 }
161 
162 static void convert_double(double *work_buf, int size, char *null_buf,
163  const DCELL *rast, int row, int n)
164 {
165  int i;
166 
167  for (i = 0; i < n; i++) {
168  DCELL d;
169 
170  /* substitute embedded null vals by 0's */
171  if (Rast_is_d_null_value(&rast[i])) {
172  d = 0.;
173  null_buf[i] = 1;
174  }
175  else
176  d = rast[i];
177 
178  G_xdr_put_double(&work_buf[i], &d);
179  }
180 }
181 
182 /* writes data to fcell file for either full or partial rows */
183 static void put_fp_data(int fd, char *null_buf, const void *rast,
184  int row, int n, RASTER_MAP_TYPE data_type)
185 {
186  struct fileinfo *fcb = &R__.fileinfo[fd];
187  int compressed = (fcb->open_mode == OPEN_NEW_COMPRESSED);
188  int size = fcb->nbytes * fcb->cellhd.cols;
189  void *work_buf;
190 
191  if (row < 0 || row >= fcb->cellhd.rows)
192  return;
193 
194  if (n <= 0)
195  return;
196 
197  work_buf = G_malloc(size + 1);
198 
199  if (compressed)
200  set_file_pointer(fd, row);
201 
202  if (data_type == FCELL_TYPE)
203  convert_float(work_buf, size, null_buf, rast, row, n);
204  else
205  convert_double(work_buf, size, null_buf, rast, row, n);
206 
207  if (compressed)
208  write_data_compressed(fd, row, work_buf, n, fcb->cellhd.compressed);
209  else
210  write_data(fd, row, work_buf, n);
211 
212  G_free(work_buf);
213 }
214 
215 static void convert_int(unsigned char *wk, char *null_buf, const CELL * rast,
216  int n, int len, int zeros_r_nulls)
217 {
218  int i;
219 
220  /* transform CELL data into non-machine dependent multi-byte format */
221 
222  for (i = 0; i < n; i++) {
223  CELL v = rast[i];
224  int neg;
225  int k;
226 
227  /* substitute embedded null vals by 0's */
228  if (Rast_is_c_null_value(&v)) {
229  v = 0;
230  null_buf[i] = 1;
231  }
232  else if (zeros_r_nulls && !v)
233  null_buf[i] = 1;
234 
235  /* negatives */
236  if (v < 0) {
237  neg = 1;
238  v = -v;
239  }
240  else
241  neg = 0;
242 
243  /* copy byte by byte */
244  for (k = len - 1; k >= 0; k--) {
245  wk[k] = v & 0xff;
246  v >>= 8;
247  }
248 
249  /* set negative bit in first byte */
250  if (neg)
251  wk[0] |= 0x80;
252 
253  wk += len;
254  }
255 }
256 
257 static int count_bytes(const unsigned char *wk, int n, int len)
258 {
259  int i, j;
260 
261  for (i = 0; i < len - 1; i++)
262  for (j = 0; j < n; j++)
263  if (wk[j * len + i] != 0)
264  return len - i;
265 
266  return 1;
267 }
268 
269 static void trim_bytes(unsigned char *wk, int n, int slen, int trim)
270 {
271  unsigned char *wk2 = wk;
272  int i, j;
273 
274  for (i = 0; i < n; i++) {
275  for (j = 0; j < trim; j++)
276  wk++;
277  for (; j < slen; j++)
278  *wk2++ = *wk++;
279  }
280 }
281 
282 static int same(const unsigned char *x, const unsigned char *y, int n)
283 {
284  return (memcmp(x, y, n) == 0);
285 }
286 
287 static int count_run(const unsigned char *src, int n, int nbytes)
288 {
289  const unsigned char *cur = src + nbytes;
290  int i;
291 
292  for (i = 1; i < n; i++) {
293  if (i == 255 || !same(cur, src, nbytes))
294  return i;
295 
296  cur += nbytes;
297  }
298 
299  return n;
300 }
301 
302 static int rle_compress(unsigned char *dst, unsigned char *src, int n,
303  int nbytes)
304 {
305  int nwrite = 0;
306  int total = nbytes * n;
307 
308  while (n > 0) {
309  int count;
310 
311  nwrite += nbytes + 1;
312  if (nwrite >= total)
313  return 0;
314 
315  count = count_run(src, n, nbytes);
316 
317  *dst++ = count;
318  memcpy(dst, src, nbytes);
319  dst += nbytes;
320 
321  src += count * nbytes;
322  n -= count;
323  }
324 
325  return (nwrite >= total) ? 0 : nwrite;
326 }
327 
328 static void put_data(int fd, char *null_buf, const CELL * cell,
329  int row, int n, int zeros_r_nulls)
330 {
331  struct fileinfo *fcb = &R__.fileinfo[fd];
332  int compressed = (fcb->open_mode == OPEN_NEW_COMPRESSED);
333  int len = compressed ? sizeof(CELL) : fcb->nbytes;
334  unsigned char *work_buf, *wk;
335  ssize_t nwrite;
336 
337  if (row < 0 || row >= fcb->cellhd.rows)
338  return;
339 
340  if (n <= 0)
341  return;
342 
343  work_buf = G_malloc(fcb->cellhd.cols * sizeof(CELL) + 1);
344  wk = work_buf;
345 
346  if (compressed)
347  set_file_pointer(fd, row);
348 
349  if (compressed)
350  wk++;
351 
352  convert_int(wk, null_buf, cell, n, len, zeros_r_nulls);
353 
354  if (compressed) {
355  int nbytes = count_bytes(wk, n, len);
356  unsigned char *compressed_buf;
357  int total, cmax;
358 
359  if (fcb->nbytes < nbytes)
360  fcb->nbytes = nbytes;
361 
362  /* first trim away zero high bytes */
363  if (nbytes < len)
364  trim_bytes(wk, n, len, len - nbytes);
365 
366  total = nbytes * n;
367  /* get upper bound of compressed size */
368  if (fcb->cellhd.compressed == 1)
369  cmax = total;
370  else
371  cmax = G_compress_bound(total, fcb->cellhd.compressed);
372  compressed_buf = G_malloc(cmax + 1);
373 
374  compressed_buf[0] = work_buf[0] = nbytes;
375 
376  /* then compress the data */
377  if (fcb->cellhd.compressed == 1)
378  nwrite = rle_compress(compressed_buf + 1, work_buf + 1, n, nbytes);
379  else {
380  nwrite = G_compress(work_buf + 1, total, compressed_buf + 1, cmax,
381  fcb->cellhd.compressed);
382  }
383 
384  if (nwrite >= total)
385  nwrite = 0;
386 
387  if (nwrite > 0) {
388  nwrite++;
389 
390  if (write(fcb->data_fd, compressed_buf, nwrite) != nwrite)
391  G_fatal_error(_("Error writing compressed data for row %d of <%s>"),
392  row, fcb->name);
393  }
394  else {
395  nwrite = nbytes * n + 1;
396  if (write(fcb->data_fd, work_buf, nwrite) != nwrite)
397  G_fatal_error(_("Error writing compressed data for row %d of <%s>"),
398  row, fcb->name);
399  }
400 
401  G_free(compressed_buf);
402  }
403  else {
404  nwrite = fcb->nbytes * n;
405 
406  if (write(fcb->data_fd, work_buf, nwrite) != nwrite)
407  G_fatal_error(_("Error writing uncompressed data for row %d of <%s>"),
408  row, fcb->name);
409  }
410 
411  G_free(work_buf);
412 }
413 
414 static void put_data_gdal(int fd, const void *rast, int row, int n,
415  int zeros_r_nulls, RASTER_MAP_TYPE map_type)
416 {
417 #ifdef HAVE_GDAL
418  struct fileinfo *fcb = &R__.fileinfo[fd];
419  int size = Rast_cell_size(map_type);
420  DCELL null_val = fcb->gdal->null_val;
421  const void *src;
422  void *work_buf, *dst;
423  GDALDataType datatype;
424  CPLErr err;
425  int i;
426 
427  if (row < 0 || row >= fcb->cellhd.rows)
428  return;
429 
430  if (n <= 0)
431  return;
432 
433  work_buf = G_malloc(n * size);
434 
435  datatype = GDT_Unknown;
436  switch (map_type) {
437  case CELL_TYPE:
438  datatype = GDT_Int32;
439  break;
440  case FCELL_TYPE:
441  datatype = GDT_Float32;
442  break;
443  case DCELL_TYPE:
444  datatype = GDT_Float64;
445  break;
446  }
447 
448  src = rast;
449  dst = work_buf;
450 
451  for (i = 0; i < n; i++) {
452  if (Rast_is_null_value(src, map_type) ||
453  (zeros_r_nulls && !*(CELL *) src))
454  Rast_set_d_value(dst, null_val, map_type);
455  else
456  memcpy(dst, src, size);
457  src = G_incr_void_ptr(src, size);
458  dst = G_incr_void_ptr(dst, size);
459  }
460 
461  err = Rast_gdal_raster_IO(fcb->gdal->band, GF_Write, 0, row, n, 1,
462  work_buf, n, 1, datatype, 0, 0);
463 
464  G_free(work_buf);
465 
466  if (err != CE_None)
467  G_fatal_error(_("Error writing data via GDAL for row %d of <%s>"),
468  row, fcb->name);
469 #endif
470 }
471 
472 static void put_raster_data(int fd, char *null_buf, const void *rast,
473  int row, int n,
474  int zeros_r_nulls, RASTER_MAP_TYPE map_type)
475 {
476  struct fileinfo *fcb = &R__.fileinfo[fd];
477 
478  if (fcb->gdal)
479  put_data_gdal(fd, rast, row, n, zeros_r_nulls, map_type);
480  else if (map_type == CELL_TYPE)
481  put_data(fd, null_buf, rast, row, n, zeros_r_nulls);
482  else
483  put_fp_data(fd, null_buf, rast, row, n, map_type);
484 }
485 
486 static void put_null_value_row(int fd, const char *flags)
487 {
488  struct fileinfo *fcb = &R__.fileinfo[fd];
489 
490  if (fcb->gdal)
491  G_fatal_error(_("GDAL output doesn't support writing null rows separately"));
492 
493  if (fcb->null_fd < 0)
494  G_fatal_error(_("No null file for <%s>"), fcb->name);
495 
496  Rast__convert_01_flags(flags, fcb->null_bits,
497  fcb->cellhd.cols);
498 
500 }
501 
502 static void write_null_bits_compressed(const unsigned char *flags,
503  int row, size_t size, int fd)
504 {
505  struct fileinfo *fcb = &R__.fileinfo[fd];
506  unsigned char *compressed_buf;
507  ssize_t nwrite;
508  size_t cmax;
509 
510  fcb->null_row_ptr[row] = lseek(fcb->null_fd, 0L, SEEK_CUR);
511 
512  /* get upper bound of compressed size */
513  cmax = G_compress_bound(size, 3);
514  compressed_buf = G_malloc(cmax);
515 
516  /* compress null bits file with LZ4, see lib/gis/compress.h */
517  nwrite = G_compress((unsigned char *)flags, size, compressed_buf, cmax, 3);
518 
519  if (nwrite > 0 && nwrite < size) {
520  if (write(fcb->null_fd, compressed_buf, nwrite) != nwrite)
521  G_fatal_error(_("Error writing compressed null data for row %d of <%s>"),
522  row, fcb->name);
523  }
524  else {
525  if (write(fcb->null_fd, flags, size) != size)
526  G_fatal_error(_("Error writing compressed null data for row %d of <%s>"),
527  row, fcb->name);
528  }
529 
530  G_free(compressed_buf);
531 }
532 
533 /*!
534  \brief Write null data
535 
536  \param flags ?
537  \param row row number
538  \param col col number
539  \param fd file descriptor of cell data file
540 
541  \return void
542  */
543 void Rast__write_null_bits(int fd, const unsigned char *flags)
544 {
545  struct fileinfo *fcb = &R__.fileinfo[fd];
546  int row = fcb->null_cur_row++;
547  off_t offset;
548  size_t size;
549 
551 
552  if (fcb->null_row_ptr) {
553  write_null_bits_compressed(flags, row, size, fd);
554  return;
555  }
556 
557  offset = (off_t) size * row;
558 
559  if (lseek(fcb->null_fd, offset, SEEK_SET) < 0)
560  G_fatal_error(_("Error writing null row %d of <%s>"), row, fcb->name);
561 
562  if (write(fcb->null_fd, flags, size) != size)
563  G_fatal_error(_("Error writing null row %d of <%s>"), row, fcb->name);
564 }
565 
566 static void convert_and_write_if(int fd, const void *vbuf)
567 {
568  const CELL *buf = vbuf;
569  struct fileinfo *fcb = &R__.fileinfo[fd];
570  FCELL *p = (FCELL *) fcb->data;
571  int i;
572 
573  for (i = 0; i < fcb->cellhd.cols; i++)
574  if (Rast_is_c_null_value(&buf[i]))
575  Rast_set_f_null_value(&p[i], 1);
576  else
577  p[i] = (FCELL) buf[i];
578 
579  Rast_put_f_row(fd, p);
580 }
581 
582 static void convert_and_write_df(int fd, const void *vbuf)
583 {
584  const DCELL *buf = vbuf;
585  struct fileinfo *fcb = &R__.fileinfo[fd];
586  FCELL *p = (FCELL *) fcb->data;
587  int i;
588 
589  for (i = 0; i < fcb->cellhd.cols; i++)
590  if (Rast_is_d_null_value(&buf[i]))
591  Rast_set_f_null_value(&p[i], 1);
592  else
593  p[i] = (FCELL) buf[i];
594 
595  Rast_put_f_row(fd, p);
596 }
597 
598 static void convert_and_write_id(int fd, const void *vbuf)
599 {
600  const CELL *buf = vbuf;
601  struct fileinfo *fcb = &R__.fileinfo[fd];
602  DCELL *p = (DCELL *) fcb->data;
603  int i;
604 
605  for (i = 0; i < fcb->cellhd.cols; i++)
606  if (Rast_is_c_null_value(&buf[i]))
607  Rast_set_d_null_value(&p[i], 1);
608  else
609  p[i] = (DCELL) buf[i];
610 
611  Rast_put_d_row(fd, p);
612 }
613 
614 static void convert_and_write_fd(int fd, const void *vbuf)
615 {
616  const FCELL *buf = vbuf;
617  struct fileinfo *fcb = &R__.fileinfo[fd];
618  DCELL *p = (DCELL *) fcb->data;
619  int i;
620 
621  for (i = 0; i < fcb->cellhd.cols; i++)
622  if (Rast_is_f_null_value(&buf[i]))
623  Rast_set_d_null_value(&p[i], 1);
624  else
625  p[i] = (DCELL) buf[i];
626 
627  Rast_put_d_row(fd, p);
628 }
629 
630 static void convert_and_write_fi(int fd, const void *vbuf)
631 {
632  const FCELL *buf = vbuf;
633  struct fileinfo *fcb = &R__.fileinfo[fd];
634  CELL *p = (CELL *) fcb->data;
635  int i;
636 
637  for (i = 0; i < fcb->cellhd.cols; i++)
638  if (Rast_is_f_null_value(&buf[i]))
639  Rast_set_c_null_value(&p[i], 1);
640  else
641  p[i] = (CELL) buf[i];
642 
643  Rast_put_c_row(fd, p);
644 }
645 
646 static void convert_and_write_di(int fd, const void *vbuf)
647 {
648  const DCELL *buf = vbuf;
649  struct fileinfo *fcb = &R__.fileinfo[fd];
650  CELL *p = (CELL *) fcb->data;
651  int i;
652 
653  for (i = 0; i < fcb->cellhd.cols; i++)
654  if (Rast_is_d_null_value(&buf[i]))
655  Rast_set_c_null_value(&p[i], 1);
656  else
657  p[i] = (CELL) buf[i];
658 
659  Rast_put_c_row(fd, p);
660 }
661 
662 /*!
663  \brief converts a buffer of zero's and ones to bitstream.
664 
665  Stores this bitstream in memory. (the null rows from memory are
666  written into null file after the limit is reached, and the place for
667  new null rows to be kept in memory is freed. Should not be used by
668  application programs.
669 
670  \param fd file descriptor where data is to be written
671  \param buf buffer holding null data
672 
673  \return void
674  */
675 static void put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type,
676  int zeros_r_nulls)
677 {
678  static void (*convert_and_write_FtypeOtype[3][3])(int, const void *) = {
679  {NULL, convert_and_write_if, convert_and_write_id},
680  {convert_and_write_fi, NULL, convert_and_write_fd},
681  {convert_and_write_di, convert_and_write_df, NULL}
682  };
683  struct fileinfo *fcb = &R__.fileinfo[fd];
684  char *null_buf;
685 
686  switch (fcb->open_mode) {
687  case OPEN_OLD:
688  G_fatal_error(_("put_raster_row: raster map <%s> not open for write - request ignored"),
689  fcb->name);
690  break;
691  case OPEN_NEW_COMPRESSED:
693  break;
694  default:
695  G_fatal_error(_("put_raster_row: unopened file descriptor - request ignored"));
696  break;
697  }
698 
699  if (fcb->map_type != data_type) {
700  convert_and_write_FtypeOtype[data_type][fcb->map_type](fd, buf);
701  return;
702  }
703 
704  null_buf = G_malloc(fcb->cellhd.cols);
705  G_zero(null_buf, fcb->cellhd.cols);
706 
707  put_raster_data(fd, null_buf, buf, fcb->cur_row, fcb->cellhd.cols,
708  zeros_r_nulls, data_type);
709 
710  /* only for integer maps */
711  if (data_type == CELL_TYPE) {
712  if (fcb->want_histogram)
713  Rast_update_cell_stats(buf, fcb->cellhd.cols, &fcb->statf);
714  Rast__row_update_range(buf, fcb->cellhd.cols, &fcb->range,
715  zeros_r_nulls);
716  }
717  else
718  Rast_row_update_fp_range(buf, fcb->cellhd.cols, &fcb->fp_range,
719  data_type);
720 
721  fcb->cur_row++;
722 
723  /* write the null row for the data row */
724  if (!fcb->gdal)
725  put_null_value_row(fd, null_buf);
726 
727  G_free(null_buf);
728 }
#define CELL_TYPE
Definition: raster.h:11
#define OPEN_NEW_COMPRESSED
Definition: R.h:109
#define G_malloc(n)
Definition: defs/gis.h:112
void Rast__write_null_bits(int fd, const unsigned char *flags)
Write null data.
int nbytes
Definition: R.h:73
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
if(!(yy_init))
Definition: sqlp.yy.c:775
struct compressor_list compressor[]
Definition: compress.h:54
int want_histogram
Definition: R.h:62
int G_write_compressed(int, unsigned char *, int, int)
Definition: compress.c:326
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
Definition: null_val.c:124
RASTER_MAP_TYPE map_type
Definition: R.h:74
Definition: R.h:88
void Rast_put_c_row(int fd, const CELL *buf)
Writes the next row for cell file (CELL version)
CPLErr Rast_gdal_raster_IO(GDALRasterBandH, GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int)
char * name
Definition: R.h:78
int data_fd
Definition: R.h:83
#define Rast_is_d_null_value(dcellVal)
Definition: defs/raster.h:420
off_t * row_ptr
Definition: R.h:64
int G_compress_bound(int, int)
Definition: compress.c:205
double DCELL
Definition: gis.h:603
void G_free(void *)
Free allocated memory.
Definition: gis/alloc.c:149
int count
void Rast__row_update_range(const CELL *, int, struct Range *, int)
Update range structure based on raster row.
Definition: range.c:587
unsigned char * data
Definition: R.h:70
char * dst
Definition: lz4.h:599
#define G_incr_void_ptr(ptr, size)
Definition: defs/gis.h:100
#define Rast_is_f_null_value(fcellVal)
Definition: defs/raster.h:418
#define NULL
Definition: ccmath.h:32
unsigned char * null_bits
Definition: R.h:72
struct GDAL_link * gdal
Definition: R.h:82
#define x
struct Range range
Definition: R.h:60
#define OPEN_NEW_UNCOMPRESSED
Definition: R.h:110
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
Definition: symbol/read.c:220
int compressed
Compression mode (raster header only)
Definition: gis.h:425
#define DCELL_TYPE
Definition: raster.h:13
struct Cell_stats statf
Definition: R.h:59
int Rast__null_bitstream_size(int)
Determines null bitstream size.
Definition: alloc_cell.c:148
size_t Rast_cell_size(RASTER_MAP_TYPE)
Returns size of a raster cell in bytes.
Definition: alloc_cell.c:39
int null_fd
Definition: R.h:71
int G_compress(unsigned char *, int, unsigned char *, int, int)
Definition: compress.c:221
int open_mode
Definition: R.h:56
void G_xdr_put_double(void *, const double *)
Definition: gis/xdr.c:88
int cur_row
Definition: R.h:67
void G_xdr_put_float(void *, const float *)
Definition: gis/xdr.c:78
void Rast_set_f_null_value(FCELL *, int)
To set a number of FCELL raster values to NULL.
Definition: null_val.c:138
void Rast_put_f_row(int fd, const FCELL *buf)
Writes the next row for fcell file (FCELL version)
struct fileinfo * fileinfo
Definition: R.h:103
#define OPEN_OLD
Definition: R.h:108
int Rast_update_cell_stats(const CELL *, int, struct Cell_stats *)
Add data to cell stats.
Definition: cell_stats.c:62
float FCELL
Definition: gis.h:604
void Rast_put_d_row(int fd, const DCELL *buf)
Writes the next row for dcell file (DCELL version)
void Rast_set_d_value(void *, DCELL, RASTER_MAP_TYPE)
Places a DCELL raster value.
void Rast_row_update_fp_range(const void *, int, struct FPRange *, RASTER_MAP_TYPE)
Update range structure based on raster row (floating-point)
Definition: range.c:630
int cols
Number of columns for 2D data.
Definition: gis.h:431
off_t * null_row_ptr
Definition: R.h:84
struct Cell_head cellhd
Definition: R.h:57
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
Definition: gis/zero.c:23
int CELL
Definition: gis.h:602
Definition: R.h:54
#define _(str)
Definition: glocale.h:10
int RASTER_MAP_TYPE
Definition: raster.h:25
void Rast__convert_01_flags(const char *, unsigned char *, int)
?
Definition: null_val.c:423
int null_cur_row
Definition: R.h:68
#define FCELL_TYPE
Definition: raster.h:12
void Rast_put_row(int fd, const void *buf, RASTER_MAP_TYPE data_type)
Writes the next row for cell/fcell/dcell file.
int rows
Number of rows for 2D data.
Definition: gis.h:427
#define Rast_is_c_null_value(cellVal)
Definition: defs/raster.h:416
struct FPRange fp_range
Definition: R.h:61
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
Definition: null_val.c:155
int Rast_is_null_value(const void *, RASTER_MAP_TYPE)
To check if a raster value is set to NULL.
Definition: null_val.c:179