|
GRASS Programmer's Manual
6.5.svn(2012)-r51648
|
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 00098 00106 int Vect_get_num_faces(struct Map_info *map) 00107 { 00108 return (map->plus.n_flines); 00109 } 00110 00111 00119 int Vect_get_num_volumes(struct Map_info *map) 00120 { 00121 return (map->plus.n_volumes); 00122 } 00123 00124 00132 int Vect_get_num_islands(struct Map_info *map) 00133 { 00134 return (map->plus.n_isles); 00135 } 00136 00137 00145 int Vect_get_num_holes(struct Map_info *map) 00146 { 00147 return (map->plus.n_holes); 00148 } 00149 00150 00158 int Vect_get_num_dblinks(struct Map_info *map) 00159 { 00160 return (map->dblnk->n_fields); 00161 } 00162 00170 int Vect_get_num_updated_lines(struct Map_info *map) 00171 { 00172 return (map->plus.n_uplines); 00173 } 00174 00183 int Vect_get_updated_line(struct Map_info *map, int idx) 00184 { 00185 return (map->plus.uplines[idx]); 00186 } 00187 00195 int Vect_get_num_updated_nodes(struct Map_info *map) 00196 { 00197 return (map->plus.n_upnodes); 00198 } 00199 00208 int Vect_get_updated_node(struct Map_info *map, int idx) 00209 { 00210 return (map->plus.upnodes[idx]); 00211 } 00212 00222 int 00223 Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y, 00224 double *z) 00225 { 00226 P_NODE *Node; 00227 00228 Node = map->plus.Node[num]; 00229 *x = Node->x; 00230 *y = Node->y; 00231 00232 if (z != NULL) 00233 *z = Node->z; 00234 00235 return (0); 00236 } 00237 00247 int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2) 00248 { 00249 00250 if (Map->level < 2) 00251 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00252 Vect_get_full_name(Map)); 00253 00254 if (n1 != NULL) 00255 *n1 = Map->plus.Line[line]->N1; 00256 00257 if (n2 != NULL) 00258 *n2 = Map->plus.Line[line]->N2; 00259 00260 return 1; 00261 } 00262 00272 int Vect_get_line_areas(struct Map_info *Map, int line, int *left, int *right) 00273 { 00274 00275 if (Map->level < 2) 00276 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00277 Vect_get_full_name(Map)); 00278 00279 if (left != NULL) 00280 *left = Map->plus.Line[line]->left; 00281 00282 if (right != NULL) 00283 *right = Map->plus.Line[line]->right; 00284 00285 return 1; 00286 } 00287 00296 int Vect_get_node_n_lines(struct Map_info *Map, int node) 00297 { 00298 00299 if (Map->level < 2) 00300 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00301 Vect_get_full_name(Map)); 00302 00303 return (Map->plus.Node[node]->n_lines); 00304 00305 } 00306 00316 int Vect_get_node_line(struct Map_info *Map, int node, int line) 00317 { 00318 if (Map->level < 2) 00319 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00320 Vect_get_full_name(Map)); 00321 00322 return (Map->plus.Node[node]->lines[line]); 00323 } 00324 00334 float Vect_get_node_line_angle(struct Map_info *Map, int node, int line) 00335 { 00336 if (Map->level < 2) 00337 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00338 Vect_get_full_name(Map)); 00339 00340 return (Map->plus.Node[node]->angles[line]); 00341 } 00342 00353 int Vect_get_centroid_area(struct Map_info *Map, int centroid) 00354 { 00355 if (Map->level < 2) 00356 G_fatal_error(_("Vector map <%s> is not open on level >= 2"), 00357 Vect_get_full_name(Map)); 00358 00359 return (Map->plus.Line[centroid]->left); 00360 }