read.c

Go to the documentation of this file.
00001 /*
00002 ****************************************************************************
00003 *
00004 * MODULE:       Vector library 
00005 *               
00006 * AUTHOR(S):    Original author CERL, probably Dave Gerdes or Mike Higgins.
00007 *               Update to GRASS 5.7 Radim Blazek and David D. Gray.
00008 *
00009 * PURPOSE:      Higher level functions for reading/writing/manipulating vectors.
00010 *
00011 * COPYRIGHT:    (C) 2001 by the GRASS Development Team
00012 *
00013 *               This program is free software under the GNU General Public
00014 *               License (>=v2). Read the file COPYING that comes with GRASS
00015 *               for details.
00016 *
00017 *****************************************************************************/
00018 #include <grass/Vect.h>
00019 
00020 
00021 static int read_next_dummy () { return -1; }
00022 
00023 #ifndef HAVE_OGR
00024 static int format () { G_fatal_error ("Requested format is not compiled in this version"); return 0; }
00025 #endif
00026 
00027 static int (*Read_next_line_array[][3]) () =
00028 {
00029     { read_next_dummy, V1_read_next_line_nat, V2_read_next_line_nat }
00030 #ifdef HAVE_OGR
00031    ,{ read_next_dummy, V1_read_next_line_ogr, V2_read_next_line_ogr }
00032 #else
00033    ,{ read_next_dummy, format, format }
00034 #endif
00035 };
00036 
00037 static int (*V2_read_line_array[]) () =
00038 {
00039    V2_read_line_nat 
00040 #ifdef HAVE_OGR
00041    , V2_read_line_ogr
00042 #else
00043    , format
00044 #endif
00045 };
00046 
00057 int
00058 Vect_read_next_line (
00059     struct Map_info *Map,
00060     struct line_pnts *line_p,
00061     struct line_cats *line_c)
00062 {
00063 #ifdef GDEBUG
00064     G_debug (3, "Vect_read_next_line()");
00065 #endif    
00066   
00067     if (!VECT_OPEN (Map))
00068         return -1;
00069 
00070     return (*Read_next_line_array[Map->format][Map->level]) (Map, line_p, line_c);
00071 }
00072 
00084 int
00085 Vect_read_line (
00086                 struct Map_info *Map,
00087                 struct line_pnts *line_p,
00088                 struct line_cats *line_c,
00089                 int    line)
00090 {
00091 
00092     G_debug (3, "Vect_read_line()");
00093   
00094     if (!VECT_OPEN (Map))
00095         G_fatal_error ( "Vect_read_line(): vector is not opened" );
00096 
00097     if (line < 1 || line > Map->plus.n_lines)
00098         G_fatal_error ( "Vect_read_line(): line '%d' is not reasonable (max line in map: %d)",
00099                          line, Map->plus.n_lines );
00100     
00101     return (*V2_read_line_array[Map->format]) (Map, line_p, line_c, line);
00102 }
00103 
00110 int
00111 Vect_line_alive ( struct Map_info *Map, int line )
00112 {
00113     if ( Map->plus.Line[line] != NULL ) return 1;
00114     
00115     return 0;
00116 }
00117 
00124 int
00125 Vect_node_alive ( struct Map_info *Map, int node )
00126 {
00127     if ( Map->plus.Node[node] != NULL ) return 1;
00128     
00129     return 0;
00130 }
00131 
00138 int
00139 Vect_area_alive ( struct Map_info *Map, int area )
00140 {
00141     if ( Map->plus.Area[area] != NULL ) return 1;
00142     
00143     return 0;
00144 }
00145 
00152 int
00153 Vect_isle_alive ( struct Map_info *Map, int isle )
00154 {
00155     if ( Map->plus.Isle[isle] != NULL ) return 1;
00156     
00157     return 0;
00158 }
00159 

Generated on Sun Apr 6 17:32:44 2008 for GRASS by  doxygen 1.5.5