[GRASS-SVN] r73665 - grass/branches/releasebranch_7_4/vector/v.select

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 12 01:32:58 PST 2018


Author: mlennert
Date: 2018-11-12 01:32:58 -0800 (Mon, 12 Nov 2018)
New Revision: 73665

Modified:
   grass/branches/releasebranch_7_4/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_4/vector/v.select/main.c
===================================================================
--- grass/branches/releasebranch_7_4/vector/v.select/main.c	2018-11-11 17:44:21 UTC (rev 73664)
+++ grass/branches/releasebranch_7_4/vector/v.select/main.c	2018-11-12 09:32:58 UTC (rev 73665)
@@ -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