GRASS Programmer's Manual  6.4.2(2012)
vector/vedit/copy.c
Go to the documentation of this file.
00001 
00015 #include <grass/vedit.h>
00016 
00027 int Vedit_copy_lines(struct Map_info *Map, struct Map_info *FromMap,
00028                      struct ilist *List)
00029 {
00030     struct line_cats *Cats;
00031     struct line_pnts *Points;
00032     int i;
00033     int type, line;
00034     int nlines_copied;
00035 
00036     nlines_copied = 0;
00037     Cats = Vect_new_cats_struct();
00038     Points = Vect_new_line_struct();
00039 
00040     if (!FromMap) {
00041         FromMap = Map;
00042     }
00043 
00044     /* for each line, make a copy */
00045     for (i = 0; i < List->n_values; i++) {
00046         line = List->value[i];
00047 
00048         if (!Vect_line_alive(FromMap, line))
00049             continue;
00050 
00051         type = Vect_read_line(FromMap, Points, Cats, line);
00052 
00053         G_debug(3, "Vedit_copy_lines(): type=%d, line=%d", type, line);
00054 
00055         /* copy */
00056         if (Vect_write_line(Map, type, Points, Cats) < 0) {
00057             return -1;
00058         }
00059 
00060         nlines_copied++;
00061     }
00062 
00063     Vect_destroy_line_struct(Points);
00064     Vect_destroy_cats_struct(Cats);
00065 
00066     return nlines_copied;
00067 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines