GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
level_two.c
Go to the documentation of this file.
1 
17 #include <stdlib.h>
18 #include <grass/gis.h>
19 #include <grass/Vect.h>
20 #include <grass/glocale.h>
21 
29 int Vect_get_num_nodes(struct Map_info *map)
30 {
31  return (map->plus.n_nodes);
32 }
33 
42 int Vect_get_num_primitives(struct Map_info *map, int type)
43 {
44  int num = 0;
45 
46  if (type & GV_POINT)
47  num += map->plus.n_plines;
48  if (type & GV_LINE)
49  num += map->plus.n_llines;
50  if (type & GV_BOUNDARY)
51  num += map->plus.n_blines;
52  if (type & GV_CENTROID)
53  num += map->plus.n_clines;
54  if (type & GV_FACE)
55  num += map->plus.n_flines;
56  if (type & GV_KERNEL)
57  num += map->plus.n_klines;
58 
59  return num;
60 }
61 
69 int Vect_get_num_lines(struct Map_info *map)
70 {
71  return (map->plus.n_lines);
72 }
73 
81 int Vect_get_num_areas(struct Map_info *map)
82 {
83  return (map->plus.n_areas);
84 }
85 
93 int Vect_get_num_kernels(struct Map_info *map)
94 {
95  return (map->plus.n_klines);
96 }
97 
98 
106 int Vect_get_num_faces(struct Map_info *map)
107 {
108  return (map->plus.n_flines);
109 }
110 
111 
119 int Vect_get_num_volumes(struct Map_info *map)
120 {
121  return (map->plus.n_volumes);
122 }
123 
124 
132 int Vect_get_num_islands(struct Map_info *map)
133 {
134  return (map->plus.n_isles);
135 }
136 
137 
145 int Vect_get_num_holes(struct Map_info *map)
146 {
147  return (map->plus.n_holes);
148 }
149 
150 
158 int Vect_get_num_dblinks(struct Map_info *map)
159 {
160  return (map->dblnk->n_fields);
161 }
162 
170 int Vect_get_num_updated_lines(struct Map_info *map)
171 {
172  return (map->plus.n_uplines);
173 }
174 
183 int Vect_get_updated_line(struct Map_info *map, int idx)
184 {
185  return (map->plus.uplines[idx]);
186 }
187 
195 int Vect_get_num_updated_nodes(struct Map_info *map)
196 {
197  return (map->plus.n_upnodes);
198 }
199 
208 int Vect_get_updated_node(struct Map_info *map, int idx)
209 {
210  return (map->plus.upnodes[idx]);
211 }
212 
222 int
223 Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y,
224  double *z)
225 {
226  P_NODE *Node;
227 
228  Node = map->plus.Node[num];
229  *x = Node->x;
230  *y = Node->y;
231 
232  if (z != NULL)
233  *z = Node->z;
234 
235  return (0);
236 }
237 
247 int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2)
248 {
249 
250  if (Map->level < 2)
251  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
252  Vect_get_full_name(Map));
253 
254  if (n1 != NULL)
255  *n1 = Map->plus.Line[line]->N1;
256 
257  if (n2 != NULL)
258  *n2 = Map->plus.Line[line]->N2;
259 
260  return 1;
261 }
262 
272 int Vect_get_line_areas(struct Map_info *Map, int line, int *left, int *right)
273 {
274 
275  if (Map->level < 2)
276  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
277  Vect_get_full_name(Map));
278 
279  if (left != NULL)
280  *left = Map->plus.Line[line]->left;
281 
282  if (right != NULL)
283  *right = Map->plus.Line[line]->right;
284 
285  return 1;
286 }
287 
296 int Vect_get_node_n_lines(struct Map_info *Map, int node)
297 {
298 
299  if (Map->level < 2)
300  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
301  Vect_get_full_name(Map));
302 
303  return (Map->plus.Node[node]->n_lines);
304 
305 }
306 
316 int Vect_get_node_line(struct Map_info *Map, int node, int line)
317 {
318  if (Map->level < 2)
319  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
320  Vect_get_full_name(Map));
321 
322  return (Map->plus.Node[node]->lines[line]);
323 }
324 
334 float Vect_get_node_line_angle(struct Map_info *Map, int node, int line)
335 {
336  if (Map->level < 2)
337  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
338  Vect_get_full_name(Map));
339 
340  return (Map->plus.Node[node]->angles[line]);
341 }
342 
353 int Vect_get_centroid_area(struct Map_info *Map, int centroid)
354 {
355  if (Map->level < 2)
356  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
357  Vect_get_full_name(Map));
358 
359  return (Map->plus.Line[centroid]->left);
360 }
int Vect_get_node_line(struct Map_info *Map, int node, int line)
Get line id for node line index.
Definition: level_two.c:316
int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2)
Get line nodes.
Definition: level_two.c:247
int Vect_get_line_areas(struct Map_info *Map, int line, int *left, int *right)
Get area/isle ids on the left and right.
Definition: level_two.c:272
Definition: index.h:56
long num
Definition: g3dcats.c:93
int Vect_get_updated_node(struct Map_info *map, int idx)
Get updated node by index.
Definition: level_two.c:208
int Vect_get_num_updated_lines(struct Map_info *map)
Get number of updated features.
Definition: level_two.c:170
int Vect_get_num_areas(struct Map_info *map)
Get number of areas in vector map.
Definition: level_two.c:81
int Vect_get_num_holes(struct Map_info *map)
Fetch number of holes in vector map.
Definition: level_two.c:145
int y
Definition: plot.c:34
const char * Vect_get_full_name(struct Map_info *Map)
Get full map name.
int Vect_get_num_dblinks(struct Map_info *map)
Get number of defined dblinks.
Definition: level_two.c:158
int Vect_get_num_primitives(struct Map_info *map, int type)
Get number of primitives in vector map.
Definition: level_two.c:42
int Vect_get_num_kernels(struct Map_info *map)
Fetch number of kernels in vector map.
Definition: level_two.c:93
int Vect_get_updated_line(struct Map_info *map, int idx)
Get updated line by index.
Definition: level_two.c:183
int Vect_get_num_updated_nodes(struct Map_info *map)
Get number of updated nodes.
Definition: level_two.c:195
return NULL
Definition: dbfopen.c:1394
int Vect_get_num_faces(struct Map_info *map)
Get number of faces in vector map.
Definition: level_two.c:106
int Vect_get_num_lines(struct Map_info *map)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
Definition: level_two.c:69
tuple Map
Definition: render.py:1310
int Vect_get_num_volumes(struct Map_info *map)
Fetch number of volumes in vector map.
Definition: level_two.c:119
float Vect_get_node_line_angle(struct Map_info *Map, int node, int line)
Angle of segment of the line connected to the node.
Definition: level_two.c:334
int Vect_get_centroid_area(struct Map_info *Map, int centroid)
Get area id the centroid is within.
Definition: level_two.c:353
int Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y, double *z)
Get node coordinates.
Definition: level_two.c:223
int Vect_get_num_nodes(struct Map_info *map)
Get number of nodes in vector map.
Definition: level_two.c:29
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int Vect_get_num_islands(struct Map_info *map)
Get number of islands in vector map.
Definition: level_two.c:132
int Vect_get_node_n_lines(struct Map_info *Map, int node)
Get number of lines for node.
Definition: level_two.c:296