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