GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 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 
156  if (fcb->null_bits)
157  G_free(fcb->null_bits);
158  if (fcb->null_row_ptr)
159  G_free(fcb->null_row_ptr);
160  if (fcb->null_fd >= 0)
161  close(fcb->null_fd);
162  fcb->null_fd = -1;
163 
164  if (fcb->cellhd.compressed)
165  G_free(fcb->row_ptr);
166  G_free(fcb->col_map);
167  G_free(fcb->mapset);
168  G_free(fcb->data);
169  G_free(fcb->name);
170  if (fcb->reclass_flag)
171  Rast_free_reclass(&fcb->reclass);
172  fcb->open_mode = -1;
173 
174  if (fcb->map_type != CELL_TYPE) {
175  Rast_quant_free(&fcb->quant);
176  }
177  if (fcb->data_fd >= 0)
178  close(fcb->data_fd);
179 
180  return 1;
181 }
182 
183 static void write_support_files(int fd)
184 {
185  struct fileinfo *fcb = &R__.fileinfo[fd];
186  struct Categories cats;
187  struct History hist;
188  CELL cell_min, cell_max;
189  char path[GPATH_MAX];
190 
191  /* remove color table */
192  Rast_remove_colors(fcb->name, "");
193 
194  /* create a history file */
195  Rast_short_history(fcb->name, "raster", &hist);
196  Rast_write_history(fcb->name, &hist);
197 
198  /* write the range */
199  if (fcb->map_type == CELL_TYPE) {
200  Rast_write_range(fcb->name, &fcb->range);
202  }
203  /*NOTE: int range for floating point maps is not written out */
204  else { /* if(fcb->map_type != CELL_TYPE) */
205 
206  Rast_write_fp_range(fcb->name, &fcb->fp_range);
208  /* this range will be used to add default rule to quant structure */
209  }
210 
211  if (fcb->map_type != CELL_TYPE)
212  fcb->cellhd.format = -1;
213  else /* CELL map */
214  fcb->cellhd.format = fcb->nbytes - 1;
215 
216  /* write header file */
217  Rast_put_cellhd(fcb->name, &fcb->cellhd);
218 
219  /* if map is floating point write the quant rules, otherwise remove f_quant */
220  if (fcb->map_type != CELL_TYPE) {
221  /* DEFAULT RANGE QUANT
222  Rast_get_fp_range_min_max(&fcb->fp_range, &dcell_min, &dcell_max);
223  if(!Rast_is_d_null_value(&dcell_min) && !Rast_is_d_null_value(&dcell_max))
224  {
225  Rast_get_range_min_max(&fcb->range, &cell_min, &cell_max);
226  Rast_quant_add_rule(&fcb->quant, dcell_min, dcell_max,
227  cell_min, cell_max);
228  }
229  */
230  Rast_quant_round(&fcb->quant);
231  Rast_write_quant(fcb->name, fcb->mapset, &fcb->quant);
232  }
233  else {
234  /* remove cell_misc/name/f_quant */
235  G_file_name_misc(path, "cell_misc", QUANT_FILE, fcb->name,
236  fcb->mapset);
237  remove(path);
238  }
239 
240  /* create empty cats file */
241  Rast_get_range_min_max(&fcb->range, &cell_min, &cell_max);
242  if (Rast_is_c_null_value(&cell_max))
243  cell_max = 0;
244  Rast_init_cats((char *)NULL, &cats);
245  Rast_write_cats(fcb->name, &cats);
246  Rast_free_cats(&cats);
247 
248  /* write the histogram */
249  /* only works for integer maps */
250  if ((fcb->map_type == CELL_TYPE)
251  && (fcb->want_histogram)) {
252  Rast_write_histogram_cs(fcb->name, &fcb->statf);
254  }
255  else {
257  }
258 }
259 
260 static int close_new_gdal(int fd, int ok)
261 {
262  struct fileinfo *fcb = &R__.fileinfo[fd];
263  char path[GPATH_MAX];
264  int stat = 1;
265 
266  if (ok) {
267  int cell_fd;
268 
269  G_debug(1, "close %s GDAL", fcb->name);
270 
271  if (fcb->cur_row < fcb->cellhd.rows) {
272  int row;
273 
274  Rast_zero_output_buf(fcb->data, fcb->map_type);
275  for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
276  Rast_put_row(fd, fcb->data, fcb->map_type);
277  G_free(fcb->data);
278  fcb->data = NULL;
279  }
280 
281  /* create path : full null file name */
282  G__make_mapset_element_misc("cell_misc", fcb->name);
283  G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name,
284  G_mapset());
285  remove(path);
286  G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name,
287  G_mapset());
288  remove(path);
289 
290  /* write 0-length cell file */
291  G_make_mapset_element("cell");
292  G_file_name(path, "cell", fcb->name, fcb->mapset);
293  cell_fd = creat(path, 0666);
294  close(cell_fd);
295 
296  if (fcb->map_type != CELL_TYPE) { /* floating point map */
297  write_fp_format(fd);
298 
299  /* write 0-length fcell file */
300  G_make_mapset_element("fcell");
301  G_file_name(path, "fcell", fcb->name, fcb->mapset);
302  cell_fd = creat(path, 0666);
303  close(cell_fd);
304  }
305  else {
306  /* remove fcell/name file */
307  G_file_name(path, "fcell", fcb->name, fcb->mapset);
308  remove(path);
309  /* remove cell_misc/name/f_format */
310  G_file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name,
311  fcb->mapset);
312  remove(path);
313  }
314 
315  if (Rast_close_gdal_write_link(fcb->gdal) < 0)
316  stat = -1;
317  }
318  else {
319  remove(fcb->gdal->filename);
321  }
322 
323  fcb->open_mode = -1;
324 
325  if (fcb->data != NULL)
326  G_free(fcb->data);
327 
328  if (ok)
329  write_support_files(fd);
330 
331  G_free(fcb->name);
332  G_free(fcb->mapset);
333 
334  if (fcb->map_type != CELL_TYPE)
335  Rast_quant_free(&fcb->quant);
336 
337  return stat;
338 }
339 
340 static int close_new(int fd, int ok)
341 {
342  struct fileinfo *fcb = &R__.fileinfo[fd];
343  int stat;
344  char path[GPATH_MAX];
345  int row;
346  const char *CELL_DIR;
347 
348  if (fcb->gdal)
349  return close_new_gdal(fd, ok);
350 
351  if (ok) {
352  switch (fcb->open_mode) {
353  case OPEN_NEW_COMPRESSED:
354  G_debug(1, "close %s compressed", fcb->name);
355  break;
357  G_debug(1, "close %s uncompressed", fcb->name);
358  break;
359  }
360 
361  if (fcb->cur_row < fcb->cellhd.rows) {
362  Rast_zero_output_buf(fcb->data, fcb->map_type);
363  for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
364  Rast_put_row(fd, fcb->data, fcb->map_type);
365  G_free(fcb->data);
366  fcb->data = NULL;
367  }
368 
369  if (fcb->null_row_ptr) { /* compressed nulls */
370  fcb->null_row_ptr[fcb->cellhd.rows] = lseek(fcb->null_fd, 0L, SEEK_CUR);
372  }
373 
374  if (fcb->null_fd >= 0)
375  close(fcb->null_fd);
376  fcb->null_fd = -1;
377 
378  /* create path : full null file name */
379  G__make_mapset_element_misc("cell_misc", fcb->name);
380  G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name, G_mapset());
381  remove(path);
382  G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name, G_mapset());
383  remove(path);
384 
385  G_file_name_misc(path, "cell_misc",
387  fcb->name, G_mapset());
388 
389  if (fcb->null_cur_row > 0) {
390  /* if temporary NULL file exists, write it into cell_misc/name/null */
391  if (rename(fcb->null_temp_name, path)) {
392  G_warning(_("Unable to rename null file '%s' to '%s': %s"),
393  fcb->null_temp_name, path, strerror(errno));
394  stat = -1;
395  }
396  /* if rename() was successful what is left to remove() ? */
397  else {
398  remove(fcb->null_temp_name);
399  }
400  }
401  else {
402  remove(fcb->null_temp_name);
403  remove(path); /* again ? */
404  } /* null_cur_row > 0 */
405 
406  if (fcb->open_mode == OPEN_NEW_COMPRESSED) { /* auto compression */
407  fcb->row_ptr[fcb->cellhd.rows] = lseek(fcb->data_fd, 0L, SEEK_CUR);
409  }
410 
411  if (fcb->map_type != CELL_TYPE) { /* floating point map */
412  int cell_fd;
413 
414  write_fp_format(fd);
415 
416  /* now write 0-length cell file */
417  G_make_mapset_element("cell");
418  cell_fd =
419  creat(G_file_name(path, "cell", fcb->name, fcb->mapset),
420  0666);
421  close(cell_fd);
422  CELL_DIR = "fcell";
423  }
424  else {
425  /* remove fcell/name file */
426  G_file_name(path, "fcell", fcb->name, fcb->mapset);
427  remove(path);
428  /* remove cell_misc/name/f_format */
429  G_file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name,
430  fcb->mapset);
431  remove(path);
432  CELL_DIR = "cell";
433  }
434  } /* ok */
435  /* NOW CLOSE THE FILE DESCRIPTOR */
436 
437  close(fcb->data_fd);
438  fcb->open_mode = -1;
439 
440  if (fcb->null_fd >= 0)
441  close(fcb->null_fd);
442  fcb->null_fd = -1;
443 
444  if (fcb->data != NULL)
445  G_free(fcb->data);
446 
447  if (fcb->null_temp_name != NULL) {
448  G_free(fcb->null_temp_name);
449  fcb->null_temp_name = NULL;
450  }
451 
452  /* if the cell file was written to a temporary file
453  * move this temporary file into the cell file
454  * if the move fails, tell the user, but go ahead and create
455  * the support files
456  */
457  stat = 1;
458  if (ok && (fcb->temp_name != NULL)) {
459  G_file_name(path, CELL_DIR, fcb->name, fcb->mapset);
460  remove(path);
461  if (rename(fcb->temp_name, path)) {
462  G_warning(_("Unable to rename cell file '%s' to '%s': %s"),
463  fcb->temp_name, path, strerror(errno));
464  stat = -1;
465  }
466  /* if rename() was successful what is left to remove() ? */
467  else {
468  remove(fcb->temp_name);
469  }
470  }
471 
472  if (fcb->temp_name != NULL) {
473  G_free(fcb->temp_name);
474  }
475 
476  if (ok)
477  write_support_files(fd);
478 
479  G_free(fcb->name);
480  G_free(fcb->mapset);
481 
482  G_free(fcb->null_bits);
483 
484  if (fcb->null_row_ptr)
485  G_free(fcb->null_row_ptr);
486 
487  if (fcb->map_type != CELL_TYPE)
488  Rast_quant_free(&fcb->quant);
489 
490  return stat;
491 }
492 
493 void Rast__close_null(int fd)
494 {
495  struct fileinfo *fcb = &R__.fileinfo[fd];
496  char path[GPATH_MAX];
497 
498  if (fcb->null_row_ptr) { /* compressed nulls */
499  fcb->null_row_ptr[fcb->cellhd.rows] = lseek(fcb->null_fd, 0L, SEEK_CUR);
501  G_free(fcb->null_row_ptr);
502  }
503 
504  if (fcb->null_fd >= 0)
505  close(fcb->null_fd);
506  fcb->null_fd = -1;
507 
508  /* create path : full null file name */
509  G__make_mapset_element_misc("cell_misc", fcb->name);
510  G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name, G_mapset());
511  remove(path);
512  G_file_name_misc(path, "cell_misc", NULLC_FILE, fcb->name, G_mapset());
513  remove(path);
514 
515  G_file_name_misc(path, "cell_misc",
516  fcb->null_row_ptr ? NULLC_FILE : NULL_FILE,
517  fcb->name, G_mapset());
518 
519  if (rename(fcb->null_temp_name, path))
520  G_warning(_("Unable to rename null file '%s' to '%s': %s"),
521  fcb->null_temp_name, path, strerror(errno));
522  remove(fcb->null_temp_name);
523 
524  G_free(fcb->null_temp_name);
525 
526  G_free(fcb->name);
527  G_free(fcb->mapset);
528 
529  G_free(fcb->null_bits);
530 
531  fcb->open_mode = -1;
532 }
533 
534 /* returns 0 on success, 1 on failure */
535 static void write_fp_format(int fd)
536 {
537  struct fileinfo *fcb = &R__.fileinfo[fd];
538  struct Key_Value *format_kv;
539  char path[GPATH_MAX];
540 
541  if (fcb->map_type == CELL_TYPE) {
542  G_warning(_("unable to write f_format file for CELL maps"));
543  return;
544  }
545  format_kv = G_create_key_value();
546  if (fcb->map_type == FCELL_TYPE)
547  G_set_key_value("type", "float", format_kv);
548  else
549  G_set_key_value("type", "double", format_kv);
550 
551  G_set_key_value("byte_order", "xdr", format_kv);
552 
553  if (fcb->open_mode == OPEN_NEW_COMPRESSED)
554  G_set_key_value("lzw_compression_bits", "-1", format_kv);
555 
556  G__make_mapset_element_misc("cell_misc", fcb->name);
557  G_file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name, fcb->mapset);
558  G_write_key_value_file(path, format_kv);
559 
560  G_free_key_value(format_kv);
561 }
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:93
#define NULLC_FILE
Definition: raster/close.c:37
int nbytes
Definition: R.h:58
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:47
void Rast_write_fp_range(const char *name, const struct FPRange *range)
Write raster range file (floating-point)
Definition: range.c:391
RASTER_MAP_TYPE map_type
Definition: R.h:59
void Rast_zero_output_buf(void *rast, RASTER_MAP_TYPE data_type)
Definition: zero_cell.c:38
Definition: R.h:72
char * name
Definition: R.h:63
int data_fd
Definition: R.h:68
void Rast_close(int fd)
Close a raster map.
Definition: raster/close.c:72
off_t * row_ptr
Definition: R.h:49
int Rast_close_gdal_write_link(struct GDAL_link *gdal)
Close existing GDAL link and write out data.
Definition: gdal.c:592
char * temp_name
Definition: R.h:60
unsigned char * data
Definition: R.h:55
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
COLUMN_MAPPING * col_map
Definition: R.h:50
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:57
struct GDAL_link * gdal
Definition: R.h:67
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:45
#define OPEN_NEW_UNCOMPRESSED
Definition: R.h:94
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:43
fd
Definition: d/range.c:69
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Definition: gis/error.c:159
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:44
void Rast_init_cats(const char *title, struct Categories *pcats)
Initialize category structure.
Definition: raster/cats.c:1145
int null_fd
Definition: R.h:56
#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:64
int open_mode
Definition: R.h:41
Raster history info (metadata)
Definition: raster.h:180
int cur_row
Definition: R.h:52
void Rast_write_range(const char *name, const struct Range *range)
Write raster range file.
Definition: range.c:357
#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:86
struct fileinfo * fileinfo
Definition: R.h:87
char * null_temp_name
Definition: R.h:61
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:92
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:69
struct Cell_head cellhd
Definition: R.h:42
int CELL
Definition: gis.h:580
Definition: R.h:39
Definition: path.h:16
#define _(str)
Definition: glocale.h:13
int null_cur_row
Definition: R.h:53
#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:66
void Rast_close_gdal_link(struct GDAL_link *gdal)
Close existing GDAL link.
Definition: gdal.c:575
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:493
int Rast_remove_colors(const char *name, const char *mapset)
Remove color table of raster map.
struct FPRange fp_range
Definition: R.h:46
int Rast__write_row_ptrs(int fd)
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition: gis/error.c:203
void Rast_get_range_min_max(const struct Range *range, CELL *min, CELL *max)
Get range min and max.
Definition: range.c:699
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:48
void Rast_construct_default_range(struct Range *range)
Construct default range.
Definition: range.c:45