GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 }
struct line_pnts * Vect_new_line_struct()
Creates and initializes a struct line_pnts.
Definition: line.c:57
int Vect_destroy_cats_struct(struct line_cats *p)
Frees all memory associated with line_cats structure, including the struct itself.
int Vedit_copy_lines(struct Map_info *Map, struct Map_info *FromMap, struct ilist *List)
Copy selected primitives.
int Vect_line_alive(struct Map_info *Map, int line)
Check if feature is alive or dead.
struct line_cats * Vect_new_cats_struct()
Creates and initializes line_cats structure.
tuple Map
Definition: render.py:1310
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
long Vect_write_line(struct Map_info *Map, int type, struct line_pnts *points, struct line_cats *cats)
Writes new feature to the end of file (table)
int Vect_destroy_line_struct(struct line_pnts *p)
Frees all memory associated with a struct line_pnts, including the struct itself. ...
Definition: line.c:90
int Vect_read_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read vector feature.