GRASS Programmer's Manual 6.4.1(2011)
|
00001 00017 #include <grass/vedit.h> 00018 00032 int Vedit_chtype_lines(struct Map_info *Map, struct ilist *List) 00033 { 00034 int i; 00035 int nret, line; 00036 int type, newtype; 00037 struct line_pnts *Points; 00038 struct line_cats *Cats; 00039 00040 nret = 0; 00041 00042 Points = Vect_new_line_struct(); 00043 Cats = Vect_new_cats_struct(); 00044 00045 for (i = 0; i < List->n_values; i++) { 00046 line = List->value[i]; 00047 if (!Vect_line_alive(Map, line)) 00048 continue; 00049 type = Vect_read_line(Map, Points, Cats, line); 00050 if (type < 0) { 00051 return -1; 00052 } 00053 switch (type) { 00054 case GV_POINT: 00055 newtype = GV_CENTROID; 00056 break; 00057 case GV_CENTROID: 00058 newtype = GV_POINT; 00059 break; 00060 case GV_LINE: 00061 newtype = GV_BOUNDARY; 00062 break; 00063 case GV_BOUNDARY: 00064 newtype = GV_LINE; 00065 break; 00066 default: 00067 newtype = -1; 00068 break; 00069 } 00070 00071 G_debug(3, "Vedit_chtype_lines(): line=%d, from_type=%d, to_type=%d", 00072 line, type, newtype); 00073 00074 if (newtype > 0) { 00075 if (Vect_rewrite_line(Map, line, newtype, Points, Cats) < 0) { 00076 return -1; 00077 } 00078 nret++; 00079 } 00080 } 00081 00082 Vect_destroy_line_struct(Points); 00083 Vect_destroy_cats_struct(Cats); 00084 00085 return nret; 00086 }