[GRASS-SVN] r52078 - grass/trunk/vector/v.in.db

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 15 08:11:35 PDT 2012


Author: mlennert
Date: 2012-06-15 08:11:34 -0700 (Fri, 15 Jun 2012)
New Revision: 52078

Modified:
   grass/trunk/vector/v.in.db/main.c
Log:
add flag to allow reusing imported table as attribute table


Modified: grass/trunk/vector/v.in.db/main.c
===================================================================
--- grass/trunk/vector/v.in.db/main.c	2012-06-15 14:42:42 UTC (rev 52077)
+++ grass/trunk/vector/v.in.db/main.c	2012-06-15 15:11:34 UTC (rev 52078)
@@ -34,6 +34,7 @@
     struct Option *driver_opt, *database_opt, *table_opt;
     struct Option *xcol_opt, *ycol_opt, *zcol_opt, *keycol_opt, *where_opt,
 	*outvect;
+    struct Flag *same_table_flag;
     struct GModule *module;
     struct Map_info Map;
     struct line_pnts *Points;
@@ -93,6 +94,11 @@
 
     outvect = G_define_standard_option(G_OPT_V_OUTPUT);
 
+    same_table_flag = G_define_flag();
+    same_table_flag->key = 't';
+    same_table_flag->guisection = _("Connection");
+    same_table_flag->description = _("Use imported table as attribute table for new map");
+
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -213,7 +219,8 @@
 
     /* Copy table */
     G_message(_("Copying attributes..."));
-    if (where_opt->answer)
+    if (!same_table_flag->answer) {
+        if (where_opt->answer)
 	ret =
 	    db_copy_table_where(driver_opt->answer, database_opt->answer,
 				table_opt->answer, fi->driver, fi->database,
@@ -223,7 +230,6 @@
 	    db_copy_table(driver_opt->answer, database_opt->answer,
 			  table_opt->answer, fi->driver, fi->database,
 			  fi->table);
-
     if (ret == DB_FAILED) {
 	G_warning(_("Unable to copy table"));
     }
@@ -231,6 +237,9 @@
 	Vect_map_add_dblink(&Map, 1, NULL, fi->table, keycol_opt->answer,
 			    fi->database, fi->driver);
     }
+    } else {
+        Vect_map_add_dblink(&Map, 1, NULL, table_opt->answer, keycol_opt->answer, database_opt->answer, driver_opt->answer);
+    }
 
     Vect_build(&Map);
     Vect_close(&Map);



More information about the grass-commit mailing list