[GRASS-SVN] r59395 - grass-addons/grass7/raster/r.stream.channel
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Mar 27 03:31:32 PDT 2014
Author: martinl
Date: 2014-03-27 03:31:32 -0700 (Thu, 27 Mar 2014)
New Revision: 59395
Modified:
grass-addons/grass7/raster/r.stream.channel/Makefile
grass-addons/grass7/raster/r.stream.channel/io.c
grass-addons/grass7/raster/r.stream.channel/local_vars.h
grass-addons/grass7/raster/r.stream.channel/main.c
grass-addons/grass7/raster/r.stream.channel/stream_topology.c
grass-addons/grass7/raster/r.stream.channel/stream_write.c
Log:
r.stream.channel: more guisection, message correction
various minor cosmetics
Modified: grass-addons/grass7/raster/r.stream.channel/Makefile
===================================================================
--- grass-addons/grass7/raster/r.stream.channel/Makefile 2014-03-27 10:15:14 UTC (rev 59394)
+++ grass-addons/grass7/raster/r.stream.channel/Makefile 2014-03-27 10:31:32 UTC (rev 59395)
@@ -8,4 +8,3 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
default: cmd
-
Modified: grass-addons/grass7/raster/r.stream.channel/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.channel/io.c 2014-03-27 10:15:14 UTC (rev 59394)
+++ grass-addons/grass7/raster/r.stream.channel/io.c 2014-03-27 10:31:32 UTC (rev 59395)
@@ -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,8 +76,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);
/* checking if input map is of required 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(_("Unrecognisabe 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,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);
@@ -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,8 +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,
- c);
+ G_warning(_("Unable to convert to NULL at: %d %d"), r, c);
}
}
Rast_put_row(output_fd, output_buffer, output_data_type);
@@ -541,7 +540,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.channel/local_vars.h
===================================================================
--- grass-addons/grass7/raster/r.stream.channel/local_vars.h 2014-03-27 10:15:14 UTC (rev 59394)
+++ grass-addons/grass7/raster/r.stream.channel/local_vars.h 2014-03-27 10:31:32 UTC (rev 59395)
@@ -8,8 +8,6 @@
#define SQRT2 1.414214
-
-
typedef struct {
int stream_num;
int number_of_cells;
@@ -35,5 +33,3 @@
GLOBAL STREAM* stream_attributes;
GLOBAL struct Cell_head window;
-
-
Modified: grass-addons/grass7/raster/r.stream.channel/main.c
===================================================================
--- grass-addons/grass7/raster/r.stream.channel/main.c 2014-03-27 10:15:14 UTC (rev 59394)
+++ grass-addons/grass7/raster/r.stream.channel/main.c 2014-03-27 10:31:32 UTC (rev 59395)
@@ -5,15 +5,15 @@
* AUTHOR(S): Jarek Jasiewicz jarekj amu.edu.pl
*
* PURPOSE: Program calculate some channel properties:
- * local elevation change, curvature along stream,
- * distance to channel init/join, elevation below channel init,
- * optionally distance to outlet, elevation above outlet;
+ * local elevation change, curvature along stream,
+ * distance to channel init/join, elevation below channel init,
+ * optionally distance to outlet, elevation above outlet;
- * 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
@@ -23,10 +23,8 @@
int nextr[9] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
int nextc[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 };
-
int main(int argc, char *argv[])
{
-
/*
IO output[] = {
{"local_diff",NO,"Local elevation difference"},
@@ -55,60 +53,61 @@
/* initialize module */
module = G_define_module();
- G_add_keyword("Horton statistics");
- module->description =
- _("Calculate local parameters for individual streams");
G_add_keyword(_("raster"));
G_add_keyword(_("hydrology"));
- G_add_keyword("Stream parameters");
- G_add_keyword("Stream gradient");
- G_add_keyword("Stream curvature");
+ G_add_keyword(_("stream network"));
+ G_add_keyword(_("Horton statistics"));
+ module->description =
+ _("Calculates local parameters for individual streams.");
in_stm_opt = G_define_standard_option(G_OPT_R_INPUT);
in_stm_opt->key = "streams";
- in_stm_opt->description = "Name of streams mask input map";
+ in_stm_opt->description = _("Name of input streams 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 input flow direction raster map");
- in_elev_opt = G_define_standard_option(G_OPT_R_INPUT);
- in_elev_opt->key = "elevation";
- in_elev_opt->description = "Name of elevation map";
+ in_elev_opt = G_define_standard_option(G_OPT_R_ELEV);
out_identifier_opt = G_define_standard_option(G_OPT_R_OUTPUT);
out_identifier_opt->key = "identifier";
out_identifier_opt->required = NO;
- out_identifier_opt->description = "Unique identifier for stream";
+ out_identifier_opt->description = _("Name for output unique stream identifier raster map");
+ out_identifier_opt->guisection = _("Output settings");
out_distance_opt = G_define_standard_option(G_OPT_R_OUTPUT);
out_distance_opt->key = "distance";
out_distance_opt->required = NO;
- out_distance_opt->description = "Distance from init/join/outlet";
+ out_distance_opt->description = _("Name for output init/join/outlet distance raster map");
+ out_distance_opt->guisection = _("Output settings");
out_difference_opt = G_define_standard_option(G_OPT_R_OUTPUT);
out_difference_opt->key = "difference";
out_difference_opt->required = NO;
out_difference_opt->description =
- "Elevation differecne from init/join/outlet";
+ _("Name for output elevation init/join/outlet difference raster map");
+ out_difference_opt->guisection = _("Output settings");
out_gradient_opt = G_define_standard_option(G_OPT_R_OUTPUT);
out_gradient_opt->key = "gradient";
out_gradient_opt->required = NO;
out_gradient_opt->description =
- "Mean gradient of stream from init/join/outlet";
+ _("Name for output mean init/join/outlet gradient of stream raster map");
+ out_gradient_opt->guisection = _("Output settings");
out_curvature_opt = G_define_standard_option(G_OPT_R_OUTPUT);
out_curvature_opt->key = "curvature";
out_curvature_opt->required = NO;
- out_curvature_opt->description = "Local stream curvature";
+ out_curvature_opt->description = _("Name for output local stream curvature raster map");
+ out_curvature_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 = _("Optional");
+ opt_swapsize->guisection = _("Memory settings");
flag_downstream = G_define_flag();
flag_downstream->key = 'd';
@@ -126,6 +125,7 @@
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);
@@ -137,7 +137,7 @@
!out_distance_opt->answer &&
!out_difference_opt->answer &&
!out_gradient_opt->answer && !out_curvature_opt->answer)
- G_fatal_error(_("You must select at least one output maps"));
+ G_fatal_error(_("You must select at least one output raster maps"));
local = (flag_local->answer != 0);
cells = (flag_cells->answer != 0);
@@ -177,7 +177,7 @@
FCELL **elevation;
DCELL **output;
- G_message(_("ALL IN RAM CALCULATION - DIRECTION: %s"),
+ G_message(_("All in RAM calculation - direction <%s>..."),
method_name[downstream]);
ram_create_map(&map_streams, CELL_TYPE);
ram_read_map(&map_streams, in_stm_opt->answer, 1, CELL_TYPE);
@@ -257,7 +257,7 @@
SEG map_dirs, map_streams, map_elevation, map_output, map_identifier;
SEGMENT *streams, *dirs, *elevation, *output, *identifier;
- G_message(_("SEGMENT CALCULATION: MAY TAKE SOME TIME- DIRECTION: %s"),
+ G_message(_("Calculating segments in direction <%s> (may take some time)..."),
method_name[downstream]);
number_of_segs = (int)atof(opt_swapsize->answer);
Modified: grass-addons/grass7/raster/r.stream.channel/stream_topology.c
===================================================================
--- grass-addons/grass7/raster/r.stream.channel/stream_topology.c 2014-03-27 10:15:14 UTC (rev 59394)
+++ grass-addons/grass7/raster/r.stream.channel/stream_topology.c 2014-03-27 10:31:32 UTC (rev 59395)
@@ -1,4 +1,5 @@
#include "local_proto.h"
+
double get_distance(int r, int c, int d)
{
double northing, easting, next_northing, next_easting;
@@ -10,6 +11,7 @@
easting = window.west + (c + .5) * window.ew_res;
next_northing = window.north - (next_r + .5) * window.ns_res;
next_easting = window.west + (next_c + .5) * window.ew_res;
+
return G_distance(easting, northing, next_easting, next_northing);
}
@@ -380,6 +382,7 @@
if (SA[i].elevation[0] == -99999)
SA[i].elevation[0] = 2 * SA[i].elevation[1] - SA[i].elevation[2];
}
+
return 0;
}
@@ -420,5 +423,6 @@
G_free(SA[i].distance);
}
G_free(stream_attributes);
+
return 0;
}
Modified: grass-addons/grass7/raster/r.stream.channel/stream_write.c
===================================================================
--- grass-addons/grass7/raster/r.stream.channel/stream_write.c 2014-03-27 10:15:14 UTC (rev 59394)
+++ grass-addons/grass7/raster/r.stream.channel/stream_write.c 2014-03-27 10:31:32 UTC (rev 59395)
@@ -1,25 +1,26 @@
#include "local_proto.h"
int ram_set_null_output(DCELL **output)
{
-
int r;
for (r = 0; r < nrows; ++r)
Rast_set_d_null_value(output[r], ncols);
+
return 0;
}
int seg_set_null_output(SEGMENT *output)
{
-
int r, c;
double output_cell;
- for (r = 0; r < nrows; ++r)
+ for (r = 0; r < nrows; ++r) {
for (c = 0; c < ncols; ++c) {
Rast_set_d_null_value(&output_cell, 1);
segment_put(output, &output_cell, r, c);
}
+ }
+
return 0;
}
@@ -39,6 +40,7 @@
identifier[r][c] = SA[i].stream_num;
}
}
+
return 0;
}
@@ -58,6 +60,7 @@
segment_put(identifier, &(SA[i].stream_num), r, c);
}
}
+
return 0;
}
@@ -89,6 +92,7 @@
output[r][c] = cum_length;
}
}
+
return 0;
}
@@ -119,6 +123,7 @@
segment_put(output, &cum_length, r, c);
}
}
+
return 0;
}
@@ -139,6 +144,7 @@
output[r][c] = downstream ? k : j;
}
}
+
return 0;
}
@@ -162,6 +168,7 @@
segment_put(output, &output_cell, r, c);
}
}
+
return 0;
}
@@ -186,6 +193,7 @@
output[r][c] = result;
}
}
+
return 0;
}
@@ -210,6 +218,7 @@
segment_put(output, &output_cell, r, c);
}
}
+
return 0;
}
@@ -240,6 +249,7 @@
}
}
}
+
return 0;
}
@@ -274,6 +284,7 @@
}
}
}
+
return 0;
}
@@ -309,6 +320,7 @@
}
}
}
+
return 0;
}
@@ -348,6 +360,7 @@
}
}
}
+
return 0;
}
@@ -371,6 +384,7 @@
output[r][c] = elev_diff / SA[i].distance[j];
}
}
+
return 0;
}
@@ -396,6 +410,7 @@
segment_put(output, &output_cell, r, c);
}
}
+
return 0;
}
@@ -416,6 +431,7 @@
output[r][c] = SA[i].distance[j];
}
}
+
return 0;
}
@@ -437,6 +453,7 @@
segment_put(output, &output_cell, r, c);
}
}
+
return 0;
}
@@ -468,6 +485,7 @@
pow((1 + second_derivative * second_derivative), 1.5);
}
}
+
return 0;
}
@@ -501,5 +519,6 @@
segment_put(output, &output_cell, r, c);
}
}
+
return 0;
}
More information about the grass-commit
mailing list