[GRASS-SVN] r48466 - in grass/trunk/raster: r.random r.reclass
r.recode r.slope.aspect r.sunmask simwe/simlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Sep 26 02:28:07 EDT 2011
Author: hamish
Date: 2011-09-25 23:28:07 -0700 (Sun, 25 Sep 2011)
New Revision: 48466
Modified:
grass/trunk/raster/r.random/support.c
grass/trunk/raster/r.reclass/reclass.c
grass/trunk/raster/r.recode/main.c
grass/trunk/raster/r.recode/recode.c
grass/trunk/raster/r.slope.aspect/main.c
grass/trunk/raster/r.sunmask/main.c
grass/trunk/raster/simwe/simlib/output.c
Log:
add Rast_command_history();
r.recode: fix title=;
simwe/simlib: i18n/std'ize error messages
(merge from devbr6)
Modified: grass/trunk/raster/r.random/support.c
===================================================================
--- grass/trunk/raster/r.random/support.c 2011-09-26 05:48:56 UTC (rev 48465)
+++ grass/trunk/raster/r.random/support.c 2011-09-26 06:28:07 UTC (rev 48466)
@@ -49,8 +49,9 @@
&hist, HIST_DATSRC_2,
"%ld random points on the base map <%s>",
theState->nRand, theState->inraster);
+
+ Rast_command_history(&hist);
Rast_write_history(theState->outraster, &hist);
-
}
/* write commandline to output vector */
Modified: grass/trunk/raster/r.reclass/reclass.c
===================================================================
--- grass/trunk/raster/r.reclass/reclass.c 2011-09-26 05:48:56 UTC (rev 48465)
+++ grass/trunk/raster/r.reclass/reclass.c 2011-09-26 06:28:07 UTC (rev 48466)
@@ -249,6 +249,8 @@
Rast_set_history(&hist, HIST_DATSRC_1, "Reclassified map based on:");
Rast_format_history(&hist, HIST_DATSRC_2, " Map [%s] in mapset [%s]",
new.name, new.mapset);
+
+ Rast_command_history(&hist);
Rast_write_history(new_name, &hist);
new_range(new_name, &new);
Modified: grass/trunk/raster/r.recode/main.c
===================================================================
--- grass/trunk/raster/r.recode/main.c 2011-09-26 05:48:56 UTC (rev 48465)
+++ grass/trunk/raster/r.recode/main.c 2011-09-26 06:28:07 UTC (rev 48466)
@@ -6,7 +6,7 @@
* Bob Covill <bcovill tekmap.ns.ca>, Hamish Bowman <hamish_b yahoo.com>,
* Jan-Oliver Wagner <jan intevation.de>
* PURPOSE: Recode categorical raster maps
- * COPYRIGHT: (C) 1999-2006, 2010 by the GRASS Development Team
+ * COPYRIGHT: (C) 1999-2011 by the GRASS Development Team
*
* This program is free software under the GNU General
* Public License (>=v2). Read the file COPYING that
@@ -102,5 +102,8 @@
do_recode();
+ if(title)
+ Rast_put_cell_title(result, title);
+
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.recode/recode.c
===================================================================
--- grass/trunk/raster/r.recode/recode.c 2011-09-26 05:48:56 UTC (rev 48465)
+++ grass/trunk/raster/r.recode/recode.c 2011-09-26 06:28:07 UTC (rev 48466)
@@ -65,6 +65,8 @@
if (nrules > 50)
Rast_append_history(&hist, "...");
Rast_format_history(&hist, HIST_DATSRC_1, "raster map %s", name);
+
+ Rast_command_history(&hist);
Rast_write_history(result, &hist);
return 0;
Modified: grass/trunk/raster/r.slope.aspect/main.c
===================================================================
--- grass/trunk/raster/r.slope.aspect/main.c 2011-09-26 05:48:56 UTC (rev 48465)
+++ grass/trunk/raster/r.slope.aspect/main.c 2011-09-26 06:28:07 UTC (rev 48466)
@@ -15,7 +15,7 @@
* PURPOSE: generates raster maps of slope, aspect, curvatures and
* first and second order partial derivatives from a raster map
* of true elevation values
- * COPYRIGHT: (C) 1999-2006, 2010 by the GRASS Development Team
+ * COPYRIGHT: (C) 1999-2011 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
@@ -1045,6 +1045,7 @@
Rast_append_format_history(&hist, "zfactor = %.2f", zfactor);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(aspect_name, &hist);
G_message(_("Aspect raster map <%s> complete"), aspect_name);
@@ -1154,6 +1155,7 @@
parm.slope_fmt->answer);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(slope_name, &hist);
G_message(_("Slope raster map <%s> complete"), slope_name);
@@ -1225,6 +1227,7 @@
Rast_append_format_history(&hist, "zfactor = %.2f", zfactor);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(pcurv_name, &hist);
G_message(_("Profile curve raster map <%s> complete"), pcurv_name);
@@ -1251,6 +1254,7 @@
Rast_append_format_history(&hist, "zfactor = %.2f", zfactor);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(tcurv_name, &hist);
G_message(_("Tangential curve raster map <%s> complete"), tcurv_name);
@@ -1275,6 +1279,7 @@
Rast_append_format_history(&hist, "zfactor = %.2f", zfactor);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(dx_name, &hist);
G_message(_("E-W slope raster map <%s> complete"), dx_name);
@@ -1299,6 +1304,7 @@
Rast_append_format_history(&hist, "zfactor = %.2f", zfactor);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(dy_name, &hist);
G_message(_("N-S slope raster map <%s> complete"), dy_name);
@@ -1323,6 +1329,7 @@
Rast_append_format_history(&hist, "zfactor = %.2f", zfactor);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(dxx_name, &hist);
G_message(_("Dxx raster map <%s> complete"), dxx_name);
@@ -1347,6 +1354,7 @@
Rast_append_format_history(&hist, "zfactor = %.2f", zfactor);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(dyy_name, &hist);
G_message(_("Dyy raster map <%s> complete"), dyy_name);
@@ -1371,6 +1379,7 @@
Rast_append_format_history(&hist, "zfactor = %.2f", zfactor);
Rast_append_format_history(&hist, "min_slp_allowed = %f", min_slp_allowed);
Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", elev_name);
+ Rast_command_history(&hist);
Rast_write_history(dxy_name, &hist);
G_message(_("Dxy raster map <%s> complete"), dxy_name);
Modified: grass/trunk/raster/r.sunmask/main.c
===================================================================
--- grass/trunk/raster/r.sunmask/main.c 2011-09-26 05:48:56 UTC (rev 48465)
+++ grass/trunk/raster/r.sunmask/main.c 2011-09-26 06:28:07 UTC (rev 48466)
@@ -526,9 +526,8 @@
/* writing history file */
Rast_short_history(outname, "raster", &hist);
- Rast_append_history(&hist, argv[0]);
- Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation file %s", name);
- Rast_set_history(&hist, HIST_DATSRC_2, G_recreate_command());
+ Rast_format_history(&hist, HIST_DATSRC_1, "raster elevation map %s", name);
+ Rast_command_history(&hist);
Rast_write_history(outname, &hist);
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/simwe/simlib/output.c
===================================================================
--- grass/trunk/raster/simwe/simlib/output.c 2011-09-26 05:48:56 UTC (rev 48465)
+++ grass/trunk/raster/simwe/simlib/output.c 2011-09-26 06:28:07 UTC (rev 48466)
@@ -8,9 +8,9 @@
#include <grass/bitmap.h>
#include <grass/linkm.h>
#include <grass/vector.h>
+#include <grass/glocale.h>
#include <grass/waterglobs.h>
-#include <grass/glocale.h>
static void output_walker_as_vector(int tt, int ndigit);
@@ -20,7 +20,7 @@
/* Only the 3d coordinates of the walker are stored. */
void output_walker_as_vector(int tt, int ndigit)
{
- char buf[256];
+ char buf[GNAME_MAX + 10];
char *outwalk_time = NULL;
double x, y, z;
struct Map_info Out;
@@ -32,7 +32,7 @@
/* In case of time series we extent the output name with the time value */
if (ts == 1) {
- G_snprintf(buf, 256, "%s_%.*d", outwalk, ndigit, tt);
+ G_snprintf(buf, sizeof(buf), "%s_%.*d", outwalk, ndigit, tt);
outwalk_time = G_store(buf);
Vect_open_new(&Out, outwalk_time, WITH_Z);
G_message("Writing %i walker into vector file %s", nstack, outwalk_time);
@@ -85,12 +85,14 @@
char *erdep0 = NULL;
const char *mapst = NULL;
char *type;
- char buf[256];
+ char buf[GNAME_MAX + 10];
int ndigit;
FCELL dat1, dat2;
float a1, a2;
ndigit = 2;
+ /* more compact but harder to read:
+ ndigit = (int)floor(log10(timesec)) + 2 */
if (timesec >= 10)
ndigit = 3;
if (timesec >= 100)
@@ -106,16 +108,16 @@
Rast_set_window(&cellhd);
if (my != Rast_window_rows())
- G_fatal_error("OOPS: rows changed from %d to %d\n", mx,
+ G_fatal_error("OOPS: rows changed from %d to %d", mx,
Rast_window_rows());
if (mx != Rast_window_cols())
- G_fatal_error("OOPS: cols changed from %d to %d\n", my,
+ G_fatal_error("OOPS: cols changed from %d to %d", my,
Rast_window_cols());
if (depth) {
depth_cell = Rast_allocate_f_buf();
if (ts == 1) {
- G_snprintf(buf, 256,"%s.%.*d", depth, ndigit, tt);
+ G_snprintf(buf, sizeof(buf), "%s.%.*d", depth, ndigit, tt);
depth0 = G_store(buf);
depth_fd = Rast_open_fp_new(depth0);
}
@@ -126,7 +128,7 @@
if (disch) {
disch_cell = Rast_allocate_f_buf();
if (ts == 1) {
- G_snprintf(buf, 256,"%s.%.*d", disch, ndigit, tt);
+ G_snprintf(buf, sizeof(buf),"%s.%.*d", disch, ndigit, tt);
disch0 = G_store(buf);
disch_fd = Rast_open_fp_new(disch0);
}
@@ -137,7 +139,7 @@
if (err) {
err_cell = Rast_allocate_f_buf();
if (ts == 1) {
- G_snprintf(buf, 256,"%s.%.*d", err, ndigit, tt);
+ G_snprintf(buf, sizeof(buf), "%s.%.*d", err, ndigit, tt);
err0 = G_store(buf);
err_fd = Rast_open_fp_new(err0);
}
@@ -148,7 +150,7 @@
if (conc) {
conc_cell = Rast_allocate_f_buf();
if (ts == 1) {
- G_snprintf(buf, 256,"%s.%.*d", conc, ndigit, tt);
+ G_snprintf(buf, sizeof(buf), "%s.%.*d", conc, ndigit, tt);
conc0 = G_store(buf);
conc_fd = Rast_open_fp_new(conc0);
}
@@ -159,7 +161,7 @@
if (flux) {
flux_cell = Rast_allocate_f_buf();
if (ts == 1) {
- G_snprintf(buf, 256,"%s.%.*d", flux, ndigit, tt);
+ G_snprintf(buf, sizeof(buf), "%s.%.*d", flux, ndigit, tt);
flux0 = G_store(buf);
flux_fd = Rast_open_fp_new(flux0);
}
@@ -170,7 +172,7 @@
if (erdep) {
erdep_cell = Rast_allocate_f_buf();
if (ts == 1) {
- G_snprintf(buf, 256,"%s.%.*d", erdep, ndigit, tt);
+ G_snprintf(buf, sizeof(buf), "%s.%.*d", erdep, ndigit, tt);
erdep0 = G_store(buf);
erdep_fd = Rast_open_fp_new(erdep0);
}
@@ -299,7 +301,7 @@
if (ts == 1) {
if ((mapst = G_find_file("fcell", depth0, "")) == NULL)
- G_fatal_error("cannot find file %s", depth0);
+ G_fatal_error(_("FP raster map <%s> not found"), depth0);
Rast_write_colors(depth0, mapst, &colors);
Rast_quantize_fp_map_range(depth0, mapst, 0., (FCELL) gmax, 0,
(CELL) gmax);
@@ -307,7 +309,7 @@
}
else {
if ((mapst = G_find_file("fcell", depth, "")) == NULL)
- G_fatal_error("cannot find file %s", depth);
+ G_fatal_error(_("FP raster map <%s> not found"), depth);
Rast_write_colors(depth, mapst, &colors);
Rast_quantize_fp_map_range(depth, mapst, 0., (FCELL) gmax, 0,
(CELL) gmax);
@@ -341,7 +343,7 @@
if (ts == 1) {
if ((mapst = G_find_file("cell", disch0, "")) == NULL)
- G_fatal_error("cannot find file %s", disch0);
+ G_fatal_error(_("Raster map <%s> not found"), disch0);
Rast_write_colors(disch0, mapst, &colors);
Rast_quantize_fp_map_range(disch0, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
@@ -350,7 +352,7 @@
else {
if ((mapst = G_find_file("cell", disch, "")) == NULL)
- G_fatal_error("cannot find file %s", disch);
+ G_fatal_error(_("Raster map <%s> not found"), disch);
Rast_write_colors(disch, mapst, &colors);
Rast_quantize_fp_map_range(disch, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
@@ -381,7 +383,7 @@
if (ts == 1) {
if ((mapst = G_find_file("cell", flux0, "")) == NULL)
- G_fatal_error("cannot find file %s", flux0);
+ G_fatal_error(_("Raster map <%s> not found"), flux0);
Rast_write_colors(flux0, mapst, &colors);
Rast_quantize_fp_map_range(flux0, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
@@ -390,7 +392,7 @@
else {
if ((mapst = G_find_file("cell", flux, "")) == NULL)
- G_fatal_error("cannot find file %s", flux);
+ G_fatal_error(_("Raster map <%s> not found"), flux);
Rast_write_colors(flux, mapst, &colors);
Rast_quantize_fp_map_range(flux, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
@@ -436,7 +438,7 @@
if (ts == 1) {
if ((mapst = G_find_file("cell", erdep0, "")) == NULL)
- G_fatal_error("cannot find file %s", erdep0);
+ G_fatal_error(_("Raster map <%s> not found"), erdep0);
Rast_write_colors(erdep0, mapst, &colors);
Rast_quantize_fp_map_range(erdep0, mapst, (FCELL) ermin,
(FCELL) ermax, (CELL) ermin,
@@ -447,12 +449,13 @@
Rast_short_history(erdep0, type, &hist1);
Rast_append_format_history(
&hist1, "The sediment flux file is %s", flux0);
+ Rast_command_history(&hist1);
Rast_write_history(erdep0, &hist1);
}
else {
if ((mapst = G_find_file("cell", erdep, "")) == NULL)
- G_fatal_error("cannot find file %s", erdep);
+ G_fatal_error(_("Raster map <%s> not found"), erdep);
Rast_write_colors(erdep, mapst, &colors);
Rast_quantize_fp_map_range(erdep, mapst, (FCELL) ermin,
(FCELL) ermax, (CELL) ermin,
@@ -463,18 +466,18 @@
Rast_short_history(erdep, type, &hist1);
Rast_append_format_history(
&hist1, "The sediment flux file is %s", flux);
+ Rast_command_history(&hist1);
Rast_write_history(erdep, &hist1);
}
}
/* history section */
-
if (depth) {
type = "raster";
if (ts == 0) {
mapst = G_find_file("cell", depth, "");
if (mapst == NULL) {
- G_warning("File [%s] not found", depth);
+ G_warning(_("Raster map <%s> not found"), depth);
return -1;
}
Rast_short_history(depth, type, &hist);
@@ -482,9 +485,6 @@
else
Rast_short_history(depth0, type, &hist);
- /* fprintf (stdout, "\n history initiated\n");
- fflush(stdout); */
-
Rast_append_format_history(
&hist, "init.walk=%d, maxwalk=%d, remaining walkers=%d",
nwalk, maxwa, nwalka);
@@ -516,15 +516,12 @@
if (ts == 0) {
mapst = G_find_file("cell", disch, "");
if (mapst == NULL)
- G_fatal_error("file [%s] not found\n", disch);
+ G_fatal_error(_("Raster map <%s> not found"), disch);
Rast_short_history(disch, type, &hist);
}
else
Rast_short_history(disch0, type, &hist);
- /* fprintf (stdout, "\n history initiated\n");
- fflush(stdout); */
-
Rast_append_format_history(
&hist,"init.walkers=%d, maxwalk=%d, rem. walkers=%d",
nwalk, maxwa, nwalka);
@@ -556,15 +553,12 @@
if (ts == 0) {
mapst = G_find_file("cell", flux, "");
if (mapst == NULL)
- G_fatal_error("file [%s] not found\n", flux);
+ G_fatal_error(_("Raster map <%s> not found"), flux);
Rast_short_history(flux, type, &hist);
}
else
Rast_short_history(flux0, type, &hist);
- /* fprintf (stdout, "\n history initiated\n");
- fflush(stdout); */
-
Rast_append_format_history(
&hist, "init.walk=%d, maxwalk=%d, remaining walkers=%d",
nwalk, maxwa, nwalka);
@@ -605,7 +599,7 @@
struct Colors colors;
const char *mapst = NULL;
- /* char buf[256]; */
+ /* char buf[GNAME_MAX + 10]; */
FCELL dat1, dat2;
/* float a1,a2; */
@@ -614,10 +608,10 @@
if (et) {
et_cell = Rast_allocate_f_buf();
- /* if (ts == 1) {
- sprintf(buf,"%s.%.*d",et,ndigit,tt);
+ /* if (ts == 1) {
+ sprintf(buf, "%s.%.*d", et, ndigit, tt);
et0 = G_store(buf);
- et_fd = Rast_open_fp_new (et0);
+ et_fd = Rast_open_fp_new(et0);
}
else */
et_fd = Rast_open_fp_new(et);
@@ -626,19 +620,19 @@
if (tc) {
tc_cell = Rast_allocate_f_buf();
/* if (ts == 1) {
- sprintf(buf,"%s.%.*d",tc,ndigit,tt);
+ sprintf(buf, "%s.%.*d", tc, ndigit, tt);
tc0 = G_store(buf);
- tc_fd = Rast_open_fp_new (tc0);
+ tc_fd = Rast_open_fp_new(tc0);
}
else */
tc_fd = Rast_open_fp_new(tc);
}
if (my != Rast_window_rows())
- G_fatal_error("OOPS: rows changed from %d to %d\n", mx,
+ G_fatal_error("OOPS: rows changed from %d to %d", mx,
Rast_window_rows());
if (mx != Rast_window_cols())
- G_fatal_error("OOPS: cols changed from %d to %d\n", my,
+ G_fatal_error("OOPS: cols changed from %d to %d", my,
Rast_window_cols());
for (iarc = 0; iarc < my; iarc++) {
@@ -718,15 +712,15 @@
/* if (ts == 1) {
if ((mapst = G_find_file("cell", et0, "")) == NULL)
- G_fatal_error ("cannot find file %s", et0);
+ G_fatal_error(_("Raster map <%s> not found"), et0);
Rast_write_colors(et0, mapst, &colors);
- Rast_quantize_fp_map_range(et0,mapst,(FCELL)etmin,(FCELL)etmax,(CELL)etmin,(CELL)etmax);
+ Rast_quantize_fp_map_range(et0, mapst, (FCELL)etmin, (FCELL)etmax, (CELL)etmin, (CELL)etmax);
Rast_free_colors(&colors);
}
else { */
if ((mapst = G_find_file("cell", et, "")) == NULL)
- G_fatal_error("cannot find file %s", et);
+ G_fatal_error(_("Raster map <%s> not found"), et);
Rast_write_colors(et, mapst, &colors);
Rast_quantize_fp_map_range(et, mapst, (FCELL) etmin, (FCELL) etmax,
(CELL) etmin, (CELL) etmax);
More information about the grass-commit
mailing list