Sfoglia il codice sorgente

v.select: Output map should only be created if any elements are found

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73652 15284696-431f-4ddb-bdfa-cd5b030d7da7
Moritz Lennert 6 anni fa
parent
commit
86adbb3574
1 ha cambiato i file con 10 aggiunte e 11 eliminazioni
  1. 10 11
      vector/v.select/main.c

+ 10 - 11
vector/v.select/main.c

@@ -118,17 +118,6 @@ int main(int argc, char *argv[])
     /* 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,6 +144,16 @@ int main(int argc, char *argv[])
 
 
     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;