[GRASS-SVN] r73652 - grass/trunk/vector/v.select

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 7 07:35:47 PST 2018


Author: mlennert
Date: 2018-11-07 07:35:46 -0800 (Wed, 07 Nov 2018)
New Revision: 73652

Modified:
   grass/trunk/vector/v.select/main.c
Log:
v.select: Output map should only be created if any elements are found

Modified: grass/trunk/vector/v.select/main.c
===================================================================
--- grass/trunk/vector/v.select/main.c	2018-11-06 17:07:20 UTC (rev 73651)
+++ grass/trunk/vector/v.select/main.c	2018-11-07 15:35:46 UTC (rev 73652)
@@ -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