00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "gis.h"
00019 #include "glocale.h"
00020 #include "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 static int format () { G_fatal_error ( _("Requested format is not compiled in this version") ); return 0; }
00036
00037 static long (*Write_line_array[][3]) () =
00038 {
00039 { write_dummy, V1_write_line_nat, V2_write_line_nat }
00040 #ifdef HAVE_OGR
00041 ,{ write_dummy, write_dummy, write_dummy }
00042 #else
00043 ,{ write_dummy, format, format }
00044 #endif
00045 };
00046
00047 static int (*Vect_rewrite_line_array[][3]) () =
00048 {
00049 { rewrite_dummy, rewrite_dummy, V2_rewrite_line_nat }
00050 #ifdef HAVE_OGR
00051 ,{ rewrite_dummy, rewrite_dummy, rewrite_dummy }
00052 #else
00053 ,{ rewrite_dummy, format, format }
00054 #endif
00055 };
00056
00057 static int (*Vect_delete_line_array[][3]) () =
00058 {
00059 { delete_dummy, delete_dummy, V2_delete_line_nat }
00060 #ifdef HAVE_OGR
00061 ,{ delete_dummy, delete_dummy, delete_dummy }
00062 #else
00063 ,{ delete_dummy, format, format }
00064 #endif
00065 };
00066
00080 long
00081 Vect_write_line (
00082 struct Map_info *Map,
00083 int type,
00084 struct line_pnts *points,
00085 struct line_cats *cats)
00086 {
00087 long offset;
00088
00089 G_debug (3, "Vect_write_line(): name = %s, format = %d, level = %d",
00090 Map->name, Map->format, Map->level);
00091
00092 if (!VECT_OPEN (Map))
00093 G_fatal_error ( _("Cannot write line, the map is not opened") );
00094
00095 dig_line_reset_updated ( &(Map->plus) );
00096 dig_node_reset_updated ( &(Map->plus) );
00097 if ( !(Map->plus.update_cidx) ) {
00098 Map->plus.cidx_up_to_date = 0;
00099 }
00100
00101 offset = (*Write_line_array[Map->format][Map->level]) (Map, type, points, cats);
00102
00103 if ( offset == -1 )
00104 G_fatal_error ( _("Cannot write line") );
00105
00106 return offset;
00107 }
00108
00109
00123 int
00124 Vect_rewrite_line (
00125 struct Map_info *Map,
00126 int line,
00127 int type,
00128 struct line_pnts *points,
00129 struct line_cats *cats)
00130 {
00131 long ret;
00132
00133 G_debug (3, "Vect_rewrite_line(): name = %s", Map->name);
00134
00135 if (!VECT_OPEN (Map))
00136 G_fatal_error ( _("Cannot rewrite line, the map is not opened") );
00137
00138 dig_line_reset_updated ( &(Map->plus) );
00139 dig_node_reset_updated ( &(Map->plus) );
00140 if ( !(Map->plus.update_cidx) ) {
00141 Map->plus.cidx_up_to_date = 0;
00142 }
00143
00144 ret = (*Vect_rewrite_line_array[Map->format][Map->level]) (Map, line, type, points, cats);
00145
00146 if ( ret == -1 )
00147 G_fatal_error ( _("Cannot rewrite line") );
00148
00149 return ret;
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00179 int
00180 Vect_delete_line (
00181 struct Map_info *Map,
00182 int line)
00183 {
00184 int ret;
00185
00186 G_debug (3, "Vect_delete_line(): name = %s", Map->name);
00187
00188 if ( Map->level < 2 ) {
00189 G_fatal_error ( _("Cannot delete the line, map '%s' is not opened on level 2"), Map->name );
00190 }
00191
00192 if ( Map->mode != GV_MODE_RW && Map->mode != GV_MODE_WRITE ) {
00193 G_fatal_error ( _("Cannot delete the line, map '%s' is not in opened in 'write' mode"), Map->name );
00194 }
00195
00196 dig_line_reset_updated ( &(Map->plus) );
00197 dig_node_reset_updated ( &(Map->plus) );
00198 if ( !(Map->plus.update_cidx) ) {
00199 Map->plus.cidx_up_to_date = 0;
00200 }
00201
00202 ret = (*Vect_delete_line_array[Map->format][Map->level]) (Map, line);
00203
00204 if ( ret == -1 )
00205 G_fatal_error ( _("Cannot delete line") );
00206
00207 return ret;
00208 }
00209