GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
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);
47  stat = G_remove(element, GV_COLR_ELEMENT);
48  }
49 
50  return stat;
51 }
int G_remove(const char *, const char *)
Remove a database file.
Definition: remove.c:44
#define GMAPSET_MAX
Definition: gis.h:178
int Vect_remove_colors(const char *name, const char *mapset)
Remove color table of raster map.
#define GV_DIRECTORY
Name of vector directory.
Definition: dig_defines.h:8
Definition: lidar.h:86
#define GPATH_MAX
Definition: gis.h:180
#define GV_COLR2_DIRECTORY
Name of directory for alternative color tables.
Definition: dig_defines.h:30
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
#define GNAME_MAX
Definition: gis.h:177
#define GV_COLR_ELEMENT
Color table.
Definition: dig_defines.h:28
const char * name
Definition: named_colr.c:7
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