[GRASS-SVN] r59429 - grass-addons/grass7/raster/r.stream.basins
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Mar 27 08:10:38 PDT 2014
Author: martinl
Date: 2014-03-27 08:10:37 -0700 (Thu, 27 Mar 2014)
New Revision: 59429
Modified:
grass-addons/grass7/raster/r.stream.basins/Makefile
grass-addons/grass7/raster/r.stream.basins/basins_fill.c
grass-addons/grass7/raster/r.stream.basins/basins_inputs.c
grass-addons/grass7/raster/r.stream.basins/io.c
grass-addons/grass7/raster/r.stream.basins/io.h
grass-addons/grass7/raster/r.stream.basins/local_vars.h
grass-addons/grass7/raster/r.stream.basins/main.c
Log:
r.stream.basins: more guisection, message correction
various minor cosmetics
Modified: grass-addons/grass7/raster/r.stream.basins/Makefile
===================================================================
--- grass-addons/grass7/raster/r.stream.basins/Makefile 2014-03-27 15:07:02 UTC (rev 59428)
+++ grass-addons/grass7/raster/r.stream.basins/Makefile 2014-03-27 15:10:37 UTC (rev 59429)
@@ -11,4 +11,3 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
default: cmd
-
Modified: grass-addons/grass7/raster/r.stream.basins/basins_fill.c
===================================================================
--- grass-addons/grass7/raster/r.stream.basins/basins_fill.c 2014-03-27 15:07:02 UTC (rev 59428)
+++ grass-addons/grass7/raster/r.stream.basins/basins_fill.c 2014-03-27 15:10:37 UTC (rev 59429)
@@ -24,7 +24,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) {
Modified: grass-addons/grass7/raster/r.stream.basins/basins_inputs.c
===================================================================
--- grass-addons/grass7/raster/r.stream.basins/basins_inputs.c 2014-03-27 15:07:02 UTC (rev 59428)
+++ grass-addons/grass7/raster/r.stream.basins/basins_inputs.c 2014-03-27 15:10:37 UTC (rev 59429)
@@ -23,17 +23,17 @@
for (n = 0, outlets_num = 0; answers[n] != NULL; n += 2, outlets_num++) {
if (!G_scan_easting(answers[n], &X, G_projection()))
- G_fatal_error("Wrong coordinate <%s>", answers[n]);
+ G_fatal_error(_("Wrong coordinate '%s'"), answers[n]);
if (!answers[n + 1])
- G_fatal_error("Missing north coordinate for east %g", X);
+ G_fatal_error(_("Missing north coordinate for east %g"), X);
if (!G_scan_northing(answers[n + 1], &Y, G_projection()))
- G_fatal_error("Wrong coordinate <%s>", answers[n + 1]);
+ G_fatal_error(_("Wrong coordinate '%s'"), answers[n + 1]);
if (X < window.west || X > window.east ||
Y < window.south || Y > window.north)
- G_fatal_error("Coordinates outside window");
+ G_fatal_error(_("Coordinates outside window"));
outlets[outlets_num].r = (window.north - Y) / window.ns_res;
outlets[outlets_num].c = (X - window.west) / window.ew_res;
@@ -45,7 +45,6 @@
int process_vector(char *in_point)
{
- char *mapset;
struct Cell_head window;
struct Map_info Map;
struct bound_box box;
@@ -57,13 +56,8 @@
sites = Vect_new_line_struct();
cats = Vect_new_cats_struct();
- mapset = G_find_vector2(in_point, "");
- if (mapset == NULL)
- G_fatal_error(_("Vector map <%s> not found"), in_point);
+ Vect_open_old(&Map, in_point, "");
- if (Vect_open_old(&Map, in_point, mapset) < 0)
- G_fatal_error("Cannot open vector map <%s>", in_point);
-
G_get_window(&window);
Vect_region_box(&window, &box);
@@ -216,8 +210,7 @@
segment_get(streams, &streams_cell, r, c);
if (streams_cell > 0) {
if (outlets_num > 6 * (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"));
if (outlets_num > (out_max - 1))
outlets =
Modified: grass-addons/grass7/raster/r.stream.basins/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.basins/io.c 2014-03-27 15:07:02 UTC (rev 59428)
+++ grass-addons/grass7/raster/r.stream.basins/io.c 2014-03-27 15:10:37 UTC (rev 59429)
@@ -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 raster 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 */
@@ -229,17 +229,17 @@
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;
}
int ram_release_map(MAP *map)
{
- /*
- * free memory allocated for map, set pointer to null;
- */
+ /*
+ * free memory allocated for map, set pointer to null;
+ */
int r;
-
+
for (r = 0; r < map->nrows; ++r)
G_free((map->map)[r]);
G_free(map->map);
@@ -294,8 +294,8 @@
seg->data_size = sizeof(DCELL);
break;
default:
- G_fatal_error(_("seg_create: unrecognisabe data type"));
- }
+ G_fatal_error(_("Unrecognisable data type"));
+
filename = G_tempfile();
fd = creat(filename, 0666);
@@ -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 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,8 +363,8 @@
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)
@@ -373,7 +373,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_fd = Rast_open_old(input_map_name, mapset);
@@ -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.basins/io.h
===================================================================
--- grass-addons/grass7/raster/r.stream.basins/io.h 2014-03-27 15:07:02 UTC (rev 59428)
+++ grass-addons/grass7/raster/r.stream.basins/io.h 2014-03-27 15:10:37 UTC (rev 59429)
@@ -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.basins/local_vars.h
===================================================================
--- grass-addons/grass7/raster/r.stream.basins/local_vars.h 2014-03-27 15:07:02 UTC (rev 59428)
+++ grass-addons/grass7/raster/r.stream.basins/local_vars.h 2014-03-27 15:10:37 UTC (rev 59429)
@@ -32,9 +32,3 @@
GLOBAL int nrows, ncols;
GLOBAL int fifo_max;
GLOBAL POINT* fifo_points;
-
-
-
-
-
-
Modified: grass-addons/grass7/raster/r.stream.basins/main.c
===================================================================
--- grass-addons/grass7/raster/r.stream.basins/main.c 2014-03-27 15:07:02 UTC (rev 59428)
+++ grass-addons/grass7/raster/r.stream.basins/main.c 2014-03-27 15:10:37 UTC (rev 59429)
@@ -5,17 +5,17 @@
*
* PURPOSE: Calculate basins according user' input data.
* It uses multiple type of inputs:
- * r.stream.order, r.stream.extract or r.watershed stream map
+ * r.stream.order, r.stream.extract or r.watershed stream map
* list of categoires to create basins (require stream map);
* vector file containing outputs;
* list of coordinates;
* with analogous direction map;
*
- * COPYRIGHT: (C) 2002,2010 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002,2010-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
@@ -44,53 +44,51 @@
G_gisinit(argv[0]);
module = G_define_module();
- module->description = _("Delineate basins according user' input. \
- Input can be stream network, point file with outlets or outlet coordinates");
+ module->label = _("Delineates basins according stream network.");
+ module->description = _("Input can be stream network, vector point map with outlets or outlet coordinates.");
G_add_keyword(_("raster"));
G_add_keyword(_("hydrology"));
- G_add_keyword("basins creation");
+ G_add_keyword(_("stream network"));
+ G_add_keyword(_("basins creation"));
in_dir_opt = G_define_standard_option(G_OPT_R_INPUT); /* input direction file */
in_dir_opt->key = "dirs";
- in_dir_opt->description = _("Name of flow direction input map");
+ in_dir_opt->description = _("Name of input flow direction raster map");
- in_coor_opt = G_define_option(); /* input coordinates of outlet */
- in_coor_opt->key = "coors";
- in_coor_opt->type = TYPE_STRING;
- in_coor_opt->key_desc = "x,y";
- in_coor_opt->answers = NULL;
+ in_coor_opt = G_define_standard_option(G_OPT_M_COORS); /* input coordinates of outlet */
in_coor_opt->required = NO;
in_coor_opt->multiple = YES;
- in_coor_opt->description = _("Basin's outlet's coordinates: E,N");
+ in_coor_opt->description = _("Basin's outlet's coordinates");
in_stm_opt = G_define_standard_option(G_OPT_R_INPUT); /* input stream file file */
in_stm_opt->key = "streams";
in_stm_opt->required = NO;
- in_stm_opt->description = _("Name of stream mask input map");
+ in_stm_opt->description = _("Name of input stream mask raster map");
+ in_stm_opt->guisection = _("Input maps");
- in_stm_cat_opt = G_define_option(); /* input stream category - optional */
- in_stm_cat_opt->key = "cats";
- in_stm_cat_opt->type = TYPE_STRING;
+ in_stm_cat_opt = G_define_standard_option(G_OPT_V_CATS); /* input stream category - optional */
in_stm_cat_opt->required = NO;
in_stm_cat_opt->description =
- _("Create basins only for these categories:");
+ _("Create basins only for these categories");
in_point_opt = G_define_standard_option(G_OPT_V_INPUT); /* input point outputs - optional */
in_point_opt->key = "points";
in_point_opt->required = NO;
- in_point_opt->description = _("Name of vector points map");
+ in_point_opt->description = _("Name of input vector points map");
+ in_point_opt->guisection = _("Input maps");
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");
+ opt_swapsize->guisection = _("Memory settings");
opt_basins = G_define_standard_option(G_OPT_R_OUTPUT);
opt_basins->key = "basins";
- opt_basins->description = _("Output basin map");
-
+ opt_basins->description = _("Name for output basin raster map");
+ opt_basins->guisection = _("Output maps");
+
/*flags */
flag_zerofill = G_define_flag();
flag_zerofill->key = 'z';
@@ -109,7 +107,8 @@
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)) /* parser */
exit(EXIT_FAILURE);
@@ -122,7 +121,7 @@
G_fatal_error(_("One basin's outlet definition is required"));
if (in_stm_cat_opt->answers && !in_stm_opt->answer)
- G_fatal_error(_("If cats stream file is required"));
+ G_fatal_error(_("Option <%s> required"), in_stm_opt->key);
if (in_coor_opt->answers)
b_test += 1;
@@ -137,16 +136,12 @@
nrows = Rast_window_rows();
ncols = Rast_window_cols();
- if (G_legal_filename(opt_basins->answer) < 0)
- G_fatal_error(_("<%s> is an illegal basin name"), opt_basins->answer);
-
-
/* ALL IN RAM VERSION */
if (!segmentation) {
MAP map_dirs, map_streams, map_basins;
CELL **streams = NULL, **dirs, **basins;
- G_message("ALL IN RAM CALCULATION");
+ G_message("All in RAM calculation...");
ram_create_map(&map_dirs, CELL_TYPE);
ram_read_map(&map_dirs, in_dir_opt->answer, 1, CELL_TYPE);
@@ -155,12 +150,12 @@
switch (b_test) {
case 1:
- G_message("Calculate basins using coordinates...");
+ G_message(_("Calculating basins using coordinates..."));
outlets_num = process_coors(in_coor_opt->answers);
break;
case 2:
- G_message("Calculate basins using streams...");
+ G_message(_("Calculating basins using streams..."));
ram_create_map(&map_streams, CELL_TYPE);
ram_read_map(&map_streams, in_stm_opt->answer, 1, CELL_TYPE);
streams = (CELL **) map_streams.map;
@@ -172,7 +167,7 @@
break;
case 4:
- G_message("Calculate basins using point file...");
+ G_message(_("Calculating basins using vector point map..."));
outlets_num = process_vector(in_point_opt->answer);
break;
}
@@ -201,8 +196,8 @@
SEGMENT *streams = NULL, *dirs, *basins;
int number_of_segs;
- G_message("MEMORY SWAP CALCULATION: MAY TAKE SOME TIME!");
-
+ G_message(_("Memory swap calculation (may take some time)..."));
+
number_of_segs = (int)atof(opt_swapsize->answer);
number_of_segs = number_of_segs < 32 ? (int)(32 / 0.12) : number_of_segs / 0.12;
@@ -212,12 +207,12 @@
switch (b_test) {
case 1:
- G_message("Calculate basins using coordinates...");
+ G_message(_("Calculating basins using coordinates..."));
outlets_num = process_coors(in_coor_opt->answers);
break;
case 2:
- G_message("Calculate basins using streams...");
+ G_message(_("Calculating basins using streams..."));
seg_create_map(&map_streams, SROWS, SCOLS, number_of_segs,
CELL_TYPE);
seg_read_map(&map_streams, in_stm_opt->answer, 1, CELL_TYPE);
@@ -230,7 +225,7 @@
break;
case 4:
- G_message("Calculate basins using point file...");
+ G_message(_("Calculate basins using vector point map..."));
outlets_num = process_vector(in_point_opt->answer);
break;
}
More information about the grass-commit
mailing list