[GRASS-SVN] r73653 - grass/branches/releasebranch_7_6/vector/v.select

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 7 07:42:54 PST 2018


Author: mlennert
Date: 2018-11-07 07:42:54 -0800 (Wed, 07 Nov 2018)
New Revision: 73653

Modified:
   grass/branches/releasebranch_7_6/vector/v.select/main.c
Log:
v.select: Output map should only be created if any elements are found (backport from trunk r73652)

Modified: grass/branches/releasebranch_7_6/vector/v.select/main.c
===================================================================
--- grass/branches/releasebranch_7_6/vector/v.select/main.c	2018-11-07 15:35:46 UTC (rev 73652)
+++ grass/branches/releasebranch_7_6/vector/v.select/main.c	2018-11-07 15:42:54 UTC (rev 73653)
@@ -118,17 +118,6 @@
     /* Read field info */
     IFi = Vect_get_field(&(In[0]), ifield[0]);
 
-    /* Open output */
-    if (Vect_open_new(&Out, parm.output->answer, Vect_is_3d(&(In[0]))) < 0)
-	G_fatal_error(_("Unable to create vector map <%s>"),
-			parm.output->answer);
-
-    Vect_set_map_name(&Out, _("Output from v.select"));
-    Vect_set_person(&Out, G_whoami());
-    Vect_copy_head_data(&(In[0]), &Out);
-    Vect_hist_copy(&(In[0]), &Out);
-    Vect_hist_command(&Out);
-    
     /* Select features */
 #ifdef HAVE_GEOS
     nfound = select_lines(&(In[0]), itype[0], ifield[0],
@@ -155,7 +144,17 @@
 
 
     if (nfound != 0) {
+        /* Open output */
+        if (Vect_open_new(&Out, parm.output->answer, Vect_is_3d(&(In[0]))) < 0)
+	    G_fatal_error(_("Unable to create vector map <%s>"),
+	    		    parm.output->answer);
 
+        Vect_set_map_name(&Out, _("Output from v.select"));
+        Vect_set_person(&Out, G_whoami());
+        Vect_copy_head_data(&(In[0]), &Out);
+        Vect_hist_copy(&(In[0]), &Out);
+        Vect_hist_command(&Out);
+
 	native = Vect_maptype(&Out) == GV_FORMAT_NATIVE;
 
 	nfields = Vect_cidx_get_num_fields(&(In[0]));



More information about the grass-commit mailing list