[GRASS-SVN] r34905 - in grass/branches/develbranch_6: gui/wxpython/gui_modules scripts/d.vect.thematic scripts/v.db.update vector/v.net vector/v.net.iso vector/v.reclass

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 16 07:14:52 EST 2008


Author: martinl
Date: 2008-12-16 07:14:51 -0500 (Tue, 16 Dec 2008)
New Revision: 34905

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/scripts/d.vect.thematic/d.vect.thematic
   grass/branches/develbranch_6/scripts/v.db.update/v.db.update
   grass/branches/develbranch_6/vector/v.net.iso/main.c
   grass/branches/develbranch_6/vector/v.net/main.c
   grass/branches/develbranch_6/vector/v.reclass/main.c
Log:
message standardization, missing gisprompts added


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2008-12-15 23:17:11 UTC (rev 34904)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2008-12-16 12:14:51 UTC (rev 34905)
@@ -420,7 +420,7 @@
     def __init__(self, parent,
                  id=wx.ID_ANY, pos=wx.DefaultPosition,
                  size=globalvar.DIALOG_LAYER_SIZE,
-                 vector=None, choices=[], all=False):
+                 vector=None, choices=[], all=False, default=None):
 
         super(LayerSelect, self).__init__(parent, id, pos=pos, size=size,
                                           choices=choices)
@@ -429,6 +429,9 @@
         
         self.SetName("LayerSelect")
 
+        # default value
+        self.default = default
+            
         if len(choices) > 1:
             return
 
@@ -453,7 +456,10 @@
         else:
             self.SetItems(['1'])
             self.SetStringSelection('1')
-
+        
+        if self.default:
+            self.SetStringSelection(str(self.default))
+        
 class DriverSelect(wx.ComboBox):
     """
     Creates combo box for selecting database driver.

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2008-12-15 23:17:11 UTC (rev 34904)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2008-12-16 12:14:51 UTC (rev 34905)
@@ -1201,13 +1201,14 @@
                                 all = False
                             if p.get('age', 'old_layer') == 'old_layer':
                                 win = gselect.LayerSelect(parent=which_panel,
-                                                          all=all)
+                                                          all=all,
+                                                          default=p['default'])
                                 p['wxGetValue'] = win.GetStringSelection
                                 win.Bind(wx.EVT_CHOICE, self.OnUpdateSelection)
                                 win.Bind(wx.EVT_CHOICE, self.OnSetValue)
                             else:
                                 win = wx.SpinCtrl(parent=which_panel, id=wx.ID_ANY,
-                                                  min=1, max=100, initial=1)
+                                                  min=1, max=100, initial=int(p['default']))
                                 win.Bind(wx.EVT_SPINCTRL, self.OnSetValue)
                                 
                         elif p.get('prompt', '') == 'dbdriver':

Modified: grass/branches/develbranch_6/scripts/d.vect.thematic/d.vect.thematic
===================================================================
--- grass/branches/develbranch_6/scripts/d.vect.thematic/d.vect.thematic	2008-12-15 23:17:11 UTC (rev 34904)
+++ grass/branches/develbranch_6/scripts/d.vect.thematic/d.vect.thematic	2008-12-16 12:14:51 UTC (rev 34905)
@@ -18,34 +18,35 @@
 
 #%Module
 #%  description: Displays thematic vector map
-#%  keywords: display, legend
+#%  keywords: display, vector, thematic, legend
 #%End
 #%option
 #% guisection: Files
 #% key: map
 #% type: string
 #% gisprompt: old,vector,vector
-#% description: Vector map to display thematically
+#% description: Name of vector map
 #% required : yes
 #%end
 #%option
-#% guisection: Theme_prefs
+#% guisection: Theme
 #% key: type
 #% type: string
-#% description: Vector map type
+#% description: Feature type
 #% options: area,point,centroid,line,boundary
 #% answer: area
 #% required : yes
 #%end
 #%option
-#% guisection: Theme_prefs
+#% guisection: Theme
 #% key: column
+#% gisprompt: old_dbcolumn,dbcolumn,dbcolumn
 #% type: string
-#% description: Attribute column to use for thematic display (must be numeric)
+#% description: Name of attribute column to use for thematic display (must be numeric)
 #% required : yes
 #%end
 #%option
-#% guisection: Theme_prefs
+#% guisection: Theme
 #% key: themetype
 #% type: string
 #% options: graduated_colors,graduated_points,graduated_lines
@@ -54,7 +55,7 @@
 #% required : yes
 #%end
 #%option
-#% guisection: Theme_prefs
+#% guisection: Theme
 #% key: themecalc
 #% type: string
 #% options: interval,std_deviation,quartiles,custom_breaks
@@ -63,17 +64,19 @@
 #% required : yes
 #%end
 #%option
-#% guisection: Theme_prefs
+#% guisection: Theme
 #% key: breakpoints
 #% type: string
-#% description: Break points for custom breaks option. Separate values by spaces. (0 10 20 30 ...)
+#% label: Break points for custom breaks option
+#% description: Separate values by spaces (0 10 20 30 ...)
 #% required : no
 #%end
 #%option
-#% guisection: Theme_prefs
+#% guisection: Theme
 #% key: layer
 #% type: integer
-#% description: Layer to use for thematic display
+#% gisprompt: old_layer,layer,layer
+#% description: Layer number
 #% answer: 1
 #% required : no
 #%end
@@ -90,7 +93,8 @@
 #% guisection: Points
 #% key: size
 #% type: double
-#% description: Icon size for point data (minimum icon size/line width for graduated points/lines)
+#% label: Icon size for point data
+#% description: Minimum icon size/line width for graduated points/lines)
 #% answer: 5
 #% required : no
 #%end
@@ -103,7 +107,7 @@
 #% required : no
 #%end
 #%option
-#% guisection: Theme_prefs
+#% guisection: Theme
 #% key: nint
 #% type: integer
 #% description: Number of classes for interval theme (integer)
@@ -114,7 +118,8 @@
 #% guisection: Color
 #% key: colorscheme
 #% type: string
-#% description: Color scheme for graduated color mapping (select 'single_color' for graduated point/line display)
+#% label: Color scheme for graduated color mapping
+#% description: Select 'single_color' for graduated point/line display
 #% options: blue-red,red-blue,green-red,red-green,blue-green,green-blue,cyan-yellow,yellow-cyan,custom_gradient,single_color
 #% answer: blue-red
 #% required : yes
@@ -123,7 +128,8 @@
 #% guisection: Color
 #% key: pointcolor
 #% type: string
-#% description: Color for graduated points map (grass named color or R:G:B triplet). Set color scheme to single color.
+#% label: Color for graduated points map
+#% description: GRASS named color or R:G:B triplet. Set color scheme to single color
 #% answer: 255:0:0
 #% required : no
 #%end
@@ -131,7 +137,8 @@
 #% guisection: Color
 #% key: linecolor
 #% type: string
-#% description: Color for graduated lines or point/area outlines (grass named color or R:G:B triplet). Set color scheme to single color.
+#% label: Color for graduated lines or point/area outlines
+#% description: GRASS named color or R:G:B triplet. Set color scheme to single color.
 #% answer: 0:0:0
 #% required : no
 #%end
@@ -139,7 +146,8 @@
 #% guisection: Color
 #% key: startcolor
 #% type: string
-#% description: Beginning color for custom color gradient. Must be expressed as R:G:B triplet.
+#% label: Beginning color for custom color gradient
+#% description: Must be expressed as R:G:B triplet
 #% answer: 255:0:0
 #% required : no
 #%end
@@ -147,7 +155,8 @@
 #% guisection: Color
 #% key: endcolor
 #% type: string
-#% description: Ending color for custom color gradient. Must be expressed as R:G:B triplet
+#% label: Ending color for custom color gradient
+#% description: Must be expressed as R:G:B triplet
 #% answer: 0:0:255
 #% required : no
 #%end
@@ -166,7 +175,7 @@
 #%description: Save thematic map commands to group file for GIS Manager
 #%end
 #%option
-#% guisection: Theme_prefs
+#% guisection: Theme
 #% key: where
 #% type: string
 #% description: WHERE conditions of SQL statement without 'where' keyword
@@ -176,7 +185,8 @@
 #% guisection: Files
 #% key: psmap
 #% type: string
-#% description: Root for the name of psmap instruction files to be in current directory (if not set, no psmap instruction files will be created)
+#% label: Root for the name of psmap instruction files to be in current directory
+#% description: If not set, no psmap instruction files will be created)
 #% required : no
 #%end
 #%option
@@ -188,7 +198,7 @@
 #% required : no
 #%end
 #%flag 
-#% guisection: Theme_prefs
+#% guisection: Theme
 #%key: l
 #%description: Create graphic legend in x11 display monitor
 #%end

Modified: grass/branches/develbranch_6/scripts/v.db.update/v.db.update
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.update/v.db.update	2008-12-15 23:17:11 UTC (rev 34904)
+++ grass/branches/develbranch_6/scripts/v.db.update/v.db.update	2008-12-16 12:14:51 UTC (rev 34905)
@@ -28,6 +28,7 @@
 #%option
 #% key: layer
 #% type: integer
+#% gisprompt: old_layer,layer,layer
 #% description: Layer to which the table to be changed is connected
 #% answer: 1
 #% required : no
@@ -35,6 +36,7 @@
 #%option
 #% key: column
 #% type: string
+#% gisprompt: old_dbcolumn,dbcolumn,dbcolumn
 #% description: Column to update
 #% required : yes
 #%end
@@ -46,6 +48,7 @@
 #%end
 #%option
 #% key: qcolumn
+#% gisprompt: old_dbcolumn,dbcolumn,dbcolumn
 #% type: string
 #% description: Column to query
 #% required : no

Modified: grass/branches/develbranch_6/vector/v.net/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.net/main.c	2008-12-15 23:17:11 UTC (rev 34904)
+++ grass/branches/develbranch_6/vector/v.net/main.c	2008-12-16 12:14:51 UTC (rev 34905)
@@ -9,7 +9,7 @@
  *               
  * PURPOSE:      Network maintenance
  *               
- * COPYRIGHT:    (C) 2001 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2001-2008 by the GRASS Development Team
  *
  *               This program is free software under the 
  *               GNU General Public License (>=v2). 
@@ -45,7 +45,7 @@
 
     module = G_define_module();
     module->keywords = _("vector, networking");
-    module->description = _("Network maintenance.");
+    module->description = _("Performs network maintenance.");
 
     /* Define the options */
     input = G_define_standard_option(G_OPT_V_INPUT);
@@ -78,12 +78,14 @@
 
     afield_opt = G_define_standard_option(G_OPT_V_FIELD);
     afield_opt->key = "alayer";
-    afield_opt->label = _("Arc layer (network)");
+    afield_opt->gisprompt = "new_layer,layer,layer";
+    afield_opt->label = _("Arc layer");
 
     nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
     nfield_opt->key = "nlayer";
     nfield_opt->answer = "2";
-    nfield_opt->label = _("Node layer (points)");
+    nfield_opt->gisprompt = "new_layer,layer,layer";
+    nfield_opt->label = _("Node layer");
 
     thresh_opt = G_define_option();
     thresh_opt->key = "thresh";
@@ -185,7 +187,7 @@
 
 	    narcs = connect_arcs(&In, &Points, &Out, nfield, thresh);
 
-	    G_message(_("%d arcs added to network (nlayer: [%d])"), narcs,
+	    G_message(_("%d arcs added to network (nlayer %d)"), narcs,
 		      nfield);
 
 	    Vect_close(&Points);

Modified: grass/branches/develbranch_6/vector/v.net.iso/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.net.iso/main.c	2008-12-15 23:17:11 UTC (rev 34904)
+++ grass/branches/develbranch_6/vector/v.net.iso/main.c	2008-12-16 12:14:51 UTC (rev 34905)
@@ -7,7 +7,7 @@
  *                
  *  PURPOSE:      Split net to bands between isolines.
  *                
- *  COPYRIGHT:    (C) 2001 by the GRASS Development Team
+ *  COPYRIGHT:    (C) 2001-2008 by the GRASS Development Team
  * 
  *                This program is free software under the 
  *                GNU General Public License (>=v2). 
@@ -69,7 +69,7 @@
     G_gisinit(argv[0]);
 
     module = G_define_module();
-    module->label = _("Split net by cost isolines");
+    module->label = _("Splits net by cost isolines.");
     module->keywords = _("vector, networking");
     module->description =
 	_("Splits net to bands between cost isolines (direction from centre). "
@@ -86,30 +86,24 @@
 
     afield_opt = G_define_standard_option(G_OPT_V_FIELD);
     afield_opt->key = "alayer";
-    afield_opt->description = _("Arc layer");
+    afield_opt->label = _("Arc layer");
 
     nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
     nfield_opt->key = "nlayer";
     nfield_opt->answer = "2";
-    nfield_opt->description = _("Node layer");
+    nfield_opt->label = _("Node layer");
 
-    afcol = G_define_option();
+    afcol = G_define_standard_option(G_OPT_COLUMN);
     afcol->key = "afcolumn";
-    afcol->type = TYPE_STRING;
-    afcol->required = NO;
     afcol->description =
 	_("Arc forward/both direction(s) cost column (number)");
 
-    abcol = G_define_option();
+    abcol = G_define_standard_option(G_OPT_COLUMN);
     abcol->key = "abcolumn";
-    abcol->type = TYPE_STRING;
-    abcol->required = NO;
     abcol->description = _("Arc backward direction cost column (number)");
 
-    ncol = G_define_option();
+    ncol = G_define_standard_option(G_OPT_COLUMN);
     ncol->key = "ncolumn";
-    ncol->type = TYPE_STRING;
-    ncol->required = NO;
     ncol->description = _("Node cost column (number)");
 
     term_opt = G_define_standard_option(G_OPT_V_CATS);
@@ -167,7 +161,7 @@
 	if (iso[niso] <= iso[niso - 1])
 	    G_fatal_error(_("Iso cost: %f less than previous"), iso[niso]);
 
-	G_message(_("Iso cost [%d] : [%f]"), niso, iso[niso]);
+	G_verbose_message(_("Iso cost %d: %f"), niso, iso[niso]);
 	niso++;
 	i++;
     }
@@ -227,7 +221,7 @@
 	}
     }
 
-    G_message(_("Number of centres: [%d] (nlayer: [%d])"), ncentres, nfield);
+    G_message(_("Number of centres: %d (nlayer %d)"), ncentres, nfield);
 
     if (ncentres == 0)
 	G_warning(_("Not enough centres for selected nlayer. Nothing will be allocated."));
@@ -245,14 +239,14 @@
     pnts2 = (ISOPOINT *) G_malloc(apnts2 * sizeof(ISOPOINT));
 
     /* Fill Nodes by neares centre and costs from that centre */
-    G_message(_("Calculating costs from centres..."));
     for (centre = 0; centre < ncentres; centre++) {
-	G_percent(centre, ncentres, 1);
 	node1 = Centers[centre].node;
 	Vect_net_get_node_cost(&Map, node1, &n1cost);
 	G_debug(2, "centre = %d node = %d cat = %d", centre, node1,
 		Centers[centre].cat);
+	G_message(_("Calculating costs from centre %d..."), centre + 1);
 	for (node2 = 1; node2 <= nnodes; node2++) {
+	    G_percent(node2, nnodes, 1);
 	    G_debug(5, "  node1 = %d node2 = %d", node1, node2);
 	    Vect_net_get_node_cost(&Map, node2, &n2cost);
 	    if (n2cost == -1) {
@@ -278,14 +272,16 @@
 	    }
 	}
     }
-    G_percent(1, 1, 1);
 
     /* Write arcs to new map */
     Vect_open_new(&Out, output->answer, Vect_is_3d(&Map));
     Vect_hist_command(&Out);
 
+    G_message("Generating isolines...");
     nlines = Vect_get_num_lines(&Map);
     for (line = 1; line <= nlines; line++) {
+	G_percent(line, nlines, 2);
+	
 	ltype = Vect_read_line(&Map, Points, NULL, line);
 	if (!(ltype & type)) {
 	    continue;

Modified: grass/branches/develbranch_6/vector/v.reclass/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.reclass/main.c	2008-12-15 23:17:11 UTC (rev 34904)
+++ grass/branches/develbranch_6/vector/v.reclass/main.c	2008-12-16 12:14:51 UTC (rev 34905)
@@ -60,7 +60,7 @@
     G_gisinit(argv[0]);
 
     module = G_define_module();
-    module->keywords = _("vector, attribute table");
+    module->keywords = _("vector, reclass, attributes");
     module->description =
 	_("Changes vector category values for an existing vector map "
 	  "according to results of SQL queries or a value in attribute table column.");
@@ -69,23 +69,24 @@
 
     out_opt = G_define_standard_option(G_OPT_V_OUTPUT);
 
-    rules_opt = G_define_standard_option(G_OPT_F_INPUT);
-    rules_opt->key = "rules";
-    rules_opt->required = NO;
-    rules_opt->description = _("Full path to the reclass rule file");
+    type_opt = G_define_standard_option(G_OPT_V_TYPE);
+    type_opt->options = "point,line,boundary,centroid";
+    type_opt->answer = "point,line,boundary,centroid";
+    type_opt->guisection = _("Selection");
 
+    field_opt = G_define_standard_option(G_OPT_V_FIELD);
+    field_opt->guisection = _("Selection");
+
     col_opt = G_define_standard_option(G_OPT_COLUMN);
     col_opt->label =
 	_("The name of the column whose values are to be used as new categories");
     col_opt->description = _("The source for the new key column must be type integer or string");
 
-    type_opt = G_define_standard_option(G_OPT_V_TYPE);
-    type_opt->description = _("Select type");
-    type_opt->options = "point,line,boundary,centroid";
-    type_opt->answer = "point,line,boundary,centroid";
+    rules_opt = G_define_standard_option(G_OPT_F_INPUT);
+    rules_opt->key = "rules";
+    rules_opt->required = NO;
+    rules_opt->description = _("Full path to the reclass rule file");
 
-    field_opt = G_define_standard_option(G_OPT_V_FIELD);
-
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -117,7 +118,8 @@
 
     Fi = Vect_get_field(&In, field);
     if (Fi == NULL)
-	G_fatal_error(_("Unable to get layer info for vector map"));
+      G_fatal_error(_("Database connection not defined for layer %d"),
+		    field);
 
     Driver = db_start_driver_open_database(Fi->driver, Fi->database);
     if (Driver == NULL)
@@ -132,7 +134,8 @@
 	ctype = db_column_Ctype(Driver, Fi->table, col_opt->answer);
 
 	if (ctype == -1) {
-	    G_fatal_error(_("Column <%s> not found"), col_opt->answer);
+	    G_fatal_error(_("Column <%s> not found in table <%s>"),
+			  col_opt->answer, Fi->table);
 	}
 	else if (ctype == DB_C_TYPE_INT) {
 	    nrec =
@@ -173,13 +176,15 @@
 
 	    if (db_open_select_cursor(Driver, &stmt, &cursor, DB_SEQUENTIAL)
 		!= DB_OK)
-		G_fatal_error("Cannot open select cursor: %s",
+		G_fatal_error("Unable to open select cursor: '%s'",
 			      db_get_string(&stmt));
 
 	    nrows = db_get_num_rows(&cursor);
+
 	    G_debug(3, "  %d rows selected", nrows);
 	    if (nrows < 0)
-		G_fatal_error(_("Cannot select records from database"));
+		G_fatal_error(_("No records selected from table <%s>"),
+			      Fi->table);
 
 	    db_CatValArray_alloc(&cvarr, nrows);
 
@@ -210,17 +215,17 @@
 		Vect_close(&Out);
 		db_close_database_shutdown_driver(Driver);
 		db_close_database_shutdown_driver(Driver2);
-		G_fatal_error("Cannot create table: %s",
+		G_fatal_error("Unable to create table: '%s'",
 			      db_get_string(&stmt2));
 	    }
 
-	    if (db_create_index2(Driver2, NewFi->table, "cat") != DB_OK)
-		G_warning(_("Cannot create index"));
+	    if (db_create_index2(Driver2, NewFi->table, NewFi->key) != DB_OK)
+		G_warning(_("Unable to create index for table <%s>, key <%s>"),
+			  NewFi->table, NewFi->key);
 
-	    if (db_grant_on_table
-		(Driver2, NewFi->table, DB_PRIV_SELECT,
-		 DB_GROUP | DB_PUBLIC) != DB_OK) {
-		G_fatal_error(_("Cannot grant privileges on table <%s>"),
+	    if (db_grant_on_table(Driver2, NewFi->table, DB_PRIV_SELECT,
+				  DB_GROUP | DB_PUBLIC) != DB_OK) {
+		G_fatal_error(_("Unable to grant privileges on table <%s>"),
 			      NewFi->table);
 	    }
 
@@ -229,7 +234,8 @@
 	    /* fetch the data */
 	    for (i = 0; i < nrows; i++) {
 		if (db_fetch(&cursor, DB_NEXT, &more) != DB_OK) {
-		    G_fatal_error(_("Cannot fetch data"));
+		    G_fatal_error(_("Unable to fetch data from table <%s>"),
+				  Fi->table);
 		}
 
 		column = db_get_table_column(table, 1);
@@ -419,7 +425,7 @@
     Vect_build(&Out);
     Vect_close(&Out);
 
-    G_message(_("%d features reclassed"), rclelem);
+    G_done_msg(_("%d features reclassed."), rclelem);
 
     exit(EXIT_SUCCESS);
 }



More information about the grass-commit mailing list