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