[GRASS-SVN] r31558 - grass/branches/develbranch_6/raster/r.lake
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 28 14:06:10 EDT 2008
Author: martinl
Date: 2008-05-28 14:06:10 -0400 (Wed, 28 May 2008)
New Revision: 31558
Modified:
grass/branches/develbranch_6/raster/r.lake/main.c
Log:
r.lake: change element to 'cell' for 'dem'
message cleaning, do not use _() for debug messages
Modified: grass/branches/develbranch_6/raster/r.lake/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.lake/main.c 2008-05-28 15:33:28 UTC (rev 31557)
+++ grass/branches/develbranch_6/raster/r.lake/main.c 2008-05-28 18:06:10 UTC (rev 31558)
@@ -9,7 +9,7 @@
* As seed You can use already existing map or
* X,Y coordinates.
*
- * COPYRIGHT: (C) 2005-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2005-2008 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
@@ -43,13 +43,13 @@
int row, col;
double cellsize = -1;
- G_debug(1,_("Saving new map"));
+ G_debug(1, "Saving new map");
if (G_begin_cell_area_calculations() == 0 || G_begin_cell_area_calculations() == 1) /* All cells have constant size... */
{
cellsize = G_area_of_cell_at_row(0);
}
- G_debug(1,_("Cell area: %f"),cellsize);
+ G_debug(1, "Cell area: %f", cellsize);
for (row = 0; row < rows; row++)
{
@@ -65,7 +65,8 @@
}
if (out[row][col] > 0 || out[row][col] < 0)
{
- G_debug(5,"volume %f += cellsize %f * value %f [%d,%d]",*volume, cellsize, out[row][col],row,col);
+ G_debug(5, "volume %f += cellsize %f * value %f [%d,%d]",
+ *volume, cellsize, out[row][col],row,col);
*area += cellsize;
*volume += cellsize * out[row][col];
}
@@ -77,7 +78,8 @@
*min_depth = out[row][col];
}
if (G_put_f_raster_row(out_fd, out[row])==-1)
- G_fatal_error(_("Error writing result map file!"));
+ G_fatal_error(_("Failed writing output raster map row %d"),
+ row);
G_percent(row+1,rows,5);
}
}
@@ -155,14 +157,14 @@
module = G_define_module();
module->keywords = _("raster");
module->description =
- _("Fills lake from seed at given level");
+ _("Fills lake from seed at given level.");
tmap_opt = G_define_option() ;
tmap_opt->key = "dem";
tmap_opt->key_desc = "name";
- tmap_opt->description = _("Terrain raster map (DEM)");
+ tmap_opt->description = _("Name of terrain raster map (DEM)");
tmap_opt->type = TYPE_STRING;
- tmap_opt->gisprompt = "old,fcell,raster";
+ tmap_opt->gisprompt = "old,cell,raster";
tmap_opt->required = YES;
wlvl_opt = G_define_option() ;
@@ -174,7 +176,7 @@
lake_opt = G_define_option() ;
lake_opt->key = "lake";
lake_opt->key_desc = "name";
- lake_opt->description = _("Output raster map with lake");
+ lake_opt->description = _("Name for output raster map with lake");
lake_opt->type = TYPE_STRING;
lake_opt->gisprompt = "new,fcell,raster";
lake_opt->required = NO;
@@ -190,7 +192,7 @@
smap_opt = G_define_option() ;
smap_opt->key = "seed";
smap_opt->key_desc = "name";
- smap_opt->description = _("Raster map with seed (at least 1 cell > 0)");
+ smap_opt->description = _("Name of raster map with seed (at least 1 cell > 0)");
smap_opt->type = TYPE_STRING;
smap_opt->gisprompt = "old,cell,raster";
smap_opt->required = NO;
@@ -233,7 +235,7 @@
{
lake_fd = G_open_raster_new(lakemap, 1);
if (lake_fd < 0)
- G_fatal_error(_("Cannot write lake raster map <%s>!"), lakemap);
+ G_fatal_error(_("Unable to create raster map <%s>"), lakemap);
}
rows = G_window_rows();
@@ -253,36 +255,41 @@
if (start_row < 0 || start_row > rows ||
start_col < 0 || start_col > cols)
- G_fatal_error(_("Seed point outside the current region."));
+ G_fatal_error(_("Seed point outside the current region"));
}
/* Open terran map */
- mapset = G_find_cell(terrainmap,"");
+ mapset = G_find_cell2(terrainmap,"");
if (mapset == NULL)
- G_fatal_error(_("Terrain raster map <%s> not found!"), terrainmap);
+ G_fatal_error(_("Raster map <%s> not found"), terrainmap);
- in_terran_fd = G_open_cell_old(terrainmap,mapset);
- if (in_terran_fd < 0) G_fatal_error(_("Cannot open terrain raster map <%s@%s>!"), terrainmap,mapset);
+ in_terran_fd = G_open_cell_old(terrainmap, mapset);
+ if (in_terran_fd < 0)
+ G_fatal_error(_("Unable to open raster map <%s>"),
+ G_fully_qualified_name(terrainmap, mapset));
/* Open seed map */
if (smap_opt->answer)
{
- mapset = G_find_cell(seedmap,"");
+ mapset = G_find_cell2(seedmap,"");
if (mapset == NULL)
- G_fatal_error(_("Seed map <%s> not found!"), seedmap);
+ G_fatal_error(_("Raster map <%s> not found"),
+ seedmap);
out_fd = G_open_cell_old(seedmap,mapset);
- if (out_fd < 0) G_fatal_error(_("Cannot open seed map <%s@%s>!"), seedmap, mapset);
+ if (out_fd < 0)
+ G_fatal_error(_("Unable to open raster map <%s>"),
+ G_fully_qualified_name(seedmap, mapset));
}
/* Pointers to rows. Row = ptr to 'col' size array. */
in_terran = (FCELL **)G_malloc(rows * sizeof(FCELL *));
out_water = (FCELL **)G_malloc(rows * sizeof(FCELL *));
if (in_terran == NULL || out_water == NULL)
- G_fatal_error(_("Failure to allocate memory for row pointers"));
+ G_fatal_error(_("G_malloc: out of memory"));
- G_debug(1,_("Loading maps: "));
+ G_debug(1, "Loading maps...");
/* foo_rows[row] == array with data (2d array). */
for (row = 0; row < rows; row++)
{
@@ -291,11 +298,13 @@
/* In newly created space load data from file.*/
if (G_get_f_raster_row(in_terran_fd, in_terran[row], row)!=1)
- G_fatal_error(_("Error reading terrain raster map. Probably broken file."));
+ G_fatal_error(_("Unable to read raster map <%s> row %d"),
+ terrainmap, row);
if (smap_opt->answer)
if (G_get_f_raster_row(out_fd, out_water[row], row)!=1)
- G_fatal_error(_("Error reading seed raster map. Probably broken file."));
+ G_fatal_error(_("Unable to read raster map <%s> row %d"),
+ seedmap, row);
G_percent(row+1,rows,5);
}
@@ -304,7 +313,8 @@
if (sdxy_opt->answer)
/* Check is water level higher than seed point */
if (in_terran[start_row][start_col] >= water_level)
- G_fatal_error(_("Given water level at seed point is below earth surface. \n Increase water level or move seed point."));
+ G_fatal_error(_("Given water level at seed point is below earth surface. "
+ "Increase water level or move seed point."));
out_water[start_row][start_col] = 1;
/* Close seed map for reading. */
@@ -319,19 +329,21 @@
else
{
out_fd = G_open_raster_new(seedmap, 1);
- if (out_fd < 0) G_fatal_error(_("Cannot write lake raster map <%s@%s>!"), seedmap, mapset);
+ if (out_fd < 0)
+ G_fatal_error(_("Unable to create raster map <%s>"),
+ seedmap);
}
/* More pases are renudant. Real pases count is controled by altered cell count. */
pases = (int) (rows*cols)/2;
- G_debug(1,_("Starting lake filling at level of %8.4f in %d passes. \nPercent done:"),water_level,pases);
+ G_debug(1, "Starting lake filling at level of %8.4f in %d passes. Percent done:", water_level,pases);
lastcount = 0;
for (pass = 0; pass < pases; pass++)
{
- G_debug(3,_("Pass: %d\n"),pass);
+ G_debug(3,_("Pass: %d"),pass);
curcount = 0;
/* Move from left upper corner to right lower corner. */
for (row = 0; row < rows; row++)
@@ -412,12 +424,12 @@
}
if (G_write_colors(lakemap, G_mapset(), &colr) != 1)
- G_fatal_error(_("Error writing color file for <%s@%s>!"),lakemap,G_mapset());
-
+ G_fatal_error(_("Unable to read color file of raster map <%s>"),
+ lakemap);
+
G_short_history(lakemap, "raster", &history);
G_command_history(&history);
G_write_history(lakemap, &history);
- G_message(_("All done."));
return EXIT_SUCCESS;
}
More information about the grass-commit
mailing list