[GRASS-SVN] r34761 - grass/trunk/raster/r.surf.fractal
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Dec 6 17:44:42 EST 2008
Author: martinl
Date: 2008-12-06 17:44:41 -0500 (Sat, 06 Dec 2008)
New Revision: 34761
Removed:
grass/trunk/raster/r.surf.fractal/open_files.c
Modified:
grass/trunk/raster/r.surf.fractal/frac.h
grass/trunk/raster/r.surf.fractal/main.c
grass/trunk/raster/r.surf.fractal/process.c
grass/trunk/raster/r.surf.fractal/r.surf.fractal.html
grass/trunk/raster/r.surf.fractal/spec_syn.c
grass/trunk/raster/r.surf.fractal/write_rast.c
Log:
r.surf.fractal: avoid segfault on G_malloc
parameters key consolidated
message standardization
(merge from devbr6, r34760)
Modified: grass/trunk/raster/r.surf.fractal/frac.h
===================================================================
--- grass/trunk/raster/r.surf.fractal/frac.h 2008-12-06 22:39:43 UTC (rev 34760)
+++ grass/trunk/raster/r.surf.fractal/frac.h 2008-12-06 22:44:41 UTC (rev 34761)
@@ -36,9 +36,6 @@
/* interface.c */
int interface(int, char *[]);
-/* open_files.c */
-int open_files(void);
-
/* process.c */
int process(void);
int data_reset(double *[2], int);
Modified: grass/trunk/raster/r.surf.fractal/main.c
===================================================================
--- grass/trunk/raster/r.surf.fractal/main.c 2008-12-06 22:39:43 UTC (rev 34760)
+++ grass/trunk/raster/r.surf.fractal/main.c 2008-12-06 22:44:41 UTC (rev 34761)
@@ -4,7 +4,7 @@
* MODULE: r.surf.fractal
* AUTHOR(S): Jo Wood, 19th October, 1994
* PURPOSE: GRASS module to manipulate a raster map layer.
- * COPYRIGHT: (C) 2005 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
@@ -13,6 +13,8 @@
*****************************************************************************/
#include <grass/glocale.h>
+#include <grass/glocale.h>
+
#include "frac.h"
const char
@@ -35,25 +37,21 @@
G_gisinit(argv[0]); /* Link with GRASS interface. */
module = G_define_module();
- module->keywords = _("raster");
+ module->keywords = _("raster, DEM, fractal");
module->description =
_("Creates a fractal surface of a given fractal dimension.");
- rast_out = G_define_option();
- rast_out->key = "out";
- rast_out->description = _("Name of fractal surface raster layer");
- rast_out->type = TYPE_STRING;
- rast_out->required = YES;
+ rast_out = G_define_standard_option(G_OPT_R_OUTPUT);
frac_dim = G_define_option();
- frac_dim->key = "d";
+ frac_dim->key = "dimension";
frac_dim->description = _("Fractal dimension of surface (2 < D < 3)");
frac_dim->type = TYPE_DOUBLE;
frac_dim->required = NO;
frac_dim->answer = "2.05";
num_images = G_define_option();
- num_images->key = "n";
+ num_images->key = "number";
num_images->description = _("Number of intermediate images to produce");
num_images->type = TYPE_INTEGER;
num_images->required = NO;
@@ -67,7 +65,7 @@
H = 3.0 - H;
Steps = atoi(num_images->answer) + 1;
- G_message(_("Steps=%d"), Steps);
+ G_debug(1, "Steps %d", Steps);
mapset_out = G_mapset(); /* Set output to current mapset. */
@@ -78,11 +76,13 @@
/*--------------------------------------------------------------------*/
if ((H <= 0) || (H >= 1)) {
- G_fatal_error(_("Fractal dimension of [%.2lf] must be between 2 and 3."),
+ G_fatal_error(_("Fractal dimension of %.2lf must be between 2 and 3."),
3.0 - H);
}
process();
+ G_done_msg(_("Raster map <%s> created."), rast_out_name);
+
return EXIT_SUCCESS;
}
Deleted: grass/trunk/raster/r.surf.fractal/open_files.c
===================================================================
--- grass/trunk/raster/r.surf.fractal/open_files.c 2008-12-06 22:39:43 UTC (rev 34760)
+++ grass/trunk/raster/r.surf.fractal/open_files.c 2008-12-06 22:44:41 UTC (rev 34761)
@@ -1,28 +0,0 @@
-
-/*****************************************************************************/
-
-/*** ***/
-
-/*** open_files() ***/
-
-/*** Opens input and output raster maps for r.example ***/
-
-/*** Jo Wood, V1.0, 13th September, 1994 ***/
-
-/*** ***/
-
-/*****************************************************************************/
-
-#include <grass/glocale.h>
-#include "frac.h"
-
-int open_files(void)
-{
- /* Open new file and set the output file descriptor. */
-
- if ((fd_out = G_open_cell_new(rast_out_name)) < 0) {
- G_fatal_error(_("ERROR: Problem opening output file."));
- }
-
- return 0;
-}
Modified: grass/trunk/raster/r.surf.fractal/process.c
===================================================================
--- grass/trunk/raster/r.surf.fractal/process.c 2008-12-06 22:39:43 UTC (rev 34760)
+++ grass/trunk/raster/r.surf.fractal/process.c 2008-12-06 22:44:41 UTC (rev 34761)
@@ -13,8 +13,9 @@
/***************************************************************************/
+#include <grass/gmath.h>
+#include <grass/glocale.h>
#include "frac.h"
-#include <grass/gmath.h>
int process(void)
{
@@ -47,6 +48,10 @@
/*------------------------------------------------------------------*/
+ if (nn * nn * sizeof(double) < 1)
+ G_fatal_error(_("Unable to allocate data buffer. "
+ "Check current region with g.region."));
+
data[0] = (double *)G_malloc(nn * nn * sizeof(double));
data[1] = (double *)G_malloc(nn * nn * sizeof(double));
Modified: grass/trunk/raster/r.surf.fractal/r.surf.fractal.html
===================================================================
--- grass/trunk/raster/r.surf.fractal/r.surf.fractal.html 2008-12-06 22:39:43 UTC (rev 34760)
+++ grass/trunk/raster/r.surf.fractal/r.surf.fractal.html 2008-12-06 22:44:41 UTC (rev 34761)
@@ -31,11 +31,11 @@
<em><a href="v.surf.idw.html">v.surf.idw</a></em>,
<em><a href="v.surf.rst.html">v.surf.rst</a></em>
+<h2>AUTHOR</h2>
-<address>
-<a href="MAILTO:jwo at le.ac.uk">jwo at le.ac.uk</a></address>
+Jo Wood,
+Midlands Regional Research Laboratory (ASSIST),
+University of Leicester
-<br><a href="http://www.geog.le.ac.uk/assist/index.html">ASSIST's home</a>
-
<p>
<i>Last changed: $Date$</i>
Modified: grass/trunk/raster/r.surf.fractal/spec_syn.c
===================================================================
--- grass/trunk/raster/r.surf.fractal/spec_syn.c 2008-12-06 22:39:43 UTC (rev 34760)
+++ grass/trunk/raster/r.surf.fractal/spec_syn.c 2008-12-06 22:44:41 UTC (rev 34761)
@@ -58,7 +58,7 @@
/* Calculate all the preliminary random coefficients. */
/* ================================================== */
- G_message(_("Preliminary surface calculations."));
+ G_message(_("Preliminary surface calculations..."));
data_reset(data, nn);
for (row = 0; row <= nn / 2; row++)
@@ -117,7 +117,7 @@
/* ========================================================= */
for (coeff = 0; coeff < Steps; coeff++) {
- G_message(_("Calculating surface %d (of %d)"), coeff + 1, Steps);
+ G_message(_("Calculating surface %d (of %d)..."), coeff + 1, Steps);
data_reset(temp, nn);
for (row = 0; row <= (coeff + 1) * nn / (Steps * 2); row++)
Modified: grass/trunk/raster/r.surf.fractal/write_rast.c
===================================================================
--- grass/trunk/raster/r.surf.fractal/write_rast.c 2008-12-06 22:39:43 UTC (rev 34760)
+++ grass/trunk/raster/r.surf.fractal/write_rast.c 2008-12-06 22:44:41 UTC (rev 34761)
@@ -55,7 +55,8 @@
strcpy(file_name, rast_out_name);
if ((fd_out = G_open_raster_new(file_name, DCELL_TYPE)) < 0) {
- G_fatal_error(_("ERROR: Problem opening output file."));
+ G_fatal_error(_("Unable to create raster map <%s>"),
+ file_name);
}
/*------------------------------------------------------------------*/
More information about the grass-commit
mailing list