GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
vector/Vlib/color_remove.c
Go to the documentation of this file.
1 /*!
2  \file lib/vector/Vlib/color_remove.c
3 
4  \brief Vector Library - remove color table of vector map
5 
6  (C) 2011 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 Martin Landa <landa.martin gmail.com>
12  */
13 
14 #include <string.h>
15 
16 #include <grass/gis.h>
17 #include <grass/vector.h>
18 
19 /*!
20  \brief Remove color table of raster map
21 
22  \param name name of raster map
23  \param mapset name of mapset
24 
25  \return -1 on error
26  \return 0 color table not found
27  \return 1 on success
28  */
29 int Vect_remove_colors(const char *name, const char *mapset)
30 {
31  char element[GPATH_MAX];
32  char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
33  int stat;
34 
35  if (G_name_is_fully_qualified(name, xname, xmapset)) {
36  if (strcmp(xmapset, mapset) != 0)
37  return -1;
38  name = xname;
39  }
40 
41  /* get rid of existing colr2, if any */
42  sprintf(element, "%s/%s", GV_COLR2_DIRECTORY, mapset);
43  stat = G_remove(element, name);
44 
45  if (strcmp(mapset, G_mapset()) == 0) {
46  sprintf(element, "%s/%s", GV_DIRECTORY, name);
48  }
49 
50  return stat;
51 }
int G_name_is_fully_qualified(const char *, char *, char *)
Check if map name is fully qualified (map @ mapset)
Definition: nme_in_mps.c:36
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
int G_remove(const char *, const char *)
Remove a database file.
Definition: remove.c:44
#define GV_COLR2_DIRECTORY
Name of directory for alternative color tables.
Definition: dig_defines.h:30
#define GV_DIRECTORY
Name of vector directory.
Definition: dig_defines.h:8
#define GV_COLR_ELEMENT
Color table.
Definition: dig_defines.h:28
#define GMAPSET_MAX
Definition: gis.h:192
#define GPATH_MAX
Definition: gis.h:194
#define GNAME_MAX
Definition: gis.h:191
const char * name
Definition: named_colr.c:6
Definition: lidar.h:85
int Vect_remove_colors(const char *name, const char *mapset)
Remove color table of raster map.