GRASS Programmer's Manual  6.4.4(2014)-r
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 
105 int Vect_get_num_faces(struct Map_info *map)
106 {
107  return (map->plus.n_flines);
108 }
109 
117 int Vect_get_num_volumes(struct Map_info *map)
118 {
119  return (map->plus.n_volumes);
120 }
121 
129 int Vect_get_num_islands(struct Map_info *map)
130 {
131  return (map->plus.n_isles);
132 }
133 
141 int Vect_get_num_dblinks(struct Map_info *map)
142 {
143  return (map->dblnk->n_fields);
144 }
145 
153 int Vect_get_num_updated_lines(struct Map_info *map)
154 {
155  return (map->plus.n_uplines);
156 }
157 
166 int Vect_get_updated_line(struct Map_info *map, int idx)
167 {
168  return (map->plus.uplines[idx]);
169 }
170 
178 int Vect_get_num_updated_nodes(struct Map_info *map)
179 {
180  return (map->plus.n_upnodes);
181 }
182 
191 int Vect_get_updated_node(struct Map_info *map, int idx)
192 {
193  return (map->plus.upnodes[idx]);
194 }
195 
205 int
206 Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y,
207  double *z)
208 {
209  P_NODE *Node;
210 
211  Node = map->plus.Node[num];
212  *x = Node->x;
213  *y = Node->y;
214 
215  if (z != NULL)
216  *z = Node->z;
217 
218  return (0);
219 }
220 
230 int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2)
231 {
232 
233  if (Map->level < 2)
234  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
235  Vect_get_full_name(Map));
236 
237  if (n1 != NULL)
238  *n1 = Map->plus.Line[line]->N1;
239 
240  if (n2 != NULL)
241  *n2 = Map->plus.Line[line]->N2;
242 
243  return 1;
244 }
245 
255 int Vect_get_line_areas(struct Map_info *Map, int line, int *left, int *right)
256 {
257 
258  if (Map->level < 2)
259  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
260  Vect_get_full_name(Map));
261 
262  if (left != NULL)
263  *left = Map->plus.Line[line]->left;
264 
265  if (right != NULL)
266  *right = Map->plus.Line[line]->right;
267 
268  return 1;
269 }
270 
279 int Vect_get_node_n_lines(struct Map_info *Map, int node)
280 {
281 
282  if (Map->level < 2)
283  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
284  Vect_get_full_name(Map));
285 
286  return (Map->plus.Node[node]->n_lines);
287 
288 }
289 
299 int Vect_get_node_line(struct Map_info *Map, int node, int line)
300 {
301  if (Map->level < 2)
302  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
303  Vect_get_full_name(Map));
304 
305  return (Map->plus.Node[node]->lines[line]);
306 }
307 
317 float Vect_get_node_line_angle(struct Map_info *Map, int node, int line)
318 {
319  if (Map->level < 2)
320  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
321  Vect_get_full_name(Map));
322 
323  return (Map->plus.Node[node]->angles[line]);
324 }
325 
336 int Vect_get_centroid_area(struct Map_info *Map, int centroid)
337 {
338  if (Map->level < 2)
339  G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
340  Vect_get_full_name(Map));
341 
342  return (Map->plus.Line[centroid]->left);
343 }
int Vect_get_node_line(struct Map_info *Map, int node, int line)
Get line id for node line index.
Definition: level_two.c:299
#define NULL
Definition: strings.c:26
int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2)
Get line nodes.
Definition: level_two.c:230
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:255
Definition: index.h:56
int Vect_get_updated_node(struct Map_info *map, int idx)
Get updated node by index.
Definition: level_two.c:191
int Vect_get_num_updated_lines(struct Map_info *map)
Get number of updated features.
Definition: level_two.c:153
int Vect_get_num_areas(struct Map_info *map)
Get number of areas in vector map.
Definition: level_two.c:81
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:141
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:166
int Vect_get_num_updated_nodes(struct Map_info *map)
Get number of updated nodes.
Definition: level_two.c:178
int Vect_get_num_faces(struct Map_info *map)
Get number of faces in vector map.
Definition: level_two.c:105
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:1300
int Vect_get_num_volumes(struct Map_info *map)
Fetch number of volumes in vector map.
Definition: level_two.c:117
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:317
int Vect_get_centroid_area(struct Map_info *Map, int centroid)
Get area id the centroid is within.
Definition: level_two.c:336
int Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y, double *z)
Get node coordinates.
Definition: level_two.c:206
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:129
int Vect_get_node_n_lines(struct Map_info *Map, int node)
Get number of lines for node.
Definition: level_two.c:279