GRASS Programmer's Manual  6.4.2(2012)
vector/Vlib/read.c
Go to the documentation of this file.
00001 
00019 #include <grass/Vect.h>
00020 #include <grass/glocale.h>
00021 
00022 static int read_next_dummy()
00023 {
00024     return -1;
00025 }
00026 
00027 #ifndef HAVE_OGR
00028 static int format()
00029 {
00030     G_fatal_error(_("Requested format is not compiled in this version"));
00031     return 0;
00032 }
00033 #endif
00034 
00035 static int (*Read_next_line_array[][3]) () = {
00036     {
00037     read_next_dummy, V1_read_next_line_nat, V2_read_next_line_nat}
00038 #ifdef HAVE_OGR
00039     , {
00040     read_next_dummy, V1_read_next_line_ogr, V2_read_next_line_ogr}
00041 #else
00042     , {
00043     read_next_dummy, format, format}
00044 #endif
00045 };
00046 
00047 static int (*V2_read_line_array[]) () = {
00048     V2_read_line_nat
00049 #ifdef HAVE_OGR
00050         , V2_read_line_ogr
00051 #else
00052         , format
00053 #endif
00054 };
00055 
00067 int Vect_read_next_line(struct Map_info *Map,
00068                         struct line_pnts *line_p, struct line_cats *line_c)
00069 {
00070 
00071     G_debug(3, "Vect_read_next_line()");
00072 
00073     if (!VECT_OPEN(Map))
00074         return -1;
00075 
00076     return (*Read_next_line_array[Map->format][Map->level]) (Map, line_p,
00077                                                              line_c);
00078 }
00079 
00092 int Vect_read_line(struct Map_info *Map,
00093                    struct line_pnts *line_p, struct line_cats *line_c, int line)
00094 {
00095 
00096     G_debug(3, "Vect_read_line()");
00097 
00098     if (!VECT_OPEN(Map))
00099         G_fatal_error("Vect_read_line(): %s", _("vector map is not opened"));
00100 
00101     if (line < 1 || line > Map->plus.n_lines)
00102         G_fatal_error(_("Vect_read_line(): feature id %d is not reasonable "
00103                         "(max features in vector map <%s>: %d)"),
00104                       line, Vect_get_full_name(Map), Map->plus.n_lines);
00105 
00106     return (*V2_read_line_array[Map->format]) (Map, line_p, line_c, line);
00107 }
00108 
00118 int Vect_line_alive(struct Map_info *Map, int line)
00119 {
00120     if (Map->plus.Line[line] != NULL)
00121         return 1;
00122     
00123     return 0;
00124 }
00125 
00135 int Vect_node_alive(struct Map_info *Map, int node)
00136 {
00137     if (Map->plus.Node[node] != NULL)
00138         return 1;
00139 
00140     return 0;
00141 }
00142 
00152 int Vect_area_alive(struct Map_info *Map, int area)
00153 {
00154     if (Map->plus.Area[area] != NULL)
00155         return 1;
00156 
00157     return 0;
00158 }
00159 
00169 int Vect_isle_alive(struct Map_info *Map, int isle)
00170 {
00171     if (Map->plus.Isle[isle] != NULL)
00172         return 1;
00173 
00174     return 0;
00175 }
00176 
00188 long Vect_get_line_offset(const struct Map_info *Map, int line)
00189 {
00190     if (line < 1 || line > Map->plus.n_lines)
00191         return -1;
00192     
00193     if (Map->plus.Line[line] != NULL) {
00194         return Map->plus.Line[line]->offset;
00195     }
00196     
00197     return -1;
00198 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines