GRASS Programmer's Manual  6.4.2(2012)
chtype.c
Go to the documentation of this file.
00001 
00014 #include <grass/vedit.h>
00015 
00029 int Vedit_chtype_lines(struct Map_info *Map, struct ilist *List)
00030 {
00031     int i;
00032     int nret, line;
00033     int type, newtype;
00034     struct line_pnts *Points;
00035     struct line_cats *Cats;
00036 
00037     nret = 0;
00038 
00039     Points = Vect_new_line_struct();
00040     Cats = Vect_new_cats_struct();
00041 
00042     for (i = 0; i < List->n_values; i++) {
00043         line = List->value[i];
00044         if (!Vect_line_alive(Map, line))
00045             continue;
00046         type = Vect_read_line(Map, Points, Cats, line);
00047         if (type < 0) {
00048             return -1;
00049         }
00050         switch (type) {
00051         case GV_POINT:
00052             newtype = GV_CENTROID;
00053             break;
00054         case GV_CENTROID:
00055             newtype = GV_POINT;
00056             break;
00057         case GV_LINE:
00058             newtype = GV_BOUNDARY;
00059             break;
00060         case GV_BOUNDARY:
00061             newtype = GV_LINE;
00062             break;
00063         default:
00064             newtype = -1;
00065             break;
00066         }
00067 
00068         G_debug(3, "Vedit_chtype_lines(): line=%d, from_type=%d, to_type=%d",
00069                 line, type, newtype);
00070 
00071         if (newtype > 0) {
00072             if (Vect_rewrite_line(Map, line, newtype, Points, Cats) < 0) {
00073                 return -1;
00074             }
00075             nret++;
00076         }
00077     }
00078 
00079     Vect_destroy_line_struct(Points);
00080     Vect_destroy_cats_struct(Cats);
00081 
00082     return nret;
00083 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines