[GRASS-SVN] r59398 - grass-addons/grass7/raster/r.stream.distance

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 27 04:24:34 PDT 2014


Author: martinl
Date: 2014-03-27 04:24:34 -0700 (Thu, 27 Mar 2014)
New Revision: 59398

Modified:
   grass-addons/grass7/raster/r.stream.distance/Makefile
   grass-addons/grass7/raster/r.stream.distance/distance_calc.c
   grass-addons/grass7/raster/r.stream.distance/distance_init.c
   grass-addons/grass7/raster/r.stream.distance/io.c
   grass-addons/grass7/raster/r.stream.distance/io.h
   grass-addons/grass7/raster/r.stream.distance/local_proto.h
   grass-addons/grass7/raster/r.stream.distance/local_vars.h
   grass-addons/grass7/raster/r.stream.distance/main.c
Log:
r.stream.distance: more guisection, message correction
                   various minor cosmetics


Modified: grass-addons/grass7/raster/r.stream.distance/Makefile
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/Makefile	2014-03-27 10:46:40 UTC (rev 59397)
+++ grass-addons/grass7/raster/r.stream.distance/Makefile	2014-03-27 11:24:34 UTC (rev 59398)
@@ -8,4 +8,3 @@
 include $(MODULE_TOPDIR)/include/Make/Module.make
 
 default: cmd
-

Modified: grass-addons/grass7/raster/r.stream.distance/distance_calc.c
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/distance_calc.c	2014-03-27 10:46:40 UTC (rev 59397)
+++ grass-addons/grass7/raster/r.stream.distance/distance_calc.c	2014-03-27 11:24:34 UTC (rev 59398)
@@ -4,7 +4,7 @@
 int fifo_insert(POINT point)
 {
     if (fifo_count == fifo_max)
-	G_fatal_error("fifo queue: circular buffer too small");
+        G_fatal_error(_("Circular buffer too small"));
 
     fifo_points[tail++] = point;
     if (tail > fifo_max) {
@@ -410,8 +410,8 @@
 	}
 
     counter = n_inits = k;
-    //return 0; // do usunięcia
-    G_message("Calculate upstream parameters...");
+    /* return 0; */
+    G_message(_("Calculate upstream parameters..."));
     while (n_inits > 0) {
 	k = 0;
 	G_percent((counter - n_inits), counter, 10);
@@ -564,7 +564,7 @@
 
     counter = n_inits = k;
 
-    G_message("Calculate upstream parameters...");
+    G_message(_("Calculate upstream parameters..."));
     while (n_inits > 0) {
 	k = 0;
 	G_percent((counter - n_inits), counter, 10);
@@ -623,6 +623,6 @@
 	}
 	n_inits = k;
     }
-    G_percent((counter - n_inits), counter, 10);
+    G_percent(1, 1, 1);
     return 0;
 }

Modified: grass-addons/grass7/raster/r.stream.distance/distance_init.c
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/distance_init.c	2014-03-27 10:46:40 UTC (rev 59397)
+++ grass-addons/grass7/raster/r.stream.distance/distance_init.c	2014-03-27 11:24:34 UTC (rev 59398)
@@ -19,8 +19,7 @@
 	    if (streams[r][c] > 0) {
 		if (outlets_num > (out_max - 1)) {
 		    if (outlets_num > 4 * (out_max - 1))
-			G_fatal_error
-			    ("Stream and direction maps probably do not match");
+                        G_fatal_error(_("Stream and direction maps probably do not match"));
 		    out_max *= 4;
 		    outlets =
 			(OUTLET *) G_realloc(outlets,
@@ -84,8 +83,7 @@
 	    if (streams_cell > 0) {
 		if (outlets_num > (out_max - 1)) {
 		    if (outlets_num > 4 * (out_max - 1))
-			G_fatal_error
-			    ("Stream and direction maps probably do not match");
+			G_fatal_error(_("Stream and direction maps probably do not match"));
 		    out_max *= 4;
 		    outlets =
 			(OUTLET *) G_realloc(outlets,

Modified: grass-addons/grass7/raster/r.stream.distance/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/io.c	2014-03-27 10:46:40 UTC (rev 59397)
+++ grass-addons/grass7/raster/r.stream.distance/io.c	2014-03-27 11:24:34 UTC (rev 59398)
@@ -14,7 +14,7 @@
     int r;
 
     if (data_type < 0 || data_type > 2)
-	G_fatal_error(_("ram_creat: Cannot create map of unrecognised type"));
+	G_fatal_error(_("Unable to create map of unrecognised type"));
 
     map->data_type = data_type;
     map->map_name = NULL;
@@ -76,10 +76,10 @@
     if (check_res)
 	if (this_window.ew_res != cellhd.ew_res ||
 	    this_window.ns_res != cellhd.ns_res)
-	    G_fatal_error(_("Region resolution and map %s resolution differs. \
-		Run g.region rast=%s to set proper region resolution"),
-			  input_map_name, input_map_name);
-
+          G_fatal_error(_("Region resolution and raster map <%s> resolution differs. "
+                          "Run 'g.region rast=%s' to set proper region resolution."),
+                        input_map_name, input_map_name);
+    
     /* checking if input map is of required type */
     if (check_data_type != map->data_type)
 	G_debug(1,
@@ -87,7 +87,7 @@
     input_data_type = Rast_map_type(input_map_name, mapset);
     if (check_data_type != -1)
 	if (input_data_type != check_data_type)
-	    G_fatal_error(_("<%s> is not of type %s"),
+	    G_fatal_error(_("Raster map <%s> is not of type '%s'"),
 			  input_map_name, maptypes[check_data_type]);
 
     input_map_fd = Rast_open_old(input_map_name, mapset);
@@ -117,7 +117,7 @@
     input_buffer = Rast_allocate_buf(input_data_type);
 
     /* start reading */
-    G_message(_("Reading map <%s>"), input_map_name);
+    G_message(_("Reading raster map <%s>..."), input_map_name);
 
     for (r = 0; r < map->nrows; ++r) {
 	G_percent(r, map->nrows, 2);
@@ -145,7 +145,7 @@
 					 input_data_type);
 		    break;
 		default:
-		    G_fatal_error(_("ram_open:Wrong internal data type"));
+		    G_fatal_error(_("Wrong internal data type"));
 		    break;
 		}
     }				/*end for r */
@@ -192,7 +192,7 @@
 	G_debug(1,
 		"ram_write:required map type and internal map type differs: conversion forced!");
 
-    G_message(_("Writing map <%s>"), output_map_name);
+    G_message(_("Writing raster map <%s>..."), output_map_name);
     output_fd = Rast_open_new(output_map_name, output_data_type);
 
     /* writing */
@@ -218,7 +218,7 @@
 			Rast_set_d_null_value(row + c * (map->data_size), 1);
 		break;
 	    default:
-		G_debug(1, "ram_null:Cannot convert to null at: %d %d", r, c);
+		G_debug(1, "Cannot Cannot convert to null at: %d %d", r, c);
 	    }
 	}
 
@@ -229,7 +229,7 @@
     Rast_short_history(output_map_name, "raster", &history);
     Rast_command_history(&history);
     Rast_write_history(output_map_name, &history);
-    G_message(_("<%s> Done"), output_map_name);
+    /* G_message(_("<%s> Done"), output_map_name); */
     return 0;
 }
 
@@ -294,7 +294,7 @@
 	seg->data_size = sizeof(DCELL);
 	break;
     default:
-	G_fatal_error(_("seg_create: unrecognisabe data type"));
+	G_fatal_error(_("Unrecognisable data type"));
     }
 
     filename = G_tempfile();
@@ -305,18 +305,18 @@
 		       seg->data_size)) {
 	close(fd);
 	unlink(filename);
-	G_fatal_error(_("seg_create: cannot format segment"));
+	G_fatal_error(_("Unable to format segment"));
     }
 
     close(fd);
     if (0 > (fd = open(filename, 2))) {
 	unlink(filename);
-	G_fatal_error(_("seg_create: cannot re-open file"));
+	G_fatal_error(_("Unable to re-open file '%s'"), filename);
     }
 
     if (0 > (fd = segment_init(&(seg->seg), fd, number_of_segs))) {
 	unlink(filename);
-	G_fatal_error(_("seg_create: cannot init segment file or out of memory"));
+	G_fatal_error(_("Unable to init segment file or out of memory"));
     }
 
     seg->filename = G_store(filename);
@@ -351,7 +351,7 @@
     /* checking if map exist */
     mapset = (char *)G_find_raster2(input_map_name, "");
     if (mapset == NULL)
-	G_fatal_error(_("seg_read:Raster map <%s> not found"),
+	G_fatal_error(_("Raster map <%s> not found"),
 		      input_map_name);
     seg->mapset = mapset;
 
@@ -363,17 +363,17 @@
     if (check_res)
 	if (this_window.ew_res != cellhd.ew_res ||
 	    this_window.ns_res != cellhd.ns_res)
-	    G_fatal_error(_("Region resolution and map %s resolution differs. \
-		Run g.region rast=%s to set proper region resolution"),
+	    G_fatal_error(_("Region resolution and raster map <%s> resolution differs. "
+                            "Run 'g.region rast=%s' to set proper region resolution."),
 			  input_map_name, input_map_name);
-
+    
     if (check_data_type != seg->data_type)
 	G_debug(1,
 		"ram_open:required map type and internal map type differs: conversion forced!");
     input_data_type = Rast_map_type(input_map_name, mapset);
     if (check_data_type != -1)
 	if (input_data_type != check_data_type)
-	    G_fatal_error(_("<%s> is not of type %s"),
+	    G_fatal_error(_("Raster <%s> is not of type '%s'"),
 			  input_map_name, maptypes[check_data_type]);
 
     input_fd = Rast_open_old(input_map_name, mapset);
@@ -401,7 +401,7 @@
 
     /* end opening and checking */
 
-    G_message(_("Reading map <%s>"), input_map_name);
+    G_message(_("Reading raster map <%s>..."), input_map_name);
     input_buffer = Rast_allocate_buf(input_data_type);
 
     target_buffer = Rast_allocate_buf(seg->data_type);
@@ -441,7 +441,7 @@
 	    G_free(input_buffer);
 	    G_free(target_buffer);
 	    Rast_close(input_fd);
-	    G_fatal_error(_("seg_read: Cannot segment put row %d for map %s"),
+	    G_fatal_error(_("Unable to segment put row %d for raster map <%s>"),
 			  r, input_map_name);
 	}
     }				/* end for row */
@@ -495,7 +495,7 @@
 	G_debug(1,
 		"ram_write:required map type and internal map type differs: conversion forced!");
 
-    G_message(_("Writing map <%s>"), output_map_name);
+    G_message(_("Writing raster map <%s>..."), output_map_name);
     output_fd = Rast_open_new(output_map_name, output_data_type);
     output_buffer = Rast_allocate_buf(output_data_type);
     segment_flush(&(seg->seg));
@@ -505,7 +505,7 @@
 
 	G_percent(r, seg->nrows, 2);
 	if (0 > segment_get_row(&(seg->seg), output_buffer, r))
-	    G_warning(_("seg_write: Cannot segment read row %d for map %s"),
+	    G_warning(_("Unable to segment read row %d for raster map <%s>"),
 		      r, output_map_name);
 
 	if (convert_to_null) {
@@ -528,7 +528,7 @@
 			Rast_set_d_null_value(row + c * (seg->data_size), 1);
 		break;
 	    default:
-		G_warning(_("ram_null:Cannot convert to null at: %d %d"), r,
+		G_warning(_("Unable to convert to NULL at: %d %d"), r,
 			  c);
 	    }
 	}
@@ -541,7 +541,7 @@
     Rast_short_history(output_map_name, "raster", &history);
     Rast_command_history(&history);
     Rast_write_history(output_map_name, &history);
-    G_message(_("%s Done"), output_map_name);
+    /* G_message(_("%s Done"), output_map_name); */
 
     return 0;
 }

Modified: grass-addons/grass7/raster/r.stream.distance/io.h
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/io.h	2014-03-27 10:46:40 UTC (rev 59397)
+++ grass-addons/grass7/raster/r.stream.distance/io.h	2014-03-27 11:24:34 UTC (rev 59398)
@@ -56,4 +56,3 @@
 int seg_reset_map (SEG *, int);
 int seg_write_map(SEG *, char *, RASTER_MAP_TYPE, int, double);
 int seg_release_map(SEG *);
-

Modified: grass-addons/grass7/raster/r.stream.distance/local_proto.h
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/local_proto.h	2014-03-27 10:46:40 UTC (rev 59397)
+++ grass-addons/grass7/raster/r.stream.distance/local_proto.h	2014-03-27 11:24:34 UTC (rev 59398)
@@ -18,5 +18,3 @@
 int seg_calculate_downstream (SEGMENT *dirs, SEGMENT *distance, SEGMENT *elevation, OUTLET outlet, int outs);
 int seg_fill_basins(OUTLET outlet, SEGMENT *distance, SEGMENT *dirs);
 int seg_calculate_upstream(SEGMENT *distance, SEGMENT *dirs, SEGMENT *elevation, SEGMENT *tmp_elevation, int near);
-
-

Modified: grass-addons/grass7/raster/r.stream.distance/local_vars.h
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/local_vars.h	2014-03-27 10:46:40 UTC (rev 59397)
+++ grass-addons/grass7/raster/r.stream.distance/local_vars.h	2014-03-27 11:24:34 UTC (rev 59398)
@@ -34,9 +34,3 @@
 GLOBAL int fifo_max;
 GLOBAL POINT* fifo_points;
 GLOBAL int accum;
-
-
-
-
-
-

Modified: grass-addons/grass7/raster/r.stream.distance/main.c
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/main.c	2014-03-27 10:46:40 UTC (rev 59397)
+++ grass-addons/grass7/raster/r.stream.distance/main.c	2014-03-27 11:24:34 UTC (rev 59398)
@@ -11,11 +11,11 @@
  *               Stram input map shall contains streams or points outlets with or
  *               without unique categories
  *
- * COPYRIGHT:    (C) 2002,2009 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2002,2009-2014 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
- *   	    	 	  for details.
+ *   	    	 License (>=v2). Read the file COPYING that comes with GRASS
+ *   	    	 for details.
  *
  *****************************************************************************/
 #define MAIN
@@ -46,54 +46,53 @@
     G_gisinit(argv[0]);
 
     module = G_define_module();
+    module->label = _("Calculates distance to and elevation above streams and outlets.");
     module->description =
-	_("Calculate distance to and elevation above streams \
-    and outlets according user's input. It can work in stream mode where target are streams and outlets mode \
-    where targets are outlets");
-
+      _("The module can work in stream mode where target are streams and "
+        "outlets mode where targets are outlets.");
     G_add_keyword(_("raster"));
     G_add_keyword(_("hydrology"));
-    G_add_keyword("watercourse distance");
-    G_add_keyword("relative elevation");
+    G_add_keyword(_("stream network"));
+    G_add_keyword(_("watercourse distance"));
 
     in_stm_opt = G_define_standard_option(G_OPT_R_INPUT);
     in_stm_opt->key = "stream";
-    in_stm_opt->description = "Name of streams (outlets) mask input map";
+    in_stm_opt->description = _("Name of input streams (outlets) mask raster map");
 
     in_dir_opt = G_define_standard_option(G_OPT_R_INPUT);
     in_dir_opt->key = "dirs";
-    in_dir_opt->description = "Name of flow direction input map";
+    in_dir_opt->description = _("Name of inout flow direction raster map");
 
-    in_elev_opt = G_define_standard_option(G_OPT_R_INPUT);
-    in_elev_opt->key = "elevation";
+    in_elev_opt = G_define_standard_option(G_OPT_R_ELEV);
     in_elev_opt->required = NO;
-    in_elev_opt->description = "Name of elevation map";
-
+    
     in_method_opt = G_define_option();
     in_method_opt->key = "method";
-    in_method_opt->description = "Calculation method";
+    in_method_opt->description = _("Calculation method");
     in_method_opt->type = TYPE_STRING;
     in_method_opt->required = YES;
     in_method_opt->options = "upstream,downstream";
     in_method_opt->answer = "downstream";
 
-    opt_swapsize = G_define_option();
-    opt_swapsize->key = "memory";
-    opt_swapsize->type = TYPE_INTEGER;
-    opt_swapsize->answer = "300";
-    opt_swapsize->description = _("Max memory used in memory swap mode (MB)");
-    opt_swapsize->guisection = _("Optional");
-
     out_dist_opt = G_define_standard_option(G_OPT_R_OUTPUT);
     out_dist_opt->key = "distance";
     out_dist_opt->required = NO;
-    out_dist_opt->description = "Output distance/accumulation map";
+    out_dist_opt->description = _("Name for output distance/accumulation raster map");
+    out_dist_opt->guisection = _("Output settings");
 
     out_diff_opt = G_define_standard_option(G_OPT_R_OUTPUT);
     out_diff_opt->key = "difference";
     out_diff_opt->required = NO;
-    out_diff_opt->description = "Output elevation difference map";
+    out_diff_opt->description = _("Name for output elevation difference raster map");
+    out_diff_opt->guisection = _("Output settings");
 
+    opt_swapsize = G_define_option();
+    opt_swapsize->key = "memory";
+    opt_swapsize->type = TYPE_INTEGER;
+    opt_swapsize->answer = "300";
+    opt_swapsize->description = _("Max memory used in memory swap mode (MB)");
+    opt_swapsize->guisection = _("Memory settings");
+
     flag_outs = G_define_flag();
     flag_outs->key = 'o';
     flag_outs->description =
@@ -112,25 +111,17 @@
     flag_segmentation = G_define_flag();
     flag_segmentation->key = 'm';
     flag_segmentation->description = _("Use memory swap (operation is slow)");
+    flag_segmentation->guisection = _("Memory settings");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
     if (!out_diff_opt->answer && !out_dist_opt->answer)
-	G_fatal_error(_("You must select at least one output maps: distance and (or) elevation"));
+	G_fatal_error(_("You must select at least one output raster maps"));
     if (out_diff_opt->answer && !in_elev_opt->answer)
-	G_fatal_error(_("If you select elevation output, elevation is required"));
-
-    if (out_dist_opt->answer)
-	if (G_legal_filename(out_dist_opt->answer) < 0)
-	    G_fatal_error(_("<%s> is an illegal distance name"),
-			  out_dist_opt->answer);
-
-    if (out_diff_opt->answer)
-	if (G_legal_filename(out_diff_opt->answer) < 0)
-	    G_fatal_error(_("<%s> is an illegal elevation difference name"),
-			  out_diff_opt->answer);
-
+	G_fatal_error(_("Output elevation difference raster map requires "
+                        "input elevation raster map to be specified"));
+    
     if (!strcmp(in_method_opt->answer, "upstream"))
 	method = UPSTREAM;
     else if (!strcmp(in_method_opt->answer, "downstream"))
@@ -149,7 +140,7 @@
     fifo_points = (POINT *) G_malloc((fifo_max + 1) * sizeof(POINT));
 
     if (!segmentation) {
-	G_message(_("ALL IN RAM CALCULATION - METHOD: %s"),
+	G_message(_("All in RAM calculation - method <%s>..."),
 		  method_name[method]);
 	MAP map_dirs, map_streams, map_distance, map_elevation,
 	    map_tmp_elevation;
@@ -228,7 +219,7 @@
     }
 
     if (segmentation) {
-	G_message(_("MEMORY SWAP CALCULATION - METHOD: %s MAY TAKE SOME TIME"),
+	G_message(_("Calculating segments in direction <%s> (may take some time)..."),
 		  method_name[method]);
 	SEG map_dirs, map_streams, map_distance, map_elevation,
 	    map_tmp_elevation;



More information about the grass-commit mailing list