GRASS Programmer's Manual  6.4.3(2013)-r
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
flip.c
Go to the documentation of this file.
1 
14 #include <grass/vedit.h>
15 
25 int Vedit_flip_lines(struct Map_info *Map, struct ilist *List)
26 {
27  struct line_cats *Cats;
28  struct line_pnts *Points;
29  int i, line, type;
30  int nlines_flipped;
31 
32  nlines_flipped = 0;
33 
34  Points = Vect_new_line_struct();
35  Cats = Vect_new_cats_struct();
36 
37  for (i = 0; i < List->n_values; i++) {
38  line = List->value[i];
39 
40  if (!Vect_line_alive(Map, line))
41  continue;
42 
43  type = Vect_read_line(Map, Points, Cats, line);
44 
45  if (!(type & GV_LINES))
46  continue;
47 
48  Vect_line_reverse(Points);
49 
50  if (Vect_rewrite_line(Map, line, type, Points, Cats) < 0) {
51  return -1;
52  }
53 
54  G_debug(3, "Vedit_flip_lines(): line=%d", line);
55 
56  nlines_flipped++;
57  }
58 
59  /* destroy structures */
62 
63  return nlines_flipped;
64 }