00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <grass/gis.h>
00019 #include <grass/Vect.h>
00020 #include <stdlib.h>
00021
00022
00023
00030 int
00031 Vect_get_num_nodes (struct Map_info *map)
00032 {
00033 return (map->plus.n_nodes);
00034 }
00035
00042 int
00043 Vect_get_num_primitives (struct Map_info *map, int type)
00044 {
00045 int num = 0;
00046
00047 if ( type & GV_POINT ) num += map->plus.n_plines;
00048 if ( type & GV_LINE ) num += map->plus.n_llines;
00049 if ( type & GV_BOUNDARY ) num += map->plus.n_blines;
00050 if ( type & GV_CENTROID ) num += map->plus.n_clines;
00051 if ( type & GV_FACE ) num += map->plus.n_flines;
00052 if ( type & GV_KERNEL ) num += map->plus.n_klines;
00053
00054 return num;
00055 }
00056
00063 int
00064 Vect_get_num_lines (struct Map_info *map)
00065 {
00066 return (map->plus.n_lines);
00067 }
00068
00075 int
00076 Vect_get_num_areas (struct Map_info *map)
00077 {
00078 return (map->plus.n_areas);
00079 }
00080
00088 int
00089 Vect_get_num_faces (struct Map_info *map)
00090 {
00091 return (map->plus.n_flines);
00092 }
00093
00100 int
00101 Vect_get_num_islands (struct Map_info *map)
00102 {
00103 return (map->plus.n_isles);
00104 }
00105
00112 int
00113 Vect_get_num_dblinks (struct Map_info *map)
00114 {
00115 return (map->dblnk->n_fields);
00116 }
00117
00124 int
00125 Vect_get_num_updated_lines (struct Map_info *map)
00126 {
00127 return (map->plus.n_uplines);
00128 }
00129
00136 int
00137 Vect_get_updated_line (struct Map_info *map, int idx)
00138 {
00139 return (map->plus.uplines[idx]);
00140 }
00141
00148 int
00149 Vect_get_num_updated_nodes (struct Map_info *map)
00150 {
00151 return (map->plus.n_upnodes);
00152 }
00153
00160 int
00161 Vect_get_updated_node (struct Map_info *map, int idx)
00162 {
00163 return (map->plus.upnodes[idx]);
00164 }
00165
00172 int
00173 Vect_get_node_coor (struct Map_info *map, int num, double *x, double *y, double *z)
00174 {
00175 P_NODE *Node;
00176
00177 Node = map->plus.Node[num];
00178 *x = Node->x;
00179 *y = Node->y;
00180
00181 if ( z != NULL )
00182 *z = Node->z;
00183
00184 return (0);
00185 }
00186
00193 int
00194 Vect_get_line_nodes ( struct Map_info *Map, int line, int *n1, int *n2)
00195 {
00196
00197 if ( Map->level < 2 )
00198 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00199
00200 if ( n1 != NULL )
00201 *n1 = Map->plus.Line[line]->N1;
00202
00203 if ( n2 != NULL )
00204 *n2 = Map->plus.Line[line]->N2;
00205
00206 return 1;
00207 }
00208
00215 int
00216 Vect_get_line_areas ( struct Map_info *Map, int line, int *left, int *right)
00217 {
00218
00219 if ( Map->level < 2 )
00220 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00221
00222 if ( left != NULL )
00223 *left = Map->plus.Line[line]->left;
00224
00225 if ( right != NULL )
00226 *right = Map->plus.Line[line]->right;
00227
00228 return 1;
00229 }
00230
00237 int
00238 Vect_get_node_n_lines ( struct Map_info *Map, int node )
00239 {
00240
00241 if ( Map->level < 2 )
00242 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00243
00244 return ( Map->plus.Node[node]->n_lines );
00245
00246 }
00247
00256 int
00257 Vect_get_node_line ( struct Map_info *Map, int node, int line )
00258 {
00259 if ( Map->level < 2 )
00260 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00261
00262 return ( Map->plus.Node[node]->lines[line] );
00263 }
00264
00273 float
00274 Vect_get_node_line_angle ( struct Map_info *Map, int node, int line )
00275 {
00276 if ( Map->level < 2 )
00277 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00278
00279 return ( Map->plus.Node[node]->angles[line] );
00280 }
00281
00288 int
00289 Vect_get_centroid_area ( struct Map_info *Map, int centroid )
00290 {
00291 if ( Map->level < 2 )
00292 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00293
00294 return ( Map->plus.Line[centroid]->left );
00295 }