GRASS Programmer's Manual  6.4.3(2013)-r
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
chtype.c
Go to the documentation of this file.
1 
14 #include <grass/vedit.h>
15 
29 int Vedit_chtype_lines(struct Map_info *Map, struct ilist *List)
30 {
31  int i;
32  int nret, line;
33  int type, newtype;
34  struct line_pnts *Points;
35  struct line_cats *Cats;
36 
37  nret = 0;
38 
39  Points = Vect_new_line_struct();
40  Cats = Vect_new_cats_struct();
41 
42  for (i = 0; i < List->n_values; i++) {
43  line = List->value[i];
44  if (!Vect_line_alive(Map, line))
45  continue;
46  type = Vect_read_line(Map, Points, Cats, line);
47  if (type < 0) {
48  return -1;
49  }
50  switch (type) {
51  case GV_POINT:
52  newtype = GV_CENTROID;
53  break;
54  case GV_CENTROID:
55  newtype = GV_POINT;
56  break;
57  case GV_LINE:
58  newtype = GV_BOUNDARY;
59  break;
60  case GV_BOUNDARY:
61  newtype = GV_LINE;
62  break;
63  default:
64  newtype = -1;
65  break;
66  }
67 
68  G_debug(3, "Vedit_chtype_lines(): line=%d, from_type=%d, to_type=%d",
69  line, type, newtype);
70 
71  if (newtype > 0) {
72  if (Vect_rewrite_line(Map, line, newtype, Points, Cats) < 0) {
73  return -1;
74  }
75  nret++;
76  }
77  }
78 
81 
82  return nret;
83 }