Browse Source

Add a flag to skip to copy the attribute tables

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58202 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 11 years ago
parent
commit
8c8f06c3f0
1 changed files with 18 additions and 11 deletions
  1. 18 11
      vector/v.category/main.c

+ 18 - 11
vector/v.category/main.c

@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
     struct GModule *module;
     struct Option *in_opt, *out_opt, *option_opt, *type_opt;
     struct Option *cat_opt, *field_opt, *step_opt, *id_opt;
-    struct Flag *shell;
+    struct Flag *shell, *nodb;
     FREPORT **freps;
     int nfreps, rtype, fld;
     char *desc;
@@ -137,6 +137,11 @@ int main(int argc, char *argv[])
     shell->key = 'g';
     shell->label = _("Shell script style, currently only for report");
     shell->description = _("Format: layer type count min max");
+    
+    nodb = G_define_flag();
+    nodb->key = 'n';
+    nodb->label = _("Avoid to copy the attribute table");
+    nodb->description = _("Avoid to copy the attribute table in the database");
 
     G_gisinit(argv[0]);
 
@@ -757,19 +762,21 @@ int main(int argc, char *argv[])
     }
 
     if (option == O_ADD || option == O_DEL || option == O_CHFIELD ||
-	option == O_SUM || option == O_TRANS) {
-	G_message(_("Copying attribute table(s)..."));
-        if (Vect_copy_tables(&In, &Out, 0))
-            G_warning(_("Failed to copy attribute table to output map"));
+        option == O_SUM || option == O_TRANS){
+        if (!nodb->answer){
+	    G_message(_("Copying attribute table(s)..."));
+            if (Vect_copy_tables(&In, &Out, 0))
+                G_warning(_("Failed to copy attribute table to output map"));
+	}
 	Vect_build(&Out);
 	Vect_close(&Out);
-
-	if (option == O_TRANS && nmodified > 0)
-	    for(i = 1; i < nfields; i++)
-		G_important_message(_("Categories copied from layer %d to layer %d"),
-				fields[0], fields[i]);
-	G_done_msg(_("%d features modified."), nmodified);
     }
+
+    if (option == O_TRANS && nmodified > 0)
+        for(i = 1; i < nfields; i++)
+	    G_important_message(_("Categories copied from layer %d to layer %d"),
+		                  fields[0], fields[i]);
+    G_done_msg(_("%d features modified."), nmodified);
     Vect_close(&In);
 
     exit(EXIT_SUCCESS);