GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vector/Vlib/read.c
Go to the documentation of this file.
1 
19 #include <grass/Vect.h>
20 #include <grass/glocale.h>
21 
22 static int read_next_dummy()
23 {
24  return -1;
25 }
26 
27 #ifndef HAVE_OGR
28 static int format()
29 {
30  G_fatal_error(_("Requested format is not compiled in this version"));
31  return 0;
32 }
33 #endif
34 
35 static int (*Read_next_line_array[][3]) () = {
36  {
38 #ifdef HAVE_OGR
39  , {
41 #else
42  , {
43  read_next_dummy, format, format}
44 #endif
45 };
46 
47 static int (*V2_read_line_array[]) () = {
49 #ifdef HAVE_OGR
51 #else
52  , format
53 #endif
54 };
55 
67 int Vect_read_next_line(struct Map_info *Map,
68  struct line_pnts *line_p, struct line_cats *line_c)
69 {
70 
71  G_debug(3, "Vect_read_next_line()");
72 
73  if (!VECT_OPEN(Map))
74  return -1;
75 
76  return (*Read_next_line_array[Map->format][Map->level]) (Map, line_p,
77  line_c);
78 }
79 
92 int Vect_read_line(struct Map_info *Map,
93  struct line_pnts *line_p, struct line_cats *line_c, int line)
94 {
95 
96  G_debug(3, "Vect_read_line()");
97 
98  if (!VECT_OPEN(Map))
99  G_fatal_error("Vect_read_line(): %s", _("vector map is not opened"));
100 
101  if (line < 1 || line > Map->plus.n_lines)
102  G_fatal_error(_("Vect_read_line(): feature id %d is not reasonable "
103  "(max features in vector map <%s>: %d)"),
104  line, Vect_get_full_name(Map), Map->plus.n_lines);
105 
106  return (*V2_read_line_array[Map->format]) (Map, line_p, line_c, line);
107 }
108 
118 int Vect_line_alive(struct Map_info *Map, int line)
119 {
120  if (Map->plus.Line[line] != NULL)
121  return 1;
122 
123  return 0;
124 }
125 
135 int Vect_node_alive(struct Map_info *Map, int node)
136 {
137  if (Map->plus.Node[node] != NULL)
138  return 1;
139 
140  return 0;
141 }
142 
152 int Vect_area_alive(struct Map_info *Map, int area)
153 {
154  if (Map->plus.Area[area] != NULL)
155  return 1;
156 
157  return 0;
158 }
159 
169 int Vect_isle_alive(struct Map_info *Map, int isle)
170 {
171  if (Map->plus.Isle[isle] != NULL)
172  return 1;
173 
174  return 0;
175 }
176 
188 long Vect_get_line_offset(const struct Map_info *Map, int line)
189 {
190  if (line < 1 || line > Map->plus.n_lines)
191  return -1;
192 
193  if (Map->plus.Line[line] != NULL) {
194  return Map->plus.Line[line]->offset;
195  }
196 
197  return -1;
198 }
int V1_read_next_line_nat(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Read next line from coor file.
Definition: read_nat.c:68
int Vect_read_next_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Read next vector feature (level 1 and 2)
int V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Read next line from OGR layer.
Definition: read_ogr.c:242
int Vect_node_alive(struct Map_info *Map, int node)
Check if node is alive or dead.
int V2_read_line_nat(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Reads any specified line, this is NOT affected by constraints.
Definition: read_nat.c:124
int V2_read_next_line_nat(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Reads next unread line each time called. Use Vect_rewind to reset.
Definition: read_nat.c:154
int Vect_isle_alive(struct Map_info *Map, int isle)
Check if isle is alive or dead.
const char * Vect_get_full_name(struct Map_info *Map)
Get full map name.
int V2_read_line_ogr(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read line from layer on given offset.
Definition: read_ogr.c:325
int
Definition: g3dcolor.c:48
long Vect_get_line_offset(const struct Map_info *Map, int line)
Get feature offset.
int V1_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c)
Read next line from OGR layer. Skip empty features.
Definition: read_ogr.c:143
int Vect_line_alive(struct Map_info *Map, int line)
Check if feature is alive or dead.
return NULL
Definition: dbfopen.c:1394
tuple Map
Definition: render.py:1310
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
int Vect_area_alive(struct Map_info *Map, int area)
Check if area is alive or dead.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int Vect_read_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read vector feature.