GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
raster/close.c
Go to the documentation of this file.
1 /*!
2  * \file lib/raster/close.c
3  *
4  * \brief Raster Library - Close raster file
5  *
6  * (C) 1999-2009 by the GRASS Development Team
7  *
8  * This program is free software under the GNU General Public
9  * License (>=v2). Read the file COPYING that comes with GRASS
10  * for details.
11  *
12  * \author USACERL and many others
13  */
14 
15 #ifdef __MINGW32__
16 # include <windows.h>
17 #endif
18 
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <unistd.h>
23 #include <fcntl.h>
24 #include <signal.h>
25 #include <errno.h>
26 
27 #include <grass/gis.h>
28 #include <grass/raster.h>
29 #include <grass/glocale.h>
30 
31 #include "R.h"
32 
33 #define FORMAT_FILE "f_format"
34 #define QUANT_FILE "f_quant"
35 #define NULL_FILE "null"
36 /* cmpressed null file */
37 #define NULLC_FILE "nullcmpr"
38 
39 static int close_old(int);
40 static int close_new(int, int);
41 
42 static void sync_and_close(int fd, char *element, char *name)
43 {
44  /* from man 2 write:
45  * A successful return from write() does not make any guarantee
46  * that data has been committed to disk. On some filesystems,
47  * including NFS, it does not even guarantee that space has
48  * successfully been reserved for the data. In this case, some
49  * errors might be delayed until a future write(2), fsync(2), or
50  * even close(2). The only way to be sure is to call fsync(2)
51  * after you are done writing all your data.
52  */
53 
54 #ifndef __MINGW32__
55  if (fsync(fd)) {
56  G_warning(_("Unable to flush file %s for raster map %s: %s"),
57  element, name, strerror(errno));
58  }
59  /* for MS Windows, try fdopen(int, char *) + fflush(FILE *) + fclose(FILE *)
60  * flcose() closes the underlying file descriptor, thus no need to
61  * call close(fd) afterwards */
62 #endif
63  if (close(fd)) {
64  G_warning(_("Unable to close file %s for raster map %s: %s"),
65  element, name, strerror(errno));
66  }
67 }
68 
69 static void write_fp_format(int fd);
70 
71 /*!
72  * \brief Close a raster map
73  *
74  * The raster map opened on file descriptor <i>fd</i> is
75  * closed. Memory allocated for raster processing is freed. If open
76  * for writing, skeletal support files for the new raster map are
77  * created as well.
78  *
79  * <b>Note:</b> If a module wants to explicitly write support files
80  * (e.g., a specific color table) for a raster map it creates, it must
81  * do so after the raster map is closed. Otherwise the close will
82  * overwrite the support files. See \ref
83  * Raster_Map_Layer_Support_Routines for routines which write raster
84  * support files.
85  *
86  * If the map is a new floating point, move the <tt>.tmp</tt> file
87  * into the <tt>fcell</tt> element, create an empty file in the
88  * <tt>cell</tt> directory; write the floating-point range file; write
89  * a default quantization file quantization file is set here to round
90  * fp numbers (this is a default for now). create an empty category
91  * file, with max cat = max value (for backwards compatibility). Move
92  * the <tt>.tmp</tt> NULL-value bitmap file to the <tt>cell_misc</tt>
93  * directory.
94  *
95  * \param fd file descriptor
96  *
97  * \return void
98  */
99 void Rast_close(int fd)
100 {
101  struct fileinfo *fcb = &R__.fileinfo[fd];
102 
103  if (fd < 0 || fd >= R__.fileinfo_count || fcb->open_mode <= 0)
104  G_fatal_error(_("Invalid descriptor: %d"), fd);
105 
106  if (fcb->open_mode == OPEN_OLD)
107  close_old(fd);
108  else
109  close_new(fd, 1);
110 }
111 
112 /*!
113  * \brief Unopen a raster map
114  *
115  * The raster map opened on file descriptor <i>fd</i> is
116  * closed. Memory allocated for raster processing is freed. If open
117  * for writing, the raster map is not created and the temporary file
118  * created when the raster map was opened is removed (see \ref
119  * Creating_and_Opening_New_Raster_Files). This routine is useful when
120  * errors are detected and it is desired to not create the new raster
121  * map. While it is true that the raster map will not be created if
122  * the module exits without closing the file, the temporary file will
123  * not be removed at module exit. GRASS database management will
124  * eventually remove the temporary file, but the file can be quite
125  * large and will take up disk space until GRASS does remove it. Use
126  * this routine as a courtesy to the user.
127  *
128  * \param fd file descriptor
129  *
130  * \return void
131  */
132 void Rast_unopen(int fd)
133 {
134  struct fileinfo *fcb = &R__.fileinfo[fd];
135 
136  if (fd < 0 || fd >= R__.fileinfo_count || fcb->open_mode <= 0)
137  G_fatal_error(_("Invalid descriptor: %d"), fd);
138 
139  if (fcb->open_mode == OPEN_OLD)
140  close_old(fd);
141  else
142  close_new(fd, 0);
143 }
144 
145 /*!
146  * \brief Unopen all raster maps
147  *
148  * Unopen all raster maps opened for write. Memory allocated for
149  * raster processing is freed, and the temporary file created when the
150  * raster map was opened is removed (see \ref
151  * Creating_and_Opening_New_Raster_Files). This routine is useful when
152  * errors are detected and it is desired to remove temporary files.
153  *
154  * \return void
155  */
157 {
158  int i;
159 
160  for (i = 0; i < R__.fileinfo_count; i++) {
161  struct fileinfo *fcb = &R__.fileinfo[i];
162 
163  if (fcb->open_mode == OPEN_NEW_COMPRESSED ||
165  close_new(i, 0);
166  }
167 }
168 
169 static int close_old(int fd)
170 {
171  struct fileinfo *fcb = &R__.fileinfo[fd];
172 
173  /* if R__.auto_mask was only allocated for reading map rows to create
174  non-existant null rows, and not for actuall mask, free R__.mask_row
175  if(R__.auto_mask <=0)
176  G_free (R__.mask_buf);
177  This is obsolete since now the mask_bus is always allocated
178  */
179 
180  if (fcb->gdal)
182  if (fcb->vrt)
183  Rast_close_vrt(fcb->vrt);
184 
185  if (fcb->null_bits)
186  G_free(fcb->null_bits);
187  if (fcb->null_row_ptr)
188  G_free(fcb->null_row_ptr);
189  if (fcb->null_fd >= 0)
190  close(fcb->null_fd);
191  fcb->null_fd = -1;
192 
193  if (fcb->cellhd.compressed)
194  G_free(fcb->row_ptr);
195  G_free(fcb->col_map);
196  G_free(fcb->mapset);
197  G_free(fcb->data);
198  G_free(fcb->name);
199  if (fcb->reclass_flag)
200  Rast_free_reclass(&fcb->reclass);
201  fcb->open_mode = -1;
202 
203  if (fcb->map_type != CELL_TYPE) {
204  Rast_quant_free(&fcb->quant);
205  }
206  if (fcb->data_fd >= 0)
207  close(fcb->data_fd);
208 
209  return 1;
210 }
211 
212 static void write_support_files(int fd)
213 {
214  struct fileinfo *fcb = &R__.fileinfo[fd];
215  struct Categories cats;
216  struct History hist;
217  CELL cell_min, cell_max;
218  char path[GPATH_MAX];
219 
220  /* remove color table */
221  Rast_remove_colors(fcb->name, "");
222 
223  /* create a history file */
224  Rast_short_history(fcb->name, "raster", &hist);
225  Rast_write_history(fcb->name, &hist);
226 
227  /* write the range */
228  if (fcb->map_type == CELL_TYPE) {
229  Rast_write_range(fcb->name, &fcb->range);
231  }
232  /*NOTE: int range for floating point maps is not written out */
233  else { /* if(fcb->map_type != CELL_TYPE) */
234 
235  Rast_write_fp_range(fcb->name, &fcb->fp_range);
237  /* this range will be used to add default rule to quant structure */
238  }
239 
240  if (fcb->map_type != CELL_TYPE)
241  fcb->cellhd.format = -1;
242  else /* CELL map */
243  fcb->cellhd.format = fcb->nbytes - 1;
244 
245  /* write header file */
246  Rast_put_cellhd(fcb->name, &fcb->cellhd);
247 
248  /* if map is floating point write the quant rules, otherwise remove f_quant */
249  if (fcb->map_type != CELL_TYPE) {
250  /* DEFAULT RANGE QUANT
251  Rast_get_fp_range_min_max(&fcb->fp_range, &dcell_min, &dcell_max);
252  if(!Rast_is_d_null_value(&dcell_min) && !Rast_is_d_null_value(&dcell_max))
253  {
254  Rast_get_range_min_max(&fcb->range, &cell_min, &cell_max);
255  Rast_quant_add_rule(&fcb->quant, dcell_min, dcell_max,
256  cell_min, cell_max);
257  }
258  */
259  Rast_quant_round(&fcb->quant);
260  Rast_write_quant(fcb->name, fcb->mapset, &fcb->quant);
261  }
262  else {
263  /* remove cell_misc/name/f_quant */
264  G_file_name_misc(path, "cell_misc", QUANT_FILE, fcb->name,
265  fcb->mapset);
266  remove(path);
267  }
268 
269  /* create empty cats file */
270  Rast_get_range_min_max(&fcb->range, &cell_min, &cell_max);
271  if (Rast_is_c_null_value(&cell_max))
272  cell_max = 0;
273  Rast_init_cats((char *)NULL, &cats);
274  Rast_write_cats(fcb->name, &cats);
275  Rast_free_cats(&cats);
276 
277  /* write the histogram */
278  /* only works for integer maps */
279  if ((fcb->map_type == CELL_TYPE)
280  && (fcb->want_histogram)) {
281  Rast_write_histogram_cs(fcb->name, &fcb->statf);
283  }
284  else {
286  }
287 }
288 
289 static int close_new_gdal(int fd, int ok)
290 {
291  struct fileinfo *fcb = &R__.fileinfo[fd];
292  char path[GPATH_MAX];
293  int stat = 1;
294 
295  if (ok) {
296  int cell_fd;
297 
298  G_debug(1, "close %s GDAL", fcb->name);
299 
300  if (fcb->cur_row < fcb->cellhd.rows) {
301  int row;
302 
303  Rast_zero_output_buf(fcb->data, fcb->map_type);
304  for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
305  Rast_put_row(fd, fcb->data, fcb->map_type);
306  G_free(fcb->data);
307  fcb->data = NULL;
308  }
309 
310  /* create path : full null file name */
311  G__make_mapset_element_misc("cell_misc", fcb->name);
312  G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name,
313  G_mapset());
314  remove(path);
315  G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name,
316  G_mapset());
317  remove(path);
318 
319  /* write 0-length cell file */
320  G_make_mapset_element("cell");
321  G_file_name(path, "cell", fcb->name, fcb->mapset);
322  cell_fd = creat(path, 0666);
323  close(cell_fd);
324 
325  if (fcb->map_type != CELL_TYPE) { /* floating point map */
326  write_fp_format(fd);
327 
328  /* write 0-length fcell file */
329  G_make_mapset_element("fcell");
330  G_file_name(path, "fcell", fcb->name, fcb->mapset);
331  cell_fd = creat(path, 0666);
332  close(cell_fd);
333  }
334  else {
335  /* remove fcell/name file */
336  G_file_name(path, "fcell", fcb->name, fcb->mapset);
337  remove(path);
338  /* remove cell_misc/name/f_format */
339  G_file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name,
340  fcb->mapset);
341  remove(path);
342  }
343 
344  if (Rast_close_gdal_write_link(fcb->gdal) < 0)
345  stat = -1;
346  }
347  else {
348  remove(fcb->gdal->filename);
350  }
351 
352  fcb->open_mode = -1;
353 
354  if (fcb->data != NULL)
355  G_free(fcb->data);
356 
357  if (ok)
358  write_support_files(fd);
359 
360  G_free(fcb->name);
361  G_free(fcb->mapset);
362 
363  if (fcb->map_type != CELL_TYPE)
364  Rast_quant_free(&fcb->quant);
365 
366  return stat;
367 }
368 
369 static int close_new(int fd, int ok)
370 {
371  struct fileinfo *fcb = &R__.fileinfo[fd];
372  int stat;
373  char path[GPATH_MAX];
374  int row;
375  const char *CELL_DIR;
376 
377  if (fcb->gdal)
378  return close_new_gdal(fd, ok);
379 
380  if (ok) {
381  switch (fcb->open_mode) {
382  case OPEN_NEW_COMPRESSED:
383  G_debug(1, "close %s compressed", fcb->name);
384  break;
386  G_debug(1, "close %s uncompressed", fcb->name);
387  break;
388  }
389 
390  if (fcb->cur_row < fcb->cellhd.rows) {
391  Rast_zero_output_buf(fcb->data, fcb->map_type);
392  for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
393  Rast_put_row(fd, fcb->data, fcb->map_type);
394  G_free(fcb->data);
395  fcb->data = NULL;
396  }
397 
398  if (fcb->null_row_ptr) { /* compressed nulls */
399  fcb->null_row_ptr[fcb->cellhd.rows] = lseek(fcb->null_fd, 0L, SEEK_CUR);
401  }
402 
403  if (fcb->null_fd >= 0) {
404  sync_and_close(fcb->null_fd,
405  (fcb->null_row_ptr ? NULLC_FILE : NULL_FILE),
406  fcb->name);
407  }
408  fcb->null_fd = -1;
409 
410  /* create path : full null file name */
411  G__make_mapset_element_misc("cell_misc", fcb->name);
412  G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name, G_mapset());
413  remove(path);
414  G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name, G_mapset());
415  remove(path);
416 
417  G_file_name_misc(path, "cell_misc",
419  fcb->name, G_mapset());
420 
421  if (fcb->null_cur_row > 0) {
422  /* if temporary NULL file exists, write it into cell_misc/name/null */
423  if (rename(fcb->null_temp_name, path)) {
424  G_warning(_("Unable to rename null file '%s' to '%s': %s"),
425  fcb->null_temp_name, path, strerror(errno));
426  stat = -1;
427  }
428  /* if rename() was successful what is left to remove() ? */
429  else {
430  remove(fcb->null_temp_name);
431  }
432  }
433  else {
434  remove(fcb->null_temp_name);
435  remove(path); /* again ? */
436  } /* null_cur_row > 0 */
437 
438  if (fcb->open_mode == OPEN_NEW_COMPRESSED) { /* auto compression */
439  fcb->row_ptr[fcb->cellhd.rows] = lseek(fcb->data_fd, 0L, SEEK_CUR);
441  }
442 
443  if (fcb->map_type != CELL_TYPE) { /* floating point map */
444  int cell_fd;
445 
446  write_fp_format(fd);
447 
448  /* now write 0-length cell file */
449  G_make_mapset_element("cell");
450  cell_fd =
451  creat(G_file_name(path, "cell", fcb->name, fcb->mapset),
452  0666);
453  close(cell_fd);
454  CELL_DIR = "fcell";
455  }
456  else {
457  /* remove fcell/name file */
458  G_file_name(path, "fcell", fcb->name, fcb->mapset);
459  remove(path);
460  /* remove cell_misc/name/f_format */
461  G_file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name,
462  fcb->mapset);
463  remove(path);
464  CELL_DIR = "cell";
465  }
466  } /* ok */
467  /* NOW CLOSE THE FILE DESCRIPTOR */
468 
469  sync_and_close(fcb->data_fd,
470  (fcb->map_type == CELL_TYPE ? "cell" : "fcell"),
471  fcb->name);
472  fcb->open_mode = -1;
473 
474  if (fcb->null_fd >= 0) {
475  sync_and_close(fcb->null_fd,
476  (fcb->null_row_ptr ? NULLC_FILE : NULL_FILE),
477  fcb->name);
478  }
479  fcb->null_fd = -1;
480 
481  if (fcb->data != NULL)
482  G_free(fcb->data);
483 
484  if (fcb->null_temp_name != NULL) {
485  G_free(fcb->null_temp_name);
486  fcb->null_temp_name = NULL;
487  }
488 
489  /* if the cell file was written to a temporary file
490  * move this temporary file into the cell file
491  * if the move fails, tell the user, but go ahead and create
492  * the support files
493  */
494  stat = 1;
495  if (ok && (fcb->temp_name != NULL)) {
496  G_file_name(path, CELL_DIR, fcb->name, fcb->mapset);
497  remove(path);
498  if (rename(fcb->temp_name, path)) {
499  G_warning(_("Unable to rename cell file '%s' to '%s': %s"),
500  fcb->temp_name, path, strerror(errno));
501  stat = -1;
502  }
503  /* if rename() was successful what is left to remove() ? */
504  else {
505  remove(fcb->temp_name);
506  }
507  }
508 
509  if (fcb->temp_name != NULL) {
510  G_free(fcb->temp_name);
511  }
512 
513  if (ok)
514  write_support_files(fd);
515 
516  G_free(fcb->name);
517  G_free(fcb->mapset);
518 
519  G_free(fcb->null_bits);
520 
521  if (fcb->null_row_ptr)
522  G_free(fcb->null_row_ptr);
523 
524  if (fcb->map_type != CELL_TYPE)
525  Rast_quant_free(&fcb->quant);
526 
527  return stat;
528 }
529 
530 void Rast__close_null(int fd)
531 {
532  struct fileinfo *fcb = &R__.fileinfo[fd];
533  char path[GPATH_MAX];
534 
535  if (fcb->null_row_ptr) { /* compressed nulls */
536  fcb->null_row_ptr[fcb->cellhd.rows] = lseek(fcb->null_fd, 0L, SEEK_CUR);
538  G_free(fcb->null_row_ptr);
539  }
540 
541  if (fcb->null_fd >= 0)
542  close(fcb->null_fd);
543  fcb->null_fd = -1;
544 
545  /* create path : full null file name */
546  G__make_mapset_element_misc("cell_misc", fcb->name);
547  G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name, G_mapset());
548  remove(path);
549  G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name, G_mapset());
550  remove(path);
551 
552  G_file_name_misc(path, "cell_misc",
554  fcb->name, G_mapset());
555 
556  if (rename(fcb->null_temp_name, path))
557  G_warning(_("Unable to rename null file '%s' to '%s': %s"),
558  fcb->null_temp_name, path, strerror(errno));
559  remove(fcb->null_temp_name);
560 
561  G_free(fcb->null_temp_name);
562 
563  G_free(fcb->name);
564  G_free(fcb->mapset);
565 
566  G_free(fcb->null_bits);
567 
568  fcb->open_mode = -1;
569 }
570 
571 /* returns 0 on success, 1 on failure */
572 static void write_fp_format(int fd)
573 {
574  struct fileinfo *fcb = &R__.fileinfo[fd];
575  struct Key_Value *format_kv;
576  char path[GPATH_MAX];
577 
578  if (fcb->map_type == CELL_TYPE) {
579  G_warning(_("unable to write f_format file for CELL maps"));
580  return;
581  }
582  format_kv = G_create_key_value();
583  if (fcb->map_type == FCELL_TYPE)
584  G_set_key_value("type", "float", format_kv);
585  else
586  G_set_key_value("type", "double", format_kv);
587 
588  G_set_key_value("byte_order", "xdr", format_kv);
589 
590  if (fcb->open_mode == OPEN_NEW_COMPRESSED)
591  G_set_key_value("lzw_compression_bits", "-1", format_kv);
592 
593  G__make_mapset_element_misc("cell_misc", fcb->name);
594  G_file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name, fcb->mapset);
595  G_write_key_value_file(path, format_kv);
596 
597  G_free_key_value(format_kv);
598 }
#define CELL_TYPE
Definition: raster.h:11
#define OPEN_NEW_COMPRESSED
Definition: R.h:109
#define NULLC_FILE
Definition: raster/close.c:37
void Rast_close_gdal_link(struct GDAL_link *)
Close existing GDAL link.
Definition: gdal.c:581
int nbytes
Definition: R.h:73
char * G_file_name_misc(char *, const char *, const char *, const char *, const char *)
Builds full path names to GIS misc data files.
Definition: file_name.c:55
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
Definition: file_name.c:38
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void Rast_write_history(const char *, struct History *)
Write raster history file.
Definition: history.c:158
int want_histogram
Definition: R.h:62
RASTER_MAP_TYPE map_type
Definition: R.h:74
void Rast_put_row(int, const void *, RASTER_MAP_TYPE)
Writes the next row for cell/fcell/dcell file.
Definition: R.h:88
void Rast__remove_fp_range(const char *)
Remove floating-point range.
Definition: range.c:33
char * name
Definition: R.h:78
int data_fd
Definition: R.h:83
void Rast_free_reclass(struct Reclass *)
Free Reclass structure.
Definition: reclass.c:183
void Rast_close(int fd)
Close a raster map.
Definition: raster/close.c:99
off_t * row_ptr
Definition: R.h:64
void Rast_construct_default_range(struct Range *)
Construct default range.
Definition: range.c:45
void Rast_free_cell_stats(struct Cell_stats *)
Free cell stats structure.
Definition: cell_stats.c:385
int Rast_remove_colors(const char *, const char *)
Remove color table of raster map.
char * temp_name
Definition: R.h:75
void G_free(void *)
Free allocated memory.
Definition: gis/alloc.c:149
unsigned char * data
Definition: R.h:70
int G__make_mapset_element_misc(const char *, const char *)
Create misc element in the current mapset.
Definition: mapset_msc.c:112
struct R_vrt * vrt
Definition: R.h:85
COLUMN_MAPPING * col_map
Definition: R.h:65
#define NULL
Definition: ccmath.h:32
void Rast_close_vrt(struct R_vrt *)
Definition: vrt.c:150
unsigned char * null_bits
Definition: R.h:72
struct GDAL_link * gdal
Definition: R.h:82
int format
Max number of bytes per raster data value minus 1 (raster header only)
Definition: gis.h:418
#define FORMAT_FILE
Definition: raster/close.c:33
struct Range range
Definition: R.h:60
#define OPEN_NEW_UNCOMPRESSED
Definition: R.h:110
struct Reclass reclass
Definition: R.h:58
void Rast_quant_free(struct Quant *)
Resets and frees allocated memory.
Definition: quant.c:60
Definition: lidar.h:86
int compressed
Compression mode (raster header only)
Definition: gis.h:425
void Rast__unopen_all(void)
Unopen all raster maps.
Definition: raster/close.c:156
struct Cell_stats statf
Definition: R.h:59
void Rast_zero_output_buf(void *, RASTER_MAP_TYPE)
Definition: zero_cell.c:38
void Rast_write_fp_range(const char *, const struct FPRange *)
Write raster range file (floating-point)
Definition: range.c:406
int null_fd
Definition: R.h:71
#define NULL_FILE
Definition: raster/close.c:35
char * mapset
Definition: R.h:79
int open_mode
Definition: R.h:56
Raster history info (metadata)
Definition: raster.h:180
int cur_row
Definition: R.h:67
void G_set_key_value(const char *, const char *, struct Key_Value *)
Set value for given key.
Definition: key_value1.c:38
#define GPATH_MAX
Definition: gis.h:170
void G_write_key_value_file(const char *, const struct Key_Value *)
Write key/value pairs to file.
Definition: key_value3.c:28
void Rast_put_cellhd(const char *, struct Cell_head *)
Writes the raster file header.
Definition: put_cellhd.c:28
void Rast_init_cats(const char *, struct Categories *)
Initialize category structure.
Definition: raster/cats.c:1145
int Rast_close_gdal_write_link(struct GDAL_link *)
Close existing GDAL link and write out data.
Definition: gdal.c:598
#define QUANT_FILE
Definition: raster/close.c:34
int fileinfo_count
Definition: R.h:102
struct fileinfo * fileinfo
Definition: R.h:103
char * null_temp_name
Definition: R.h:76
Definition: gis.h:501
#define OPEN_OLD
Definition: R.h:108
int Rast__write_row_ptrs(int)
void Rast_short_history(const char *, const char *, struct History *)
Initialize history structure.
Definition: history.c:226
void Rast_unopen(int fd)
Unopen a raster map.
Definition: raster/close.c:132
off_t * null_row_ptr
Definition: R.h:84
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
struct Cell_head cellhd
Definition: R.h:57
void G_warning(const char *,...) __attribute__((format(printf
int CELL
Definition: gis.h:602
Definition: R.h:54
Definition: path.h:16
void Rast_free_cats(struct Categories *)
Free category structure memory.
Definition: raster/cats.c:1213
void Rast_write_cats(const char *, struct Categories *)
Write raster category file.
Definition: raster/cats.c:938
#define _(str)
Definition: glocale.h:10
void Rast_remove_histogram(const char *)
Removes the histogram.
Definition: histogram.c:344
void Rast_quant_round(struct Quant *)
Sets the quant rules to perform simple rounding on floats.
Definition: quant.c:234
int G_make_mapset_element(const char *)
Create element in the current mapset.
Definition: mapset_msc.c:38
int null_cur_row
Definition: R.h:68
#define FCELL_TYPE
Definition: raster.h:12
struct Quant quant
Definition: R.h:81
void Rast_write_range(const char *, const struct Range *)
Write raster range file.
Definition: range.c:372
struct Key_Value * G_create_key_value(void)
Allocate and initialize Key_Value structure.
Definition: key_value1.c:23
int Rast__write_null_row_ptrs(int, int)
const char * name
Definition: named_colr.c:7
void Rast_write_histogram_cs(const char *, struct Cell_stats *)
Writes the histogram based on cell statistics to file.
Definition: histogram.c:116
int rows
Number of rows for 2D data.
Definition: gis.h:427
#define Rast_is_c_null_value(cellVal)
Definition: defs/raster.h:416
void Rast__close_null(int fd)
Definition: raster/close.c:530
int G_debug(int, const char *,...) __attribute__((format(printf
struct FPRange fp_range
Definition: R.h:61
void G_free_key_value(struct Key_Value *)
Free allocated Key_Value structure.
Definition: key_value1.c:103
void Rast_get_range_min_max(const struct Range *, CELL *, CELL *)
Get range min and max.
Definition: range.c:714
void Rast_write_quant(const char *, const char *, const struct Quant *)
Writes the quant rule table for the raster map.
Definition: quant_rw.c:150
int reclass_flag
Definition: R.h:63