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 "Vect.h"
00019 
00020 static int read_next_dummy () { return -1; }
00021 static long last_offset_dummy () { 
00022     G_fatal_error("Vect_last_offset_ not available for this format.");
00023 }
00024 static int format () { G_fatal_error ("Requested format is not compiled in this version"); return 0; }
00025 
00026 static int (*Read_next_line_array[][3]) () =
00027 {
00028     { read_next_dummy, V1_read_next_line_nat, V2_read_next_line_nat }
00029 #ifdef HAVE_OGR
00030    ,{ read_next_dummy, V1_read_next_line_ogr, V2_read_next_line_ogr }
00031 #else
00032    ,{ read_next_dummy, format, format }
00033 #endif
00034 };
00035 
00036 static int (*V2_read_line_array[]) () =
00037 {
00038    V2_read_line_nat 
00039 #ifdef HAVE_OGR
00040    , V2_read_line_ogr
00041 #else
00042    , format
00043 #endif
00044 };
00045 
00056 int
00057 Vect_read_next_line (
00058     struct Map_info *Map,
00059     struct line_pnts *line_p,
00060     struct line_cats *line_c)
00061 {
00062 #ifdef GDEBUG
00063     G_debug (3, "Vect_read_next_line()");
00064 #endif    
00065   
00066     if (!VECT_OPEN (Map))
00067         return -1;
00068 
00069     return (*Read_next_line_array[Map->format][Map->level]) (Map, line_p, line_c);
00070 }
00071 
00083 int
00084 Vect_read_line (
00085                 struct Map_info *Map,
00086                 struct line_pnts *line_p,
00087                 struct line_cats *line_c,
00088                 int    line)
00089 {
00090 
00091     G_debug (3, "Vect_read_line()");
00092   
00093     if (!VECT_OPEN (Map))
00094         G_fatal_error ( "Vect_read_line(): vector is not opened" );
00095 
00096     if (line < 1 || line > Map->plus.n_lines)
00097         G_fatal_error ( "Vect_read_line(): line '%d' is not reasonable (max line in map: %d)",
00098                          line, Map->plus.n_lines );
00099     
00100     return (*V2_read_line_array[Map->format]) (Map, line_p, line_c, line);
00101 }
00102 
00109 int
00110 Vect_line_alive ( struct Map_info *Map, int line )
00111 {
00112     if ( Map->plus.Line[line] != NULL ) return 1;
00113     
00114     return 0;
00115 }
00116 
00123 int
00124 Vect_node_alive ( struct Map_info *Map, int node )
00125 {
00126     if ( Map->plus.Node[node] != NULL ) return 1;
00127     
00128     return 0;
00129 }
00130 
00137 int
00138 Vect_area_alive ( struct Map_info *Map, int area )
00139 {
00140     if ( Map->plus.Area[area] != NULL ) return 1;
00141     
00142     return 0;
00143 }
00144 
00151 int
00152 Vect_isle_alive ( struct Map_info *Map, int isle )
00153 {
00154     if ( Map->plus.Isle[isle] != NULL ) return 1;
00155     
00156     return 0;
00157 }
00158 

Generated on Sat Jul 22 22:05:57 2006 for GRASS by  doxygen 1.4.7