[GRASS-dev] [GRASS GIS] #3270: v.out.ogr: Append mode broken in G 7.2.1svn and 7.3
GRASS GIS
trac at osgeo.org
Wed Feb 8 01:42:01 PST 2017
#3270: v.out.ogr: Append mode broken in G 7.2.1svn and 7.3
--------------------------+---------------------------------
Reporter: sbl | Owner: martinl
Type: defect | Status: assigned
Priority: normal | Milestone: 7.2.1
Component: Vector | Version: svn-releasebranch72
Resolution: | Keywords: v.out.ogr
CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Comment (by mlennert):
Replying to [comment:4 martinl]:
> Should be solved in r70500. It changes API a bit, the `Flag` structure
has new attribute - `suppress_overwrite`. For relb72 we have two options:
>
> a) backport (API change)
> b) revert r70204.
>
> I would vote for a) since GUI dialog is quite unusable since you need to
write path to output file by hand. Any opinion?
I wouldn't call it unusable (many of use have used it in that form for
years), just not very user-friendly. ;-)
IIUC, this is not a change of the user-visible API, but of the internal
API, or ? Then I don't have an issue with that.
However, (without having looked into this in detail) why can't this "just"
be directly dealt with within v.out.ogr main.c ?
Wouldn't something like this do the job ? :
{{{
Index: main.c
===================================================================
--- main.c (révision 70501)
+++ main.c (copie de travail)
@@ -488,23 +488,25 @@
/* check if OGR layer exists */
overwrite = G_check_overwrite(argc, argv);
found = FALSE;
- for (i = 0; i < OGR_DS_GetLayerCount(Ogr_ds); i++) {
- Ogr_layer = OGR_DS_GetLayer(Ogr_ds, i);
- Ogr_field = OGR_L_GetLayerDefn(Ogr_layer);
- if (G_strcasecmp(OGR_FD_GetName(Ogr_field),
options.layer->answer))
- continue;
-
- found = TRUE;
- if (!overwrite && !flags.append->answer) {
- G_fatal_error(_("Layer <%s> already exists in OGR data source
'%s'"),
- options.layer->answer, options.dsn->answer);
+ if (!flags.append->answer) {
+ for (i = 0; i < OGR_DS_GetLayerCount(Ogr_ds); i++) {
+ Ogr_layer = OGR_DS_GetLayer(Ogr_ds, i);
+ Ogr_field = OGR_L_GetLayerDefn(Ogr_layer);
+ if (G_strcasecmp(OGR_FD_GetName(Ogr_field),
options.layer->answer))
+ continue;
+
+ found = TRUE;
+ if (!overwrite) {
+ G_fatal_error(_("Layer <%s> already exists in OGR data
source '%s'"),
+ options.layer->answer, options.dsn->answer);
+ }
+ else if (overwrite) {
+ G_warning(_("OGR layer <%s> already exists and will be
overwritten"),
+ options.layer->answer);
+ OGR_DS_DeleteLayer(Ogr_ds, i);
+ break;
+ }
}
- else if (overwrite) {
- G_warning(_("OGR layer <%s> already exists and will be
overwritten"),
- options.layer->answer);
- OGR_DS_DeleteLayer(Ogr_ds, i);
- break;
- }
}
if (flags.append->answer && !found) {
G_warning(_("OGR layer <%s> doesn't exists, "
}}}
since we don't need to worry about overwriting at all when we are in
append mode, or ?
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3270#comment:5>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list