[GRASS-SVN] r38838 - in grass/branches/develbranch_6: gui/tcltk/gis.m vector/v.db.connect

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 23 16:10:20 EDT 2009


Author: marisn
Date: 2009-08-23 16:10:18 -0400 (Sun, 23 Aug 2009)
New Revision: 38838

Modified:
   grass/branches/develbranch_6/gui/tcltk/gis.m/chart.tcl
   grass/branches/develbranch_6/gui/tcltk/gis.m/thematic.tcl
   grass/branches/develbranch_6/gui/tcltk/gis.m/vector.tcl
   grass/branches/develbranch_6/vector/v.db.connect/description.html
   grass/branches/develbranch_6/vector/v.db.connect/main.c
Log:
Workaround to not ignore layer option in v.db.connect print mode

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/chart.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/chart.tcl	2009-08-23 07:08:52 UTC (rev 38837)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/chart.tcl	2009-08-23 20:10:18 UTC (rev 38838)
@@ -155,7 +155,7 @@
 		GmLib::errmsg [G_msg "You must provide valid vector layer number"]
 		return
 	}
-	if ![catch {open "|v.db.connect map=$mapname layer=$layernum -g" r} vdb] {
+	if ![catch {open "|v.db.connect map=$mapname layer=$layernum -g -l" r} vdb] {
 		set vectdb [read $vdb]
 		if {[catch {close $vdb} error]} {
             GmLib::errmsg $error

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/thematic.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/thematic.tcl	2009-08-23 07:08:52 UTC (rev 38837)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/thematic.tcl	2009-08-23 20:10:18 UTC (rev 38838)
@@ -196,7 +196,7 @@
 		GmLib::errmsg [G_msg "You must provide valid vector layer number"]
 		return
 	}
-	if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g" r} vdb]} {
+	if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g -l" r} vdb]} {
 		set vectdb [read $vdb]
 		if {[catch {close $vdb} error]} {
 			GmLib::errmsg $error

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/vector.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/vector.tcl	2009-08-23 07:08:52 UTC (rev 38837)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/vector.tcl	2009-08-23 20:10:18 UTC (rev 38838)
@@ -273,7 +273,7 @@
 		GmLib::errmsg [G_msg "You must provide valid vector layer number"]
 		return
 	}
-	if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g" r} vdb]} {
+	if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g -l" r} vdb]} {
 		set vectdb [read $vdb]
 		if {[catch {close $vdb} error]} {
 			GmLib::errmsg $error

Modified: grass/branches/develbranch_6/vector/v.db.connect/description.html
===================================================================
--- grass/branches/develbranch_6/vector/v.db.connect/description.html	2009-08-23 07:08:52 UTC (rev 38837)
+++ grass/branches/develbranch_6/vector/v.db.connect/description.html	2009-08-23 20:10:18 UTC (rev 38838)
@@ -13,7 +13,7 @@
 <p>
 When printing database connection (<em>p</em> or <em>g</em> flag) the parameter
 <em>layer</em> is ignored, i.e. <b>all</b> connections are printed to the
-output.
+output, unless <em>l</em> flag is given.
 
 <p>
 <b>Attention:</b> Removing a vector map will also delete all tables

Modified: grass/branches/develbranch_6/vector/v.db.connect/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.db.connect/main.c	2009-08-23 07:08:52 UTC (rev 38837)
+++ grass/branches/develbranch_6/vector/v.db.connect/main.c	2009-08-23 20:10:18 UTC (rev 38838)
@@ -33,7 +33,7 @@
     char *input, *mapset;
     struct GModule *module;
     struct Option *inopt, *dbdriver, *dbdatabase, *dbtable, *field_opt,
-	*dbkey, *sep_opt;
+	*dbkey, *sep_opt, *layer_opt;
     struct Flag *overwrite, *print, *columns, *delete, *shell_print;
     dbDriver *driver;
     dbString table_name;
@@ -87,6 +87,11 @@
     shell_print->description =
 	_("Format: layer[/layer name] table key database driver");
 
+    /* This should be changed in GRASS 7. Printing options shouldn't ignore layer=%d option. */
+    layer_opt = G_define_flag();
+    layer_opt->key = 'l';
+    layer_opt->description = _("Use layer option for connection printing");
+
     columns = G_define_flag();
     columns->key = 'c';
     columns->description =
@@ -156,27 +161,31 @@
 		    if ((fi = Vect_get_dblink(&Map, i)) == NULL)
 			G_fatal_error(_("Database connection not defined"));
 
-		    if (shell_print->answer) {
-			const char *sep = sep_opt->answer;
-			if (fi->name) {
-			    fprintf(stdout, "%d/%s%s%s%s%s%s%s%s%s\n",
-				    fi->number, fi->name, sep,
-				    fi->table, sep, fi->key, sep,
-				    fi->database, sep, fi->driver);
+		    if (layer_opt->answer && fi->number == field) {
+			if (shell_print->answer) {
+			    const char *sep = sep_opt->answer;
+
+			    if (fi->name) {
+				fprintf(stdout, "%d/%s%s%s%s%s%s%s%s%s\n",
+					fi->number, fi->name, sep,
+					fi->table, sep, fi->key, sep,
+					fi->database, sep, fi->driver);
+			    }
+			    else {
+				fprintf(stdout, "%d%s%s%s%s%s%s%s%s\n",
+					fi->number, sep,
+					fi->table, sep, fi->key, sep,
+					fi->database, sep, fi->driver);
+			    }
 			}
 			else {
-			    fprintf(stdout, "%d%s%s%s%s%s%s%s%s\n",
-				    fi->number, sep,
-				    fi->table, sep, fi->key, sep,
-				    fi->database, sep, fi->driver);
+			    fprintf(stdout,
+				    _("layer <%d> table <%s> in database <%s> through driver "
+				     "<%s> with key <%s>\n"), fi->number,
+				    fi->table, fi->database, fi->driver,
+				    fi->key);
 			}
 		    }
-		    else {
-			fprintf(stdout,
-				_("layer <%d> table <%s> in database <%s> through driver "
-				 "<%s> with key <%s>\n"), fi->number,
-				fi->table, fi->database, fi->driver, fi->key);
-		    }
 		}
 	    }			/* end print */
 	    else {		/* columns */



More information about the grass-commit mailing list