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