[GRASS-SVN] r59420 - grass-addons/grass7/raster/r.stream.snap
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Mar 27 07:33:35 PDT 2014
Author: martinl
Date: 2014-03-27 07:33:35 -0700 (Thu, 27 Mar 2014)
New Revision: 59420
Modified:
grass-addons/grass7/raster/r.stream.snap/Makefile
grass-addons/grass7/raster/r.stream.snap/io.c
grass-addons/grass7/raster/r.stream.snap/io.h
grass-addons/grass7/raster/r.stream.snap/local_proto.h
grass-addons/grass7/raster/r.stream.snap/main.c
grass-addons/grass7/raster/r.stream.snap/points_io.c
grass-addons/grass7/raster/r.stream.snap/snap.c
Log:
r.stream.snap: more guisection, message correction
various minor cosmetics
Modified: grass-addons/grass7/raster/r.stream.snap/Makefile
===================================================================
--- grass-addons/grass7/raster/r.stream.snap/Makefile 2014-03-27 14:29:36 UTC (rev 59419)
+++ grass-addons/grass7/raster/r.stream.snap/Makefile 2014-03-27 14:33:35 UTC (rev 59420)
@@ -11,4 +11,3 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
default: cmd
-
Modified: grass-addons/grass7/raster/r.stream.snap/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.snap/io.c 2014-03-27 14:29:36 UTC (rev 59419)
+++ grass-addons/grass7/raster/r.stream.snap/io.c 2014-03-27 14:33:35 UTC (rev 59420)
@@ -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;
@@ -53,7 +53,7 @@
* map pointer to map stucture (created with create_map);
* check_res: [1]: check res correspondence between region and map [0 no check];
* check_data_type [CELL, FCELL, DCELL] check if reading map is of particular type, [-1] no check;
- */
+5 */
int r, c;
char *mapset;
@@ -76,9 +76,9 @@
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)
@@ -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,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,9 +363,9 @@
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);
if (check_data_type != seg->data_type)
G_debug(1,
@@ -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);
@@ -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.snap/io.h
===================================================================
--- grass-addons/grass7/raster/r.stream.snap/io.h 2014-03-27 14:29:36 UTC (rev 59419)
+++ grass-addons/grass7/raster/r.stream.snap/io.h 2014-03-27 14:33:35 UTC (rev 59420)
@@ -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.snap/local_proto.h
===================================================================
--- grass-addons/grass7/raster/r.stream.snap/local_proto.h 2014-03-27 14:29:36 UTC (rev 59419)
+++ grass-addons/grass7/raster/r.stream.snap/local_proto.h 2014-03-27 14:33:35 UTC (rev 59420)
@@ -8,4 +8,3 @@
/* points_io.c */
int write_points(char *, int);
-
Modified: grass-addons/grass7/raster/r.stream.snap/main.c
===================================================================
--- grass-addons/grass7/raster/r.stream.snap/main.c 2014-03-27 14:29:36 UTC (rev 59419)
+++ grass-addons/grass7/raster/r.stream.snap/main.c 2014-03-27 14:33:35 UTC (rev 59420)
@@ -9,11 +9,11 @@
* maximum snap distance and minimum accumulation value to snap
*
*
- * 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,11 +44,12 @@
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 for stream network.");
+ module->description = _("Input can be stream network, point vector 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_points_opt = G_define_standard_option(G_OPT_V_INPUT);
in_points_opt->description = _("Name of input vector points map");
@@ -59,13 +60,15 @@
in_stream_opt = G_define_standard_option(G_OPT_R_INPUT);
in_stream_opt->key = "streams";
in_stream_opt->required = NO;
- in_stream_opt->description = _("Name of stream map");
+ in_stream_opt->description = _("Name of input streams mask raster map");
+ in_stream_opt->guisection = _("Input maps");
in_accum_opt = G_define_standard_option(G_OPT_R_INPUT);
in_accum_opt->key = "accum";
in_accum_opt->required = NO;
- in_accum_opt->description = _("Name of accumulation map");
-
+ in_accum_opt->description = _("Name of input accumulation raster map");
+ in_accum_opt->guisection = _("Input maps");
+
opt_accum_treshold = G_define_option();
opt_accum_treshold->key = "accumtres";
opt_accum_treshold->type = TYPE_DOUBLE;
@@ -104,7 +107,7 @@
out_points_opt->answer);
if (!in_stream_opt->answer && !in_accum_opt->answer)
- G_fatal_error(_("At least one map of accumulation or streams is required"));
+ G_fatal_error(_("At least one of accumulation or streams raster maps is required"));
if (!in_accum_opt->answer)
accum_treshold = -1;
@@ -133,11 +136,12 @@
write_points(out_points_opt->answer, number_of_points);
+ /*
for (i = 0; i < number_of_points; ++i)
G_message("AFTER %d %d %d %d",
points[i].r, points[i].c, points[i].di, points[i].dj);
+ */
-
if (in_stream_opt->answer)
seg_release_map(&map_streams);
if (in_accum_opt->answer)
Modified: grass-addons/grass7/raster/r.stream.snap/points_io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.snap/points_io.c 2014-03-27 14:29:36 UTC (rev 59419)
+++ grass-addons/grass7/raster/r.stream.snap/points_io.c 2014-03-27 14:33:35 UTC (rev 59420)
@@ -2,7 +2,6 @@
int read_points(char *in_point, SEGMENT * streams, SEGMENT * accum)
{
- char *mapset;
struct Cell_head window;
struct Map_info Map;
struct bound_box box;
@@ -16,13 +15,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);
-
- if (Vect_open_old(&Map, in_point, mapset) < 0)
- G_fatal_error("Cannot open vector map <%s>", in_point);
-
+ Vect_open_old(&Map, in_point, "");
+
G_get_window(&window);
Vect_region_box(&window, &box);
Modified: grass-addons/grass7/raster/r.stream.snap/snap.c
===================================================================
--- grass-addons/grass7/raster/r.stream.snap/snap.c 2014-03-27 14:29:36 UTC (rev 59419)
+++ grass-addons/grass7/raster/r.stream.snap/snap.c 2014-03-27 14:33:35 UTC (rev 59420)
@@ -103,7 +103,8 @@
}
}
- if (sumaccum > 0)
+ /* TODO: this should be fixed by someone who knows the code */
+ if (sumaccum > 0)
/* accum_treshold=(sumaccum/naccum+maxaccum)/2 */ ;
accum_treshold = sumaccum / naccum;
@@ -129,8 +130,8 @@
}
} /* end of non-streams version */
if (di == -1 && dj == -1) {
- G_warning(_("cannot snap point with cat %d, in a given radius. \
- Increase search radius"), point->cat);
+ G_warning(_("Unable to snap point with cat %d, in a given radius. "
+ "Increase search radius."), point->cat);
di = 0;
dj = 0;
status = 2;
More information about the grass-commit
mailing list