GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
vector/Vlib/type.c
Go to the documentation of this file.
1 /*!
2  \file lib/vector/Vlib/type.c
3 
4  \brief Vector library - feature type
5 
6  Higher level functions for reading/writing/manipulating vectors.
7 
8  (C) 2001-2009 by the GRASS Development Team
9 
10  This program is free software under the GNU General Public License
11  (>=v2). Read the file COPYING that comes with GRASS for details.
12 
13  \author Radim Blazek
14  */
15 
16 #include <grass/vector.h>
17 
18 /*!
19  \brief Get types from options
20 
21  \param type_opt Option structure
22 
23  \return types
24  \return -1 on error
25  */
26 int Vect_option_to_types(const struct Option *type_opt)
27 {
28  int i, type;
29 
30  type = 0;
31  for (i = 0; type_opt->answers[i]; i++) {
32  if (strcmp(type_opt->answers[i], "auto") == 0)
33  continue;
34 
35  switch (type_opt->answers[i][0]) {
36  case 'p':
37  type |= GV_POINT;
38  break;
39  case 'l':
40  type |= GV_LINE;
41  break;
42  case 'b':
43  type |= GV_BOUNDARY;
44  break;
45  case 'c':
46  type |= GV_CENTROID;
47  break;
48  case 'f':
49  type |= GV_FACE;
50  break;
51  case 'k':
52  type |= GV_KERNEL;
53  break;
54  case 'a':
55  type |= GV_AREA;
56  break;
57  case 'v':
58  type |= GV_VOLUME;
59  break;
60  }
61  }
62 
63  return type;
64 }
#define GV_CENTROID
Definition: dig_defines.h:186
#define GV_LINE
Definition: dig_defines.h:184
#define GV_POINT
Feature types used in memory on run time (may change)
Definition: dig_defines.h:183
#define GV_BOUNDARY
Definition: dig_defines.h:185
#define GV_FACE
Definition: dig_defines.h:187
#define GV_AREA
Definition: dig_defines.h:189
#define GV_VOLUME
Definition: dig_defines.h:190
#define GV_KERNEL
Definition: dig_defines.h:188
Structure that stores option information.
Definition: gis.h:557
char ** answers
Definition: gis.h:573
int Vect_option_to_types(const struct Option *type_opt)
Get types from options.