00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <grass/gis.h>
00019 #include <grass/glocale.h>
00020 #include <grass/Vect.h>
00021
00022 static long write_dummy () {
00023 G_warning ( _("Vect_write_line() for this format/level not supported") );
00024 return -1;
00025 }
00026 static int rewrite_dummy () {
00027 G_warning ( _("Vect_rewrite_line() for this format/level not supported") );
00028 return -1;
00029 }
00030 static int delete_dummy () {
00031 G_warning ( _("Vect_delete_line() for this format/level not supported") );
00032 return -1;
00033 }
00034
00035 #ifndef HAVE_OGR
00036 static int format () { G_fatal_error ( _("Requested format is not compiled in this version") ); return 0; }
00037 #endif
00038
00039 static long (*Write_line_array[][3]) () =
00040 {
00041 { write_dummy, V1_write_line_nat, V2_write_line_nat }
00042 #ifdef HAVE_OGR
00043 ,{ write_dummy, write_dummy, write_dummy }
00044 #else
00045 ,{ write_dummy, format, format }
00046 #endif
00047 };
00048
00049 static int (*Vect_rewrite_line_array[][3]) () =
00050 {
00051 { rewrite_dummy, rewrite_dummy, V2_rewrite_line_nat }
00052 #ifdef HAVE_OGR
00053 ,{ rewrite_dummy, rewrite_dummy, rewrite_dummy }
00054 #else
00055 ,{ rewrite_dummy, format, format }
00056 #endif
00057 };
00058
00059 static int (*Vect_delete_line_array[][3]) () =
00060 {
00061 { delete_dummy, delete_dummy, V2_delete_line_nat }
00062 #ifdef HAVE_OGR
00063 ,{ delete_dummy, delete_dummy, delete_dummy }
00064 #else
00065 ,{ delete_dummy, format, format }
00066 #endif
00067 };
00068
00083 long
00084 Vect_write_line (
00085 struct Map_info *Map,
00086 int type,
00087 struct line_pnts *points,
00088 struct line_cats *cats)
00089 {
00090 long offset;
00091
00092 G_debug (3, "Vect_write_line(): name = %s, format = %d, level = %d",
00093 Map->name, Map->format, Map->level);
00094
00095 if (!VECT_OPEN (Map))
00096 G_fatal_error ( _("Cannot write line, the map is not opened") );
00097
00098 dig_line_reset_updated ( &(Map->plus) );
00099 dig_node_reset_updated ( &(Map->plus) );
00100 if ( !(Map->plus.update_cidx) ) {
00101 Map->plus.cidx_up_to_date = 0;
00102 }
00103
00104 offset = (*Write_line_array[Map->format][Map->level]) (Map, type, points, cats);
00105
00106 if ( offset == -1 )
00107 G_fatal_error ( _("Cannot write line (negative offset)") );
00108
00109 return offset;
00110 }
00111
00112
00130 int
00131 Vect_rewrite_line (
00132 struct Map_info *Map,
00133 int line,
00134 int type,
00135 struct line_pnts *points,
00136 struct line_cats *cats)
00137 {
00138 long ret;
00139
00140 G_debug (3, "Vect_rewrite_line(): name = %s", Map->name);
00141
00142 if (!VECT_OPEN (Map))
00143 G_fatal_error ( _("Cannot rewrite line, the map is not opened") );
00144
00145 dig_line_reset_updated ( &(Map->plus) );
00146 dig_node_reset_updated ( &(Map->plus) );
00147 if ( !(Map->plus.update_cidx) ) {
00148 Map->plus.cidx_up_to_date = 0;
00149 }
00150
00151 ret = (*Vect_rewrite_line_array[Map->format][Map->level]) (Map, line, type, points, cats);
00152
00153 if ( ret == -1 )
00154 G_fatal_error ( _("Cannot rewrite line") );
00155
00156 return ret;
00157 }
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00187 int
00188 Vect_delete_line (
00189 struct Map_info *Map,
00190 int line)
00191 {
00192 int ret;
00193
00194 G_debug (3, "Vect_delete_line(): name = %s", Map->name);
00195
00196 if ( Map->level < 2 ) {
00197 G_fatal_error ( _("Cannot delete the line, map '%s' is not opened on level 2"), Map->name );
00198 }
00199
00200 if ( Map->mode != GV_MODE_RW && Map->mode != GV_MODE_WRITE ) {
00201 G_fatal_error ( _("Cannot delete the line, map '%s' is not in opened in 'write' mode"), Map->name );
00202 }
00203
00204 dig_line_reset_updated ( &(Map->plus) );
00205 dig_node_reset_updated ( &(Map->plus) );
00206 if ( !(Map->plus.update_cidx) ) {
00207 Map->plus.cidx_up_to_date = 0;
00208 }
00209
00210 ret = (*Vect_delete_line_array[Map->format][Map->level]) (Map, line);
00211
00212 if ( ret == -1 )
00213 G_fatal_error ( _("Cannot delete line") );
00214
00215 return ret;
00216 }
00217