[GRASS-SVN] r34817 - in grass/trunk: raster/r.clump raster/r.surf.idw scripts/r.reclass.area

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 9 11:55:00 EST 2008


Author: martinl
Date: 2008-12-09 11:55:00 -0500 (Tue, 09 Dec 2008)
New Revision: 34817

Modified:
   grass/trunk/raster/r.clump/clump.c
   grass/trunk/raster/r.clump/main.c
   grass/trunk/raster/r.surf.idw/main.c
   grass/trunk/scripts/r.reclass.area/r.reclass.area.py
Log:
message standardization
	(merge from devbr6, r34816)


Modified: grass/trunk/raster/r.clump/clump.c
===================================================================
--- grass/trunk/raster/r.clump/clump.c	2008-12-09 16:43:52 UTC (rev 34816)
+++ grass/trunk/raster/r.clump/clump.c	2008-12-09 16:55:00 UTC (rev 34817)
@@ -18,8 +18,8 @@
 
 #include <time.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
 #include "local_proto.h"
-#include <grass/glocale.h>
 
 #define INCR 1024
 
@@ -95,13 +95,13 @@
 	/* initialize clump labels */
 	label = 0;
 
-	G_message(_("CLUMP PASS %d ... "), pass);
-	fflush(stderr);
+	G_message(_("Pass %d..."), pass);
 	for (row = 0; row < nrows; row++) {
 	    if (G_get_map_row(in_fd, cur_in + 1, row) < 0)
-		G_fatal_error(_("Unable to properly read input raster map"));
-
-	    G_percent(row, nrows, 2);
+		G_fatal_error(_("Unable to read raster map row %d "),
+			      row);
+	    
+	    G_percent(row+1, nrows, 2);
 	    X = 0;
 	    for (col = 1; col <= ncols; col++) {
 		LEFT = X;
@@ -235,7 +235,8 @@
 			G_set_null_value(&out_cell[column], 1, CELL_TYPE);
 		}
 		if (G_put_raster_row(out_fd, out_cell, CELL_TYPE) < 0)
-		    G_fatal_error(_("Unable to properly write output raster map"));
+		    G_fatal_error(_("Failed writing raster map row %d"),
+				  row);
 	    }
 
 	    /* switch the buffers so that the current buffer becomes the previous */
@@ -247,9 +248,8 @@
 	    cur_clump = prev_clump;
 	    prev_clump = temp_clump;
 	}
-	G_percent(row, nrows, 2);
+
 	print_time(&cur_time);
-
     }
     return 0;
 }
@@ -269,11 +269,11 @@
     seconds = seconds % 60;
 
     if (hours)
-	G_message("%2d:%02d:%02d", hours, minutes, seconds);
+	G_verbose_message("%2d:%02d:%02d", hours, minutes, seconds);
     else if (minutes)
-	G_message("%d:%02d", minutes, seconds);
+	G_verbose_message("%d:%02d", minutes, seconds);
     else
-	G_message("%d seconds", seconds);
+	G_verbose_message("%d seconds", seconds);
 
     return 0;
 }

Modified: grass/trunk/raster/r.clump/main.c
===================================================================
--- grass/trunk/raster/r.clump/main.c	2008-12-09 16:43:52 UTC (rev 34816)
+++ grass/trunk/raster/r.clump/main.c	2008-12-09 16:55:00 UTC (rev 34817)
@@ -8,7 +8,7 @@
  * PURPOSE:      Recategorizes data in a raster map layer by grouping cells
  *		 that form physically discrete areas into unique categories.
  *
- * COPYRIGHT:    (C) 2006 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2006-2008 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
@@ -19,10 +19,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
 #include "local_proto.h"
-#include <grass/glocale.h>
 
-
 int main(int argc, char *argv[])
 {
     struct Colors colr;
@@ -43,9 +42,9 @@
     /* Define the different options */
 
     module = G_define_module();
-    module->keywords = _("raster");
+    module->keywords = _("raster, statistics, reclass");
     module->description =
-	_("Recategorizes data in a raster map layer by grouping cells "
+	_("Recategorizes data in a raster map by grouping cells "
 	  "that form physically discrete areas into unique categories.");
 
     opt_in = G_define_standard_option(G_OPT_R_INPUT);
@@ -77,7 +76,7 @@
 
     clump(in_fd, out_fd);
 
-    G_message(_("Creating support files..."));
+    G_debug(1, "Creating support files...");
 
     G_close_cell(in_fd);
     G_close_cell(out_fd);
@@ -87,14 +86,15 @@
     if (opt_title->answer != NULL)
 	strcpy(title, opt_title->answer);
     else
-	sprintf(title, "clump of %s", name);
-
+	sprintf(title, "clump of <%s@%s>", name, mapset);
+    
     G_put_cell_title(OUTPUT, title);
     G_read_range(OUTPUT, G_mapset(), &range);
     G_get_range_min_max(&range, &min, &max);
     G_make_random_colors(&colr, min, max);
     G_write_colors(OUTPUT, G_mapset(), &colr);
 
-    G_message(_("%d clumps"), range.max);
+    G_done_msg(_("%d clumps."), range.max);
+
     exit(EXIT_SUCCESS);
 }

Modified: grass/trunk/raster/r.surf.idw/main.c
===================================================================
--- grass/trunk/raster/r.surf.idw/main.c	2008-12-09 16:43:52 UTC (rev 34816)
+++ grass/trunk/raster/r.surf.idw/main.c	2008-12-09 16:55:00 UTC (rev 34817)
@@ -13,7 +13,7 @@
  *               Radim Blazek <radim.blazek gmail.com>
  * PURPOSE:      spatial interpolation based on distance squared weighting of 
  *               the values of nearest irregularly spaced data points
- * COPYRIGHT:    (C) 1999-2007 by the GRASS Development Team
+ * COPYRIGHT:    (C) 1999-2008 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
@@ -36,7 +36,6 @@
 #include <math.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
-
 #include "main.h"
 
 struct Cell_head window;
@@ -100,9 +99,9 @@
     G_gisinit(argv[0]);
 
     module = G_define_module();
-    module->keywords = _("raster");
+    module->keywords = _("raster, interpolation");
     module->description =
-	_("Surface interpolation utility for raster map layers.");
+	_("Surface interpolation utility for raster map.");
 
     parm.input = G_define_standard_option(G_OPT_R_INPUT);
 
@@ -123,7 +122,7 @@
 	exit(EXIT_FAILURE);
 
     if (sscanf(parm.npoints->answer, "%d", &n) != 1 || n <= 0)
-	G_fatal_error(_("%s=%s - illegal value"), parm.npoints->key,
+	G_fatal_error(_("Illegal value for '%s' (%s)"), parm.npoints->key,
 		      parm.npoints->answer);
 
     npoints = n;
@@ -184,7 +183,8 @@
     G_command_history(&history);
     G_write_history(output, &history);
 
-    G_done_msg("");
+    G_done_msg(" ");
+    
     exit(EXIT_SUCCESS);
 }
 
@@ -252,11 +252,11 @@
     nbr_head->searchptr = &(nbr_head->Mptr);	/* see replace_neighbor */
 #endif
 
-    G_message(_("Interpolating raster map <%s>... %d rows... "), output,
+    G_message(_("Interpolating raster map <%s> (%d rows)..."), output,
 	      nrows);
 
     for (row = 0; row < nrows; row++) {	/*  loop over rows      */
-	G_percent(row, nrows, 2);
+	G_percent(row+1, nrows, 2);
 
 	/* if mask occurs, read current row of the mask */
 	if (mask && G_get_map_row(maskfd, mask, row) < 0)
@@ -704,12 +704,13 @@
 
     /* enter data by allocation of individual matrix elements */
     *npts = 0;
-    fprintf(stderr, "Reading %s...", input);
+    G_message(_("Reading raster map <%s>..."), input);
 
     for (row = 0, Rptr = rowlist; row < rows; row++) {
-	G_percent(row, rows, 1);
+	G_percent(row+1, rows, 2);
 	if (G_get_map_row_nomask(fd, cell, row) < 0)
-	    G_fatal_error(_("Cannot read row"));
+	    G_fatal_error(_("Unable to read raster map row %d"),
+			  row);
 
 	for (col = 0; col < cols; col++) {
 	    if (cell[col] != 0) {
@@ -728,7 +729,7 @@
 	if (Rptr->prior != Rptr)	/* non-zero input data in this row */
 	    Rptr++->y = row;
     }				/* loop over rows */
-    G_percent(row, rows, 1);
+    
     endlist = Rptr;		/* point to element after last valid row list dummy */
 
     /* add final link to complete doubly-linked lists */

Modified: grass/trunk/scripts/r.reclass.area/r.reclass.area.py
===================================================================
--- grass/trunk/scripts/r.reclass.area/r.reclass.area.py	2008-12-09 16:43:52 UTC (rev 34816)
+++ grass/trunk/scripts/r.reclass.area/r.reclass.area.py	2008-12-09 16:55:00 UTC (rev 34817)
@@ -21,33 +21,36 @@
 # 1998 from NRCS, slightly modified for GRASS 4.2.1
 
 #%Module
-#%  description: Reclasses a raster map greater or less than user specified area size (in hectares)
+#%  description: Reclasses a raster map greater or less than user specified area size (in hectares).
 #%  keywords: raster, statistics, aggregation
 #%End
+
 #%option
 #% key: input
 #% type: string
 #% gisprompt: old,cell,raster
-#% description: raster input map
+#% description: Name of input raster map
 #% required : yes
 #%END
+
 #%option
+#% key: output
+#% type: string
+#% gisprompt: new,cell,raster
+#% description: Name for output raster map
+#% required : yes
+#%END
+
+#%option
 #% key: lesser
 #% type: double
-#% description: lesser val option that sets the <= area size limit [hectares]
+#% description: Lesser value option that sets the <= area size limit [hectares]
 #%END
 #%option
 #% key: greater
 #% type: double
-#% description: greater val option that sets the >= area size limit [hectares]
+#% description: Greater value option that sets the >= area size limit [hectares]
 #%END
-#%option
-#% key: output
-#% type: string
-#% gisprompt: new,cell,raster
-#% description: reclass raster output map
-#% required : yes
-#%END
 
 import sys
 import os
@@ -63,11 +66,11 @@
     kv = grass.parse_key_val(s, sep = ':')
     s = kv['projection'].strip().split()
     if s == '0':
-	grass.fatal("xy-locations are not supported.")
-	grass.fatal("Need projected data with grids in meters.")
+	grass.fatal("xy-locations are not supported")
+	grass.fatal("Need projected data with grids in meters")
 
     if not lesser and not greater:
-	grass.fatal("you have to specify either lesser= or greater=")
+	grass.fatal("You have to specify either lesser= or greater=")
     if lesser and greater:
 	grass.fatal("lesser= and greater= are mutually exclusive")
     if lesser:
@@ -76,21 +79,21 @@
 	limit = float(greater)
 
     if not grass.find_file(infile)['name']:
-	grass.fatal("Raster map <%s> does not exist." % infile)
+	grass.fatal("Raster map <%s> not found" % infile)
 
     clumpfile = "%s.clump.%s" % (infile.split('@')[0], outfile)
 
     if not grass.overwrite():
 	if grass.find_file(clumpfile)['name']:
-	    grass.fatal("Temporary raster map <%s> exists." % clumpfile)
+	    grass.fatal("Temporary raster map <%s> exists" % clumpfile)
 
     grass.message("Generating a clumped raster file ...")
     grass.run_command('r.clump', input = infile, output = clumpfile)
 
     if lesser:
-	grass.message("Generating a reclass map with area size less than or equal to %f hectares" % limit)
+	grass.message("Generating a reclass map with area size less than or equal to %f hectares..." % limit)
     else:
-	grass.message("Generating a reclass map with area size greater than or equal to %f hectares" % limit)
+	grass.message("Generating a reclass map with area size greater than or equal to %f hectares..." % limit)
 
     recfile = outfile + '.recl'
 
@@ -111,7 +114,7 @@
     p2.stdin.close()
     p2.wait()
 
-    grass.message("Written: %s" % outfile)
+    grass.message("Generating output raster map <$outfile>..." % outfile)
 
     grass.mapcalc("$outfile = $recfile", outfile = outfile, recfile = recfile)
     grass.run_command('g.remove', rast = [recfile, clumpfile], quiet = True)



More information about the grass-commit mailing list