[GRASS-SVN] r62144 - grass/trunk/vector/v.out.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 1 08:20:25 PDT 2014


Author: mmetz
Date: 2014-10-01 08:20:25 -0700 (Wed, 01 Oct 2014)
New Revision: 62144

Modified:
   grass/trunk/vector/v.out.ogr/args.c
   grass/trunk/vector/v.out.ogr/main.c
Log:
v.out.ogr: fix append mode

Modified: grass/trunk/vector/v.out.ogr/args.c
===================================================================
--- grass/trunk/vector/v.out.ogr/args.c	2014-10-01 15:06:01 UTC (rev 62143)
+++ grass/trunk/vector/v.out.ogr/args.c	2014-10-01 15:20:25 UTC (rev 62144)
@@ -87,7 +87,8 @@
 
     flags->append = G_define_flag();
     flags->append->key = 'a';
-    flags->append->description = _("Append to existing layer instead of creating new if it exists");
+    flags->append->label = _("Append to existing layer");
+    flags->append->description = _("A new OGR layer is created if it does not exist");
     
     flags->nocat = G_define_flag();
     flags->nocat->key = 's';

Modified: grass/trunk/vector/v.out.ogr/main.c
===================================================================
--- grass/trunk/vector/v.out.ogr/main.c	2014-10-01 15:06:01 UTC (rev 62143)
+++ grass/trunk/vector/v.out.ogr/main.c	2014-10-01 15:20:25 UTC (rev 62144)
@@ -193,6 +193,10 @@
     if (!options.layer->answer) {
 	char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
 
+	if (flags.append->answer)
+	    G_fatal_error(_("Appending to OGR layer requires option '%s'"),
+	                  options.layer->key);
+
 	if (G_name_is_fully_qualified(options.input->answer, xname, xmapset))
 	    options.layer->answer = G_store(xname);
 	else
@@ -459,22 +463,27 @@
     Ogr_driver = OGRGetDriver(drn);
     
     if (flags.append->answer) {
-	G_verbose_message(_("Append existing layer requires "
-			    "opening data source in update mode, forcing '-%c' flag"),
-			  flags.update->key);
-	flags.update->answer = TRUE;
-    }
-    
-    if (flags.update->answer) {
-	G_debug(1, "Update OGR data source");
+	G_debug(1, "Append to OGR layer");
 	Ogr_ds = OGR_Dr_Open(Ogr_driver, options.dsn->answer, TRUE);
+	
+	if (Ogr_ds == NULL) {
+	    G_debug(1, "Create OGR data source");
+	    Ogr_ds = OGR_Dr_CreateDataSource(Ogr_driver, options.dsn->answer,
+					     papszDSCO);
+	}
     }
     else {
-	G_debug(1, "Create OGR data source");
-	Ogr_ds = OGR_Dr_CreateDataSource(Ogr_driver, options.dsn->answer,
-					 papszDSCO);
+	if (flags.update->answer) {
+	    G_debug(1, "Update OGR data source");
+	    Ogr_ds = OGR_Dr_Open(Ogr_driver, options.dsn->answer, TRUE);
+	}
+	else {
+	    G_debug(1, "Create OGR data source");
+	    Ogr_ds = OGR_Dr_CreateDataSource(Ogr_driver, options.dsn->answer,
+					     papszDSCO);
+	}
     }
-    
+	
     CSLDestroy(papszDSCO);
     if (Ogr_ds == NULL)
 	G_fatal_error(_("Unable to open OGR data source '%s'"),



More information about the grass-commit mailing list