GRASS Programmer's Manual
6.4.2(2012)
|
00001 00017 #include <stdlib.h> 00018 #include <grass/gis.h> 00019 #include <grass/Vect.h> 00020 #include <grass/glocale.h> 00021 00029 int Vect_get_num_nodes(struct Map_info *map) 00030 { 00031 return (map->plus.n_nodes); 00032 } 00033 00042 int Vect_get_num_primitives(struct Map_info *map, int type) 00043 { 00044 int num = 0; 00045 00046 if (type & GV_POINT) 00047 num += map->plus.n_plines; 00048 if (type & GV_LINE) 00049 num += map->plus.n_llines; 00050 if (type & GV_BOUNDARY) 00051 num += map->plus.n_blines; 00052 if (type & GV_CENTROID) 00053 num += map->plus.n_clines; 00054 if (type & GV_FACE) 00055 num += map->plus.n_flines; 00056 if (type & GV_KERNEL) 00057 num += map->plus.n_klines; 00058 00059 return num; 00060 } 00061 00069 int Vect_get_num_lines(struct Map_info *map) 00070 { 00071 return (map->plus.n_lines); 00072 } 00073 00081 int Vect_get_num_areas(struct Map_info *map) 00082 { 00083 return (map->plus.n_areas); 00084 } 00085 00093 int Vect_get_num_kernels(struct Map_info *map) 00094 { 00095 return (map->plus.n_klines); 00096 } 00097 00105 int Vect_get_num_faces(struct Map_info *map) 00106 { 00107 return (map->plus.n_flines); 00108 } 00109 00117 int Vect_get_num_volumes(struct Map_info *map) 00118 { 00119 return (map->plus.n_volumes); 00120 } 00121 00129 int Vect_get_num_islands(struct Map_info *map) 00130 { 00131 return (map->plus.n_isles); 00132 } 00133 00141 int Vect_get_num_dblinks(struct Map_info *map) 00142 { 00143 return (map->dblnk->n_fields); 00144 } 00145 00153 int Vect_get_num_updated_lines(struct Map_info *map) 00154 { 00155 return (map->plus.n_uplines); 00156 } 00157 00166 int Vect_get_updated_line(struct Map_info *map, int idx) 00167 { 00168 return (map->plus.uplines[idx]); 00169 } 00170 00178 int Vect_get_num_updated_nodes(struct Map_info *map) 00179 { 00180 return (map->plus.n_upnodes); 00181 } 00182 00191 int Vect_get_updated_node(struct Map_info *map, int idx) 00192 { 00193 return (map->plus.upnodes[idx]); 00194 } 00195 00205 int 00206 Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y, 00207 double *z) 00208 { 00209 P_NODE *Node; 00210 00211 Node = map->plus.Node[num]; 00212 *x = Node->x; 00213 *y = Node->y; 00214 00215 if (z != NULL) 00216 *z = Node->z; 00217 00218 return (0); 00219 } 00220 00230 int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2) 00231 { 00232 00233 if (Map->level < 2) 00234 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00235 Vect_get_full_name(Map)); 00236 00237 if (n1 != NULL) 00238 *n1 = Map->plus.Line[line]->N1; 00239 00240 if (n2 != NULL) 00241 *n2 = Map->plus.Line[line]->N2; 00242 00243 return 1; 00244 } 00245 00255 int Vect_get_line_areas(struct Map_info *Map, int line, int *left, int *right) 00256 { 00257 00258 if (Map->level < 2) 00259 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00260 Vect_get_full_name(Map)); 00261 00262 if (left != NULL) 00263 *left = Map->plus.Line[line]->left; 00264 00265 if (right != NULL) 00266 *right = Map->plus.Line[line]->right; 00267 00268 return 1; 00269 } 00270 00279 int Vect_get_node_n_lines(struct Map_info *Map, int node) 00280 { 00281 00282 if (Map->level < 2) 00283 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00284 Vect_get_full_name(Map)); 00285 00286 return (Map->plus.Node[node]->n_lines); 00287 00288 } 00289 00299 int Vect_get_node_line(struct Map_info *Map, int node, int line) 00300 { 00301 if (Map->level < 2) 00302 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00303 Vect_get_full_name(Map)); 00304 00305 return (Map->plus.Node[node]->lines[line]); 00306 } 00307 00317 float Vect_get_node_line_angle(struct Map_info *Map, int node, int line) 00318 { 00319 if (Map->level < 2) 00320 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00321 Vect_get_full_name(Map)); 00322 00323 return (Map->plus.Node[node]->angles[line]); 00324 } 00325 00336 int Vect_get_centroid_area(struct Map_info *Map, int centroid) 00337 { 00338 if (Map->level < 2) 00339 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00340 Vect_get_full_name(Map)); 00341 00342 return (Map->plus.Line[centroid]->left); 00343 }