Sfoglia il codice sorgente

r.random.{surface|cells}: clean up

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35039 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 anni fa
parent
commit
5688d5f254

+ 1 - 1
raster/r.random.cells/flag.c

@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/gis.h>
-#include "flag.h"
 
 
+#include "flag.h"
 
 
 void FlagClearAll(FLAG * flags)
 void FlagClearAll(FLAG * flags)
 {
 {

+ 2 - 6
raster/r.random.cells/gasdev.c

@@ -1,13 +1,9 @@
 /* gasdev.c                                                             */
 /* gasdev.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include <math.h>
+
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
-
 /* GasDev() returns a random double with a mean of 0.0 and a standard   */
 /* GasDev() returns a random double with a mean of 0.0 and a standard   */
 /*      deviation of 1.0.                                               */
 /*      deviation of 1.0.                                               */
 double GasDev(void)
 double GasDev(void)
@@ -21,7 +17,7 @@ double GasDev(void)
     } while (r >= 1.0);
     } while (r >= 1.0);
 
 
     fac = sqrt(-2.0 * log(r) / r);
     fac = sqrt(-2.0 * log(r) / r);
-    DOUBLE(v2 * fac);
+    G_debug(3, "(v2 * fac):%.12lf", v2 * fac);
 
 
     return (v2 * fac);
     return (v2 * fac);
 }
 }

+ 26 - 23
raster/r.random.cells/indep.c

@@ -1,11 +1,8 @@
 /* indep.c                                                              */
 /* indep.c                                                              */
-
-#undef TRACE
-#undef DEBUG
-
 #include <grass/gis.h>
 #include <grass/gis.h>
-#include "ransurf.h"
+#include <grass/glocale.h>
 
 
+#include "ransurf.h"
 
 
 void Indep(void)
 void Indep(void)
 {
 {
@@ -14,14 +11,15 @@ void Indep(void)
     double RowDist, RowDistSq, ColDist;
     double RowDist, RowDistSq, ColDist;
     struct History history;
     struct History history;
 
 
-    FUNCTION(indep);
+    G_debug(2, "indep()");
+
     Count = 0;
     Count = 0;
     Found = 0;
     Found = 0;
 
 
     while (CellCount > 0) {
     while (CellCount > 0) {
-	INT(CellCount);
-	INT(Count);
-	RETURN;
+	G_debug(3, "(CellCount):%d", CellCount);
+	G_debug(3, "(Count):%d", Count);
+
 	DRow = DoNext[Count].R;
 	DRow = DoNext[Count].R;
 	DCol = DoNext[Count++].C;
 	DCol = DoNext[Count++].C;
 
 
@@ -37,13 +35,13 @@ void Indep(void)
 		    RowDistSq = RowDist * RowDist;
 		    RowDistSq = RowDist * RowDist;
 		    for (C = DCol; C < Cs; C++) {
 		    for (C = DCol; C < Cs; C++) {
 			ColDist = EW * (C - DCol);
 			ColDist = EW * (C - DCol);
-			DOUBLE(RowDistSq);
-			DOUBLE(ColDist);
-			DOUBLE(MaxDistSq);
-			RETURN;
+			G_debug(3, "(RowDistSq):%.12lf", RowDistSq);
+			G_debug(3, "(ColDist):%.12lf", ColDist);
+			G_debug(3, "(MaxDistSq):%.12lf", MaxDistSq);
+			
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			    if (0 != FlagGet(Cells, R, C)) {
 			    if (0 != FlagGet(Cells, R, C)) {
-				FUNCTION(unset);
+				G_debug(2, "unset()");
 				FLAG_UNSET(Cells, R, C);
 				FLAG_UNSET(Cells, R, C);
 				CellCount--;
 				CellCount--;
 			    }
 			    }
@@ -55,7 +53,7 @@ void Indep(void)
 		}
 		}
 	    }
 	    }
 
 
-	    FUNCTION(it1);
+	    G_debug(2, "it1()");
 	    for (R = DRow - 1; R >= 0; R--) {
 	    for (R = DRow - 1; R >= 0; R--) {
 		RowDist = NS * (DRow - R);
 		RowDist = NS * (DRow - R);
 		if (RowDist > MaxDistSq) {
 		if (RowDist > MaxDistSq) {
@@ -67,7 +65,7 @@ void Indep(void)
 			ColDist = EW * (C - DCol);
 			ColDist = EW * (C - DCol);
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			    if (0 != FlagGet(Cells, R, C)) {
 			    if (0 != FlagGet(Cells, R, C)) {
-				FUNCTION(unset);
+				G_debug(2, "unset()");
 				FLAG_UNSET(Cells, R, C);
 				FLAG_UNSET(Cells, R, C);
 				CellCount--;
 				CellCount--;
 			    }
 			    }
@@ -79,7 +77,7 @@ void Indep(void)
 		}
 		}
 	    }
 	    }
 
 
-	    FUNCTION(it2);
+	    G_debug(2, "it2()");
 	    for (R = DRow; R < Rs; R++) {
 	    for (R = DRow; R < Rs; R++) {
 		RowDist = NS * (R - DRow);
 		RowDist = NS * (R - DRow);
 		if (RowDist > MaxDistSq) {
 		if (RowDist > MaxDistSq) {
@@ -91,7 +89,7 @@ void Indep(void)
 			ColDist = EW * (DCol - C);
 			ColDist = EW * (DCol - C);
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			    if (0 != FlagGet(Cells, R, C)) {
 			    if (0 != FlagGet(Cells, R, C)) {
-				FUNCTION(unset);
+				G_debug(2, "unset()");
 				FLAG_UNSET(Cells, R, C);
 				FLAG_UNSET(Cells, R, C);
 				CellCount--;
 				CellCount--;
 			    }
 			    }
@@ -103,7 +101,7 @@ void Indep(void)
 		}
 		}
 	    }
 	    }
 
 
-	    FUNCTION(it3);
+	    G_debug(2, "it3()");
 	    for (R = DRow - 1; R >= 0; R--) {
 	    for (R = DRow - 1; R >= 0; R--) {
 		RowDist = NS * (DRow - R);
 		RowDist = NS * (DRow - R);
 		if (RowDist > MaxDistSq) {
 		if (RowDist > MaxDistSq) {
@@ -115,7 +113,7 @@ void Indep(void)
 			ColDist = EW * (DCol - C);
 			ColDist = EW * (DCol - C);
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			    if (0 != FlagGet(Cells, R, C)) {
 			    if (0 != FlagGet(Cells, R, C)) {
-				FUNCTION(unset);
+				G_debug(2, "unset()");
 				FLAG_UNSET(Cells, R, C);
 				FLAG_UNSET(Cells, R, C);
 				CellCount--;
 				CellCount--;
 			    }
 			    }
@@ -129,18 +127,23 @@ void Indep(void)
 	}
 	}
     }
     }
 
 
-    FUNCTION(outputting);
+    G_debug(2, "outputting()");
     OutFD = G_open_cell_new(Output->answer);
     OutFD = G_open_cell_new(Output->answer);
     if (OutFD < 0)
     if (OutFD < 0)
-	G_fatal_error("%s: unable to open new raster map [%s]",
-		      G_program_name(), Output->answer);
+	G_fatal_error(_("Unable to open raster map <%s>"),
+		      Output->answer);
 
 
+    G_message(_("Writing raster map <%s>..."),
+	      Output->answer);
     for (R = 0; R < Rs; R++) {
     for (R = 0; R < Rs; R++) {
+	G_percent(R, Rs, 2);
 	for (C = 0; C < Cs; C++) {
 	for (C = 0; C < Cs; C++) {
 	    CellBuffer[C] = Out[R][C];
 	    CellBuffer[C] = Out[R][C];
 	}
 	}
 	G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
 	G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
     }
     }
+    G_percent(1, 1, 1);
+    
     G_close_cell(OutFD);
     G_close_cell(OutFD);
     G_short_history(Output->answer, "raster", &history);
     G_short_history(Output->answer, "raster", &history);
     G_command_history(&history);
     G_command_history(&history);

+ 14 - 39
raster/r.random.cells/init.c

@@ -1,55 +1,24 @@
 /* init.c                                                               */
 /* init.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
 #include <stdlib.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <grass/gis.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
+
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
-
 /* function prototypes */
 /* function prototypes */
 static int comp_array(const void *p1, const void *p2);
 static int comp_array(const void *p1, const void *p2);
 
 
-
-void Init(int argc, char **argv)
+void Init()
 {
 {
-    struct Option *SeedStuff;
     struct Cell_head Region;
     struct Cell_head Region;
     int Count;
     int Count;
     int FD, row, col;
     int FD, row, col;
     double MinRes;
     double MinRes;
 
 
-    FUNCTION(Init);
-
-    Output = G_define_option();
-    Output->key = "output";
-    Output->type = TYPE_STRING;
-    Output->required = YES;
-    Output->multiple = NO;
-    Output->description = "Name of indepent cells map";
-    Output->gisprompt = "new,cell,raster";
-
-    Distance = G_define_option();
-    Distance->key = "distance";
-    Distance->type = TYPE_DOUBLE;
-    Distance->required = YES;
-    Distance->multiple = NO;
-    Distance->description =
-	"Input value: max. distance of spatial correlation (value(s) >= 0.0)";
-
-    SeedStuff = G_define_option();
-    SeedStuff->key = "seed";
-    SeedStuff->type = TYPE_INTEGER;
-    SeedStuff->required = NO;
-    SeedStuff->description =
-	"Input value: random seed (SEED_MIN >= value >= SEED_MAX), default [random]";
-
-    if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);
+    G_debug(2, "Init()");
 
 
     Rs = G_window_rows();
     Rs = G_window_rows();
     Cs = G_window_cols();
     Cs = G_window_cols();
@@ -73,7 +42,7 @@ void Init(int argc, char **argv)
     CellCount = 0;
     CellCount = 0;
     if (NULL != G_find_file("cell", "MASK", G_mapset())) {
     if (NULL != G_find_file("cell", "MASK", G_mapset())) {
 	if ((FD = G_open_cell_old("MASK", G_mapset())) < 0) {
 	if ((FD = G_open_cell_old("MASK", G_mapset())) < 0) {
-	    G_fatal_error(" unable to open MASK");
+	    G_fatal_error(_("Unable to open raster map <%s>"), "MASK");
 	}
 	}
 	else {
 	else {
 	    for (row = 0; row < Rs; row++) {
 	    for (row = 0; row < Rs; row++) {
@@ -99,9 +68,9 @@ void Init(int argc, char **argv)
 
 
     sscanf(Distance->answer, "%lf", &MaxDist);
     sscanf(Distance->answer, "%lf", &MaxDist);
     if (MaxDist < 0.0)
     if (MaxDist < 0.0)
-	G_fatal_error("distance must be >= 0.0");
-
-    DOUBLE(MaxDist);
+	G_fatal_error(_("Distance must be >= 0.0"));
+    
+    G_debug(3, "(MaxDist):%.12lf", MaxDist);
     MaxDistSq = MaxDist * MaxDist;
     MaxDistSq = MaxDist * MaxDist;
     if (!SeedStuff->answer) {
     if (!SeedStuff->answer) {
 	Seed = (int)getpid();
 	Seed = (int)getpid();
@@ -118,9 +87,13 @@ void Init(int argc, char **argv)
 	    Seed += SEED_MAX - SEED_MIN;
 	    Seed += SEED_MAX - SEED_MIN;
     }
     }
 
 
+    G_message(_("Generating raster map <%s>..."),
+	      Output->answer);
+
     DoNext = (CELLSORTER *) G_malloc(CellCount * sizeof(CELLSORTER));
     DoNext = (CELLSORTER *) G_malloc(CellCount * sizeof(CELLSORTER));
     Count = 0;
     Count = 0;
     for (row = 0; row < Rs; row++) {
     for (row = 0; row < Rs; row++) {
+	G_percent(row, Rs, 2);
 	for (col = 0; col < Cs; col++) {
 	for (col = 0; col < Cs; col++) {
 	    if (0 != FlagGet(Cells, row, col)) {
 	    if (0 != FlagGet(Cells, row, col)) {
 		DoNext[Count].R = row;
 		DoNext[Count].R = row;
@@ -133,6 +106,8 @@ void Init(int argc, char **argv)
 	    }
 	    }
 	}
 	}
     }
     }
+    G_percent(1, 1, 1);
+    
     qsort(DoNext, CellCount, sizeof(CELLSORTER), comp_array);
     qsort(DoNext, CellCount, sizeof(CELLSORTER), comp_array);
 }
 }
 
 

+ 1 - 1
raster/r.random.cells/local_proto.h

@@ -8,7 +8,7 @@ double GasDev(void);
 void Indep(void);
 void Indep(void);
 
 
 /* init.c */
 /* init.c */
-void Init(int argc, char **argv);
+void Init();
 
 
 /* random.c */
 /* random.c */
 double ran1(void);
 double ran1(void);

+ 28 - 8
raster/r.random.cells/main.c

@@ -9,19 +9,17 @@
  *               Brad Douglas <rez touchofmadness.com>, Glynn Clements <glynn gclements.plus.com>
  *               Brad Douglas <rez touchofmadness.com>, Glynn Clements <glynn gclements.plus.com>
  * PURPOSE:      generates a random sets of cells that are at least
  * PURPOSE:      generates a random sets of cells that are at least
  *               some distance apart
  *               some distance apart
- * COPYRIGHT:    (C) 1999-2006 by the GRASS Development Team
+ * COPYRIGHT:    (C) 1999-2008 by the GRASS Development Team
  *
  *
  *               This program is free software under the GNU General Public
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
  *               License (>=v2). Read the file COPYING that comes with GRASS
  *               for details.
  *               for details.
  *
  *
  *****************************************************************************/
  *****************************************************************************/
-#undef TRACE
-#undef DEBUG
-
 #include <stdlib.h>
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
 #include <grass/glocale.h>
+
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
@@ -35,21 +33,43 @@ int Seed, OutFD;
 struct Flag *Verbose;
 struct Flag *Verbose;
 struct Option *Distance;
 struct Option *Distance;
 struct Option *Output;
 struct Option *Output;
+struct Option *SeedStuff;
 
 
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     struct GModule *module;
     struct GModule *module;
 
 
-    FUNCTION(main);
-
     G_gisinit(argv[0]);
     G_gisinit(argv[0]);
     /* Set description */
     /* Set description */
     module = G_define_module();
     module = G_define_module();
-    module->keywords = _("raster");
+    module->keywords = _("raster, random, cell");
     module->description =
     module->description =
 	_("Generates random cell values with spatial dependence.");
 	_("Generates random cell values with spatial dependence.");
 
 
-    Init(argc, argv);
+    Output = G_define_standard_option(G_OPT_R_OUTPUT);
+
+    Distance = G_define_option();
+    Distance->key = "distance";
+    Distance->type = TYPE_DOUBLE;
+    Distance->required = YES;
+    Distance->multiple = NO;
+    Distance->description =
+	_("Maximum distance of spatial correlation (value(s) >= 0.0)");
+
+    SeedStuff = G_define_option();
+    SeedStuff->key = "seed";
+    SeedStuff->type = TYPE_INTEGER;
+    SeedStuff->required = NO;
+    SeedStuff->description =
+	_("Random seed (SEED_MIN >= value >= SEED_MAX) (default [random])");
+
+    if (G_parser(argc, argv))
+	exit(EXIT_FAILURE);
+
+    Init();
     Indep();
     Indep();
+    
+    G_done_msg(" ");
+    
     exit(EXIT_SUCCESS);
     exit(EXIT_SUCCESS);
 }
 }

+ 60 - 46
raster/r.random.cells/r.random.cells.html

@@ -1,79 +1,93 @@
 <h2>DESCRIPTION</h2>
 <h2>DESCRIPTION</h2>
 
 
 <em>r.random.cells</em> generates a random sets of cells that are at
 <em>r.random.cells</em> generates a random sets of cells that are at
-least <var>distance</var> apart. The cells are numbered from 1 to the
-numbers of cells generated. Random cells will not be generated in areas
-masked off.
+least <b>distance</b> apart. The cells are numbered from 1 to the
+numbers of cells generated. Random cells will not be generated in
+areas masked off.
 
 
-<h2>PARAMETERS</h2>
+<h3>Parameters</h3>
 
 
-<b>output </b> Output map: Random cells. Each random cell has a unique
-non-zero cell value ranging from 1 to the number of cells generated. The
-heuristic for this algorithm is to randomly pick cells until there are no
-cells outside of the chosen cell's buffer of radius <b>distance</b>.
-<p>
+<dl>
+<dt><b>output</b></dt>
+<dd>Random cells. Each random cell has a unique non-zero cell value
+ranging from 1 to the number of cells generated. The heuristic for
+this algorithm is to randomly pick cells until there are no cells
+outside of the chosen cell's buffer of radius <b>distance</b>.</dd>
 
 
-<b>distance</b> Input value(s) [default 0.0]: <b>distance</b> determines the
-minimum distance the centers of the random cells will be apart.
-<p>
-<b>seed</b> Input value [default: random]: Specifies the random seed that
+<dt><b>distance</b></dt>
+<dd>Determines the minimum distance the centers of the random cells
+will be apart.</dd>
+
+<dt><b>seed</b></dt>
+<dd>Specifies the random seed that
 <em>r.random.cells</em> will use to generate the cells. If the random seed
 <em>r.random.cells</em> will use to generate the cells. If the random seed
 is not given,<em> r.random.cells</em> will get a seed from the process ID
 is not given,<em> r.random.cells</em> will get a seed from the process ID
-number.
+number.</dd>
+
+</dl>
 
 
 <h2>NOTES</h2>
 <h2>NOTES</h2>
 
 
-The original purpose for this program was to generate independent random
-samples of cells in a study area. The <b>distance</b> value is the amount of
-spatial autocorrelation for the map being studied. The amount of spatial
-autocorrelation can be determined by using <em>r.2Dcorrelogram</em> with
+The original purpose for this program was to generate independent
+random samples of cells in a study area. The <b>distance</b> value is
+the amount of spatial autocorrelation for the map being studied. 
+
+<!-- The amount of spatial autocorrelation can be determined by
+using <em>r.2Dcorrelogram</em> with
 <em>r.2Dto1D</em>, or <em>r.1Dcorrelogram</em>. With <b>distance</b> set to
 <em>r.2Dto1D</em>, or <em>r.1Dcorrelogram</em>. With <b>distance</b> set to
 zero, the <b>output</b> map will number each non-masked cell from 1 to the
 zero, the <b>output</b> map will number each non-masked cell from 1 to the
-number of non-masked cells in the study region.
+number of non-masked cells in the study region. -->
 
 
 <h2>REFERENCES</h2>
 <h2>REFERENCES</h2>
-Random Field Software for GRASS by Chuck Ehlschlaeger<p>
+Random Field Software for GRASS by Chuck Ehlschlaeger
 
 
-<p>As part of my dissertation, I put together several programs that help
+<p>
+  As part of my dissertation, I put together several programs that help
 GRASS (4.1 and beyond) develop uncertainty models of spatial data. I hope
 GRASS (4.1 and beyond) develop uncertainty models of spatial data. I hope
 you find it useful and dependable. The following papers might clarify their
 you find it useful and dependable. The following papers might clarify their
-use: </p>
+use:
 
 
-<p>&quot;<a href="http://www.wiu.edu/users/cre111/older/CGFinal/paper.htm">Visualizing Spatial Data
-Uncertainty Using Animation (final draft)</a>,&quot; by Charles R.
+<ul>
+<li><a href="../../CGFinal/paper.htm">Visualizing Spatial Data
+Uncertainty Using Animation (final draft)</a>, by Charles R.
 Ehlschlaeger, Ashton M. Shortridge, and Michael F. Goodchild. Submitted to
 Ehlschlaeger, Ashton M. Shortridge, and Michael F. Goodchild. Submitted to
 Computers in GeoSciences in September, 1996, accepted October, 1996 for
 Computers in GeoSciences in September, 1996, accepted October, 1996 for
-publication in June, 1997. </p>
-
-<p>&quot;<a href="http://www.wiu.edu/users/cre111/older/SDH96/paper.html">Modeling Uncertainty in Elevation Data for
-Geographical Analysis</a>&quot;, by Charles R. Ehlschlaeger, and Ashton M.
-Shortridge. Proceedings of the 7th International Symposium on Spatial Data
-Handling, Delft, Netherlands, August 1996. </p>
-
-<p>&quot;<a href="http://www.wiu.edu/users/cre111/older/acm/paper.html">Dealing with Uncertainty in
-Categorical Coverage Maps: Defining, Visualizing, and Managing Data
-Errors</a>&quot;, by Charles Ehlschlaeger and Michael Goodchild.
-Proceedings, Workshop on Geographic Information Systems at the Conference on
-Information and Knowledge Management, Gaithersburg MD, 1994. </p>
-
-<p>&quot;<a href="http://www.wiu.edu/users/cre111/older/gislis/gislis.html">Uncertainty in Spatial Data:
-Defining, Visualizing, and Managing Data Errors</a>&quot;, by Charles
-Ehlschlaeger and Michael Goodchild. Proceedings, GIS/LIS'94, pp. 246-253,
-Phoenix AZ, 1994. </p>
+publication in June, 1997.</li>
+
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/paper.html">Modeling
+Uncertainty in Elevation Data for Geographical Analysis</a>, by
+Charles R. Ehlschlaeger, and Ashton M.  Shortridge. Proceedings of the
+7th International Symposium on Spatial Data Handling, Delft,
+Netherlands, August 1996.</li>
+
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing
+with Uncertainty in Categorical Coverage Maps: Defining, Visualizing,
+and Managing Data Errors</a>, by Charles Ehlschlaeger and Michael
+Goodchild.  Proceedings, Workshop on Geographic Information Systems at
+the Conference on Information and Knowledge Management, Gaithersburg
+MD, 1994.</li>
+
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty
+in Spatial Data: Defining, Visualizing, and Managing Data
+Errors</a>, by Charles Ehlschlaeger and Michael
+Goodchild. Proceedings, GIS/LIS'94, pp. 246-253, Phoenix AZ,
+1994.</li>
+</ul>
 
 
 <h2>SEE ALSO</h2>
 <h2>SEE ALSO</h2>
 
 
 <em>
 <em>
-r.1Dcorrelogram, 
+<!--r.1Dcorrelogram, 
 r.2Dcorrelogram, 
 r.2Dcorrelogram, 
-r.2Dto1D, 
+r.2Dto1D, -->
 <a href="r.random.surface.html">r.random.surface</a>,
 <a href="r.random.surface.html">r.random.surface</a>,
-r.random.model, 
 <a href="r.random.html">r.random</a>
 <a href="r.random.html">r.random</a>
 </em> 
 </em> 
 
 
 <h2>AUTHOR</h2>
 <h2>AUTHOR</h2>
-<p>Charles Ehlschlaeger; National Center for Geographic Information and
+
+Charles Ehlschlaeger; National Center for Geographic Information and
 Analysis, University of California, Santa Barbara.
 Analysis, University of California, Santa Barbara.
 
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

+ 4 - 19
raster/r.random.cells/random.c

@@ -1,9 +1,7 @@
 /* random.c                                                             */
 /* random.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <grass/gis.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
+
 #include "ransurf.h"
 #include "ransurf.h"
 
 
 #define M1 259200
 #define M1 259200
@@ -18,7 +16,6 @@
 #define IA3 4561
 #define IA3 4561
 #define IC3 51349
 #define IC3 51349
 
 
-
 /* ran1() returns a double with a value between 0.0 and 1.0             */
 /* ran1() returns a double with a value between 0.0 and 1.0             */
 double ran1(void)
 double ran1(void)
 {
 {
@@ -28,7 +25,7 @@ double ran1(void)
     static int iff = 0;
     static int iff = 0;
     int j;
     int j;
 
 
-    FUNCTION(ran1);
+    G_debug(2, "ran1()");
 
 
     if (Seed < 0 || iff == 0) {
     if (Seed < 0 || iff == 0) {
 	iff = 1;
 	iff = 1;
@@ -50,22 +47,10 @@ double ran1(void)
     ix3 = (IA3 * ix3 + IC3) % M3;
     ix3 = (IA3 * ix3 + IC3) % M3;
     j = 1 + ((97 * ix3) / M3);
     j = 1 + ((97 * ix3) / M3);
     if (j > 97 || j < 1)
     if (j > 97 || j < 1)
-	G_fatal_error("RAN1: j==%d shouldn't happen", j);
+	G_fatal_error(_("RAN1: j == %d shouldn't happen"), j);
 
 
     temp = r[j];
     temp = r[j];
     r[j] = (ix1 + ix2 * RM2) * RM1;
     r[j] = (ix1 + ix2 * RM2) * RM1;
 
 
     return temp;
     return temp;
 }
 }
-
-#undef M1
-#undef IA1
-#undef IC1
-#undef RM1
-#undef M2
-#undef IA2
-#undef IC2
-#undef RM2
-#undef M3
-#undef IA3
-#undef IC3

+ 1 - 20
raster/r.random.cells/ransurf.h

@@ -27,23 +27,4 @@ extern int Seed, OutFD;
 extern struct Flag *Verbose;
 extern struct Flag *Verbose;
 extern struct Option *Distance;
 extern struct Option *Distance;
 extern struct Option *Output;
 extern struct Option *Output;
-
-#ifdef DEBUG
-#define INDX(a,b) (printf("(a)[%d]:%lf ",(b),(a)[(b)]))
-#define CHARS(a) (printf("(a):%s ",(a)))
-#define DOUBLE(a) (printf("(a):%.12lf ",(a)))
-#define INT(a) (printf("(a):%d ",(a)))
-#define RETURN (printf("\n"))
-#else
-#define INDX(a,b)
-#define CHARS(a)
-#define DOUBLE(a)
-#define INT(a)
-#define RETURN
-#endif
-
-#ifdef TRACE
-#define FUNCTION(a) (printf("Function:(a)\n"))
-#else
-#define FUNCTION(a)
-#endif
+extern struct Option *SeedStuff;

+ 5 - 9
raster/r.random.surface/calcsd.c

@@ -1,18 +1,13 @@
 /* calcsd.c                                                             */
 /* calcsd.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
-
 void CalcSD(void)
 void CalcSD(void)
 {
 {
     int Row, Col, DoFilter;
     int Row, Col, DoFilter;
     double Effect;
     double Effect;
 
 
-    FUNCTION(CalcSD);
+    G_debug(2, "CalcSD()");
 
 
     FilterSD = 0.0;
     FilterSD = 0.0;
     for (DoFilter = 0; DoFilter < NumFilters; DoFilter++) {
     for (DoFilter = 0; DoFilter < NumFilters; DoFilter++) {
@@ -29,8 +24,9 @@ void CalcSD(void)
 	}
 	}
     }
     }
 
 
-    DOUBLE(FilterSD);
+    G_debug(3, "(FilterSD):%.12lf", FilterSD);
     FilterSD = sqrt(FilterSD);
     FilterSD = sqrt(FilterSD);
-    DOUBLE(FilterSD);
-    RETURN;
+    G_debug(3, "(FilterSD):%.12lf", FilterSD);
+
+    return;
 }
 }

+ 7 - 11
raster/r.random.surface/calcsurf.c

@@ -1,14 +1,9 @@
 /* calcsurf.c                                                           */
 /* calcsurf.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #include <stdlib.h>
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
-
 void CalcSurface(void)
 void CalcSurface(void)
 {
 {
     int Count, OutRows, OutCols;
     int Count, OutRows, OutCols;
@@ -16,7 +11,7 @@ void CalcSurface(void)
     int owC, oeC, onR, osR, wC, eC, nR, sR;
     int owC, oeC, onR, osR, wC, eC, nR, sR;
     double **Randoms;
     double **Randoms;
 
 
-    FUNCTION(CalcSurface);
+    G_debug(2, "CalcSurface()");
 
 
     OutRows = BigF.RowPlus;
     OutRows = BigF.RowPlus;
     OutCols = BigF.ColPlus;
     OutCols = BigF.ColPlus;
@@ -96,19 +91,20 @@ void CalcSurface(void)
 	for (Row = 0; Row < Rs; Row++) {
 	for (Row = 0; Row < Rs; Row++) {
 	    if (ODD(Row)) {
 	    if (ODD(Row)) {
 		for (Col = Cs - 1; Col >= 0; Col--) {
 		for (Col = Cs - 1; Col >= 0; Col--) {
+		    G_percent(Count++, MapCount, 1);
 		    Surface[Row][Col] =
 		    Surface[Row][Col] =
 			MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
 			MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
-			G_percent(++Count, MapCount, 1);
 		}
 		}
 	    }
 	    }
 	    else {
 	    else {
 		for (Col = 0; Col < Cs; Col++) {
 		for (Col = 0; Col < Cs; Col++) {
+		    G_percent(Count++, MapCount, 1);
 		    Surface[Row][Col] =
 		    Surface[Row][Col] =
 			MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
 			MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
-			G_percent(++Count, MapCount, 1);
 		}
 		}
 	    }
 	    }
 	}
 	}
+	G_percent(1, 1, 1);
     }
     }
     else {
     else {
 	for (Row = 0; Row < Rs; Row++) {
 	for (Row = 0; Row < Rs; Row++) {
@@ -118,9 +114,9 @@ void CalcSurface(void)
 		    if (CellBuffer[Col] == 0)
 		    if (CellBuffer[Col] == 0)
 			Surface[Row][Col] = 0.0;
 			Surface[Row][Col] = 0.0;
 		    else {
 		    else {
+			G_percent(Count++, MapCount, 1);
 			Surface[Row][Col] =
 			Surface[Row][Col] =
 			    MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
 			    MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
-			    G_percent(++Count, MapCount, 1);
 		    }
 		    }
 		}
 		}
 	    }
 	    }
@@ -129,15 +125,15 @@ void CalcSurface(void)
 		    if (CellBuffer[Col] == 0)
 		    if (CellBuffer[Col] == 0)
 			Surface[Row][Col] = 0.0;
 			Surface[Row][Col] = 0.0;
 		    else {
 		    else {
+			G_percent(Count++, MapCount, 1);
 			Surface[Row][Col] =
 			Surface[Row][Col] =
 			    MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
 			    MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
-			    G_percent(++Count, MapCount, 1);
 		    }
 		    }
 		}
 		}
 	    }
 	    }
 	}
 	}
+	G_percent(1, 1, 1);
     }
     }
 
 
     G_free(Randoms);
     G_free(Randoms);
-    FUNCTION(end calcsurf);
 }
 }

+ 1 - 6
raster/r.random.surface/cpfilter.c

@@ -1,14 +1,9 @@
 /* cpfilter.c                                                           */
 /* cpfilter.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "ransurf.h"
 
 
-
 void CopyFilter(FILTER * FPtr, FILTER Filter)
 void CopyFilter(FILTER * FPtr, FILTER Filter)
 {
 {
-    FUNCTION(CopyFilter);
+    G_debug(2, "CopyFilter()");
 
 
     FPtr->Mult = Filter.Mult;
     FPtr->Mult = Filter.Mult;
     FPtr->MaxDist = Filter.MaxDist;
     FPtr->MaxDist = Filter.MaxDist;

+ 0 - 5
raster/r.random.surface/dd.c

@@ -1,12 +1,7 @@
 /* dd.c                                                         */
 /* dd.c                                                         */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include <math.h>
 #include "ransurf.h"
 #include "ransurf.h"
 
 
-
 double DD(double Dist)
 double DD(double Dist)
 {
 {
     double SmallD, SmallDist;
     double SmallD, SmallDist;

+ 4 - 8
raster/r.random.surface/decay.c

@@ -1,16 +1,12 @@
 /* decay.c                                                              */
 /* decay.c                                                              */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "ransurf.h"
 
 
 void DistDecay(double *Effect, int R, int C)
 void DistDecay(double *Effect, int R, int C)
 {
 {
-    FUNCTION(DistDecay);
-    INT(R);
-    INT(C);
+    G_debug(2, "DistDecay");
+    G_debug(3, "(R):%d", R);
+    G_debug(3, "(C):%d", C);
 
 
     *Effect = BigF.F[R + BigF.RowPlus][C + BigF.ColPlus];
     *Effect = BigF.F[R + BigF.RowPlus][C + BigF.ColPlus];
-    FUNCTION(end DistDecay);
+
 }
 }

+ 1 - 6
raster/r.random.surface/digits.c

@@ -1,18 +1,13 @@
 /* digits.c                                                             */
 /* digits.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include <math.h>
 #include "ransurf.h"
 #include "ransurf.h"
 
 
-
 int Digits(double Double, int MaxSig)
 int Digits(double Double, int MaxSig)
 {
 {
     int I, Round;
     int I, Round;
     double Check, RD, Right;
     double Check, RD, Right;
 
 
-    FUNCTION(SigDigits);
+    G_debug(2, "SigDigits");
 
 
     I = 0;
     I = 0;
     Double += 1.0;
     Double += 1.0;

+ 1 - 6
raster/r.random.surface/gasdev.c

@@ -1,13 +1,8 @@
 /* gasdev.c                                                             */
 /* gasdev.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include <math.h>
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
-
 /* GasDev() returns a random double with a mean of 0.0 and a standard   */
 /* GasDev() returns a random double with a mean of 0.0 and a standard   */
 /*      deviation of 1.0.                                               */
 /*      deviation of 1.0.                                               */
 double GasDev(void)
 double GasDev(void)
@@ -21,7 +16,7 @@ double GasDev(void)
     } while (r >= 1.0);
     } while (r >= 1.0);
 
 
     fac = sqrt(-2.0 * log(r) / r);
     fac = sqrt(-2.0 * log(r) / r);
-    DOUBLE(v2 * fac);
+    G_debug(3, "(v2 * fac):%.12lf", v2 * fac);
 
 
     return (v2 * fac);
     return (v2 * fac);
 }
 }

+ 4 - 8
raster/r.random.surface/gennorm.c

@@ -1,19 +1,14 @@
 /* gennorm.c                                                    */
 /* gennorm.c                                                    */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include <math.h>
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include "ransurf.h"
 #include "ransurf.h"
 
 
-
 void GenNorm(void)
 void GenNorm(void)
 {
 {
     double t, b, c, sqr;
     double t, b, c, sqr;
     int i;
     int i;
 
 
-    FUNCTION(GenNorm);
+    G_debug(2, "GenNorm()");
 
 
     Norm = (double *)G_malloc(SIZE_OF_DISTRIBUTION * sizeof(double));
     Norm = (double *)G_malloc(SIZE_OF_DISTRIBUTION * sizeof(double));
     sqr = 1 / sqrt(2 * PI);
     sqr = 1 / sqrt(2 * PI);
@@ -22,8 +17,9 @@ void GenNorm(void)
 	t = ((double)(i - SIZE_OF_DISTRIBUTION / 2)) * DELTA_T;
 	t = ((double)(i - SIZE_OF_DISTRIBUTION / 2)) * DELTA_T;
 	b = exp(-t * t / 2.0) * sqr * DELTA_T;
 	b = exp(-t * t / 2.0) * sqr * DELTA_T;
 	c = c + b;
 	c = c + b;
-	DOUBLE(c);
+	G_debug(3, "(c):%.12lf", c);
 	Norm[i] = c;
 	Norm[i] = c;
     }
     }
-    RETURN;
+
+    return;
 }
 }

+ 24 - 38
raster/r.random.surface/init.c

@@ -1,8 +1,4 @@
 /* init.c                                                               */
 /* init.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
@@ -15,7 +11,6 @@
 #include "local_proto.h"
 #include "local_proto.h"
 
 
 
 
-
 void Init(void)
 void Init(void)
 {
 {
     struct Cell_head Region;
     struct Cell_head Region;
@@ -24,7 +19,7 @@ void Init(void)
     char msg[128], msg2[64];
     char msg[128], msg2[64];
     double MinRes;
     double MinRes;
 
 
-    FUNCTION(Init);
+    G_debug(2, "Init");
 
 
     Rs = G_window_rows();
     Rs = G_window_rows();
     Cs = G_window_cols();
     Cs = G_window_cols();
@@ -47,7 +42,7 @@ void Init(void)
     }
     }
     else {
     else {
 	if ((FDM = G_open_cell_old("MASK", G_mapset())) < 0) {
 	if ((FDM = G_open_cell_old("MASK", G_mapset())) < 0) {
-	    G_fatal_error(" unable to open MASK");
+	    G_fatal_error(_("Unable to open raster map <%s>"), "MASK");
 	}
 	}
 	else {
 	else {
 	    MapCount = 0;
 	    MapCount = 0;
@@ -76,7 +71,7 @@ void Init(void)
     }
     }
 
 
     if (1 >= High)
     if (1 >= High)
-	G_fatal_error("high [%d] must be greater than 1", High);
+	G_fatal_error(_("High (%d) must be greater than 1"), High);
 
 
     CatInfo.NumCat = High;
     CatInfo.NumCat = High;
     NumMaps = 0;
     NumMaps = 0;
@@ -85,8 +80,8 @@ void Init(void)
 	for (j = i - 1; j >= 0; j--) {
 	for (j = i - 1; j >= 0; j--) {
 	    if (strcmp(OutNames[j], Name) == 0)
 	    if (strcmp(OutNames[j], Name) == 0)
 		G_fatal_error
 		G_fatal_error
-		    ("%s: Random map [%s] repeated, maps must be unique",
-		     G_program_name(), Name);
+		    (_("Rastar map <%s> repeated, maps must be unique"),
+		     Name);
 	}
 	}
 
 
 	OutNames = (char **)G_realloc(OutNames, (i + 1) * sizeof(char *));
 	OutNames = (char **)G_realloc(OutNames, (i + 1) * sizeof(char *));
@@ -95,7 +90,7 @@ void Init(void)
 	NumMaps++;
 	NumMaps++;
     }
     }
     if (NumMaps == 0)
     if (NumMaps == 0)
-	G_fatal_error("%s: requires an output map", G_program_name());
+	G_fatal_error(_("Output raster map required"));
 
 
     Theory = 0;
     Theory = 0;
     NumSeeds = 0;
     NumSeeds = 0;
@@ -111,7 +106,7 @@ void Init(void)
 	    sscanf(Number, "%d", &(Seeds[i]));
 	    sscanf(Number, "%d", &(Seeds[i]));
 	    if (Seeds[i] > SEED_MAX) {
 	    if (Seeds[i] > SEED_MAX) {
 
 
-		sprintf(msg, _("Seed [%d] larger than maximum [%d]"),
+		sprintf(msg, _("Seed (%d) larger than maximum (%d)"),
 			Seeds[i], SEED_MAX);
 			Seeds[i], SEED_MAX);
 		Seeds[i] = Seeds[i] % SEED_MAX;
 		Seeds[i] = Seeds[i] % SEED_MAX;
 		sprintf(msg2, _(" seed is set to %d"), Seeds[i]);
 		sprintf(msg2, _(" seed is set to %d"), Seeds[i]);
@@ -119,7 +114,7 @@ void Init(void)
 		G_warning(msg);
 		G_warning(msg);
 	    }
 	    }
 	    else if (Seeds[i] < SEED_MIN) {
 	    else if (Seeds[i] < SEED_MIN) {
-		sprintf(msg, _("Seed [%d] smaller than minimum [%d]"),
+		sprintf(msg, _("Seed (%d) smaller than minimum (%d)"),
 			Seeds[i], SEED_MIN);
 			Seeds[i], SEED_MIN);
 		while (Seeds[i] < SEED_MIN)
 		while (Seeds[i] < SEED_MIN)
 		    Seeds[i] += SEED_MAX - SEED_MIN;
 		    Seeds[i] += SEED_MAX - SEED_MIN;
@@ -162,9 +157,8 @@ void Init(void)
     if (Distance->answer) {
     if (Distance->answer) {
 	sscanf(Distance->answer, "%lf", &(AllFilters[NumDist].MaxDist));
 	sscanf(Distance->answer, "%lf", &(AllFilters[NumDist].MaxDist));
 	if (AllFilters[NumDist].MaxDist < 0.0)
 	if (AllFilters[NumDist].MaxDist < 0.0)
-	    G_fatal_error("%s: distance value[%d]: [%lf] must be >= 0.0",
-			  G_program_name(), NumDist,
-			  AllFilters[NumDist].MaxDist);
+	    G_fatal_error(_("Distance value (%d): %lf must be >= 0.0"),
+			  NumDist, AllFilters[NumDist].MaxDist);
 
 
 	NumDist++;
 	NumDist++;
     }
     }
@@ -191,8 +185,8 @@ void Init(void)
     if (Exponent->answer) {
     if (Exponent->answer) {
 	sscanf(Exponent->answer, "%lf", &(AllFilters[NumExp].Exp));
 	sscanf(Exponent->answer, "%lf", &(AllFilters[NumExp].Exp));
 	if (AllFilters[NumExp].Exp <= 0.0)
 	if (AllFilters[NumExp].Exp <= 0.0)
-	    G_fatal_error("%s: exponent value [%lf] must be > 0.0",
-			  G_program_name(), AllFilters[NumExp].Exp);
+	    G_fatal_error(_("Exponent value (%lf) must be > 0.0"),
+			  AllFilters[NumExp].Exp);
 
 
 	NumExp++;
 	NumExp++;
     }
     }
@@ -215,10 +209,9 @@ void Init(void)
     if (Weight->answer) {
     if (Weight->answer) {
 	sscanf(Weight->answer, "%lf", &(AllFilters[NumWeight].Mult));
 	sscanf(Weight->answer, "%lf", &(AllFilters[NumWeight].Mult));
 	if (AllFilters[NumWeight].Mult > AllFilters[NumWeight].MaxDist)
 	if (AllFilters[NumWeight].Mult > AllFilters[NumWeight].MaxDist)
-	    G_fatal_error
-		("%s: flat value [%lf] must be less than distance value [%lf]",
-		 G_program_name(), AllFilters[NumWeight].Mult,
-		 AllFilters[NumWeight].MaxDist);
+	    G_fatal_error(_("Flat value (%lf) must be less than distance value (%lf)"),
+			  AllFilters[NumWeight].Mult,
+			  AllFilters[NumWeight].MaxDist);
 
 
 	NumWeight++;
 	NumWeight++;
     }
     }
@@ -237,8 +230,7 @@ void Init(void)
     }
     }
 
 
     if (NumDist > 1 && NumDist < NumFilters)
     if (NumDist > 1 && NumDist < NumFilters)
-	G_fatal_error("%s: must have a distance value for each filter",
-		      G_program_name());
+	G_fatal_error(_("Must have a distance value for each filter"));
 
 
     if (NumDist == 0) {
     if (NumDist == 0) {
 	AllFilters[0].MaxDist = MinRes / 4.0;
 	AllFilters[0].MaxDist = MinRes / 4.0;
@@ -270,8 +262,7 @@ void Init(void)
     }
     }
 
 
     if (NumExp > 1 && NumExp < NumFilters)
     if (NumExp > 1 && NumExp < NumFilters)
-	G_fatal_error("%s: must have a exponent value for each filter",
-		      G_program_name());
+	G_fatal_error(_("Must have a exponent value for each filter"));
 
 
     if (NumWeight > 0) {
     if (NumWeight > 0) {
 	sprintf(String, " flat=");
 	sprintf(String, " flat=");
@@ -280,7 +271,7 @@ void Init(void)
 	    sprintf(String, "%.*lf,",
 	    sprintf(String, "%.*lf,",
 		    Digits(AllFilters[i].Mult, 6), AllFilters[i].Mult);
 		    Digits(AllFilters[i].Mult, 6), AllFilters[i].Mult);
 	    strcat(Buf, String);
 	    strcat(Buf, String);
-	    DOUBLE(AllFilters[i].Mult);
+	    G_debug(3, "(AllFilters[i].Mult):%.12lf", AllFilters[i].Mult);
 	}
 	}
 	sprintf(String, "%.*lf",
 	sprintf(String, "%.*lf",
 		Digits(AllFilters[i].Mult, 6), AllFilters[i].Mult);
 		Digits(AllFilters[i].Mult, 6), AllFilters[i].Mult);
@@ -288,8 +279,7 @@ void Init(void)
     }
     }
 
 
     if (NumWeight > 1 && NumWeight < NumFilters)
     if (NumWeight > 1 && NumWeight < NumFilters)
-	G_fatal_error("%s: must have a weight value for each filter",
-		      G_program_name());
+	G_fatal_error(_("Must have a weight value for each filter"));
 
 
     if (NumExp == 1) {
     if (NumExp == 1) {
 	for (NumExp = 1; NumExp < NumFilters; NumExp++)
 	for (NumExp = 1; NumExp < NumFilters; NumExp++)
@@ -305,20 +295,17 @@ void Init(void)
 	for (NumWeight = 0; NumWeight < NumFilters; NumWeight++)
 	for (NumWeight = 0; NumWeight < NumFilters; NumWeight++)
 	    AllFilters[NumWeight].Mult = 0.0;
 	    AllFilters[NumWeight].Mult = 0.0;
     }
     }
-    RETURN;
 
 
     AllMaxDist = 0.0;
     AllMaxDist = 0.0;
     for (i = 0; i < NumFilters; i++) {
     for (i = 0; i < NumFilters; i++) {
 	if (AllMaxDist < AllFilters[i].MaxDist)
 	if (AllMaxDist < AllFilters[i].MaxDist)
 	    AllMaxDist = AllFilters[i].MaxDist;
 	    AllMaxDist = AllFilters[i].MaxDist;
 	AllFilters[i].MaxSq = AllFilters[i].MaxDist * AllFilters[i].MaxDist;
 	AllFilters[i].MaxSq = AllFilters[i].MaxDist * AllFilters[i].MaxDist;
-	INT(i);
-	DOUBLE(AllFilters[i].Mult);
-	DOUBLE(AllFilters[i].MaxDist);
-	RETURN;
-	DOUBLE(AllFilters[i].MaxSq);
-	DOUBLE(AllFilters[i].Exp);
-	RETURN;
+	G_debug(3, "(i):%d", i);
+	G_debug(3, "(AllFilters[i].Mult):%.12lf", AllFilters[i].Mult);
+	G_debug(3, "(AllFilters[i].MaxDist):%.12lf", AllFilters[i].MaxDist);
+	G_debug(3, "(AllFilters[i].MaxSq):%.12lf", AllFilters[i].MaxSq);
+	G_debug(3, "(AllFilters[i].Exp):%.12lf", AllFilters[i].Exp);
     }
     }
 
 
     BigF.RowPlus = AllMaxDist / NS;
     BigF.RowPlus = AllMaxDist / NS;
@@ -333,4 +320,3 @@ void Init(void)
 
 
     AllMaxDist *= 2.0;
     AllMaxDist *= 2.0;
 }
 }
-

+ 30 - 27
raster/r.random.surface/main.c

@@ -13,7 +13,7 @@
  *               Jachym Cepicky <jachym les-ejk.cz>, 
  *               Jachym Cepicky <jachym les-ejk.cz>, 
  *               Jan-Oliver Wagner <jan intevation.de>
  *               Jan-Oliver Wagner <jan intevation.de>
  * PURPOSE:      generates a spatially dependent random surface
  * PURPOSE:      generates a spatially dependent random surface
- * COPYRIGHT:    (C) 2000-2006 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2000-2008 by the GRASS Development Team
  *
  *
  *               This program is free software under the GNU General Public
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
  *               License (>=v2). Read the file COPYING that comes with GRASS
@@ -26,9 +26,6 @@
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
 #include <grass/glocale.h>
 
 
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
@@ -40,8 +37,8 @@ FILTER *AllFilters, Filter;
 CATINFO CatInfo;
 CATINFO CatInfo;
 int *Seeds, Seed, NumSeeds, Low, High, NumMaps, NumFilters, OutFD;
 int *Seeds, Seed, NumSeeds, Low, High, NumMaps, NumFilters, OutFD;
 char Buf[240], **OutNames, *TheoryName, *Mapset;
 char Buf[240], **OutNames, *TheoryName, *Mapset;
-struct Flag *Uniform;
 
 
+struct Flag *Uniform;
 struct Option *Distance, *Exponent, *Weight;
 struct Option *Distance, *Exponent, *Weight;
 struct Option *Output;
 struct Option *Output;
 struct Option *range_high_stuff;
 struct Option *range_high_stuff;
@@ -50,14 +47,13 @@ struct Option *SeedStuff;
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
     struct GModule *module;
     struct GModule *module;
-    int DoMap, DoFilter, MapSeed;
 
 
-    FUNCTION(main);
+    int DoMap, DoFilter, MapSeed;
 
 
     G_gisinit(argv[0]);
     G_gisinit(argv[0]);
 
 
     module = G_define_module();
     module = G_define_module();
-    module->keywords = _("raster");
+    module->keywords = _("raster, random, surface");
     module->description =
     module->description =
 	_("Generates random surface(s) with spatial dependence.");
 	_("Generates random surface(s) with spatial dependence.");
 
 
@@ -66,7 +62,7 @@ int main(int argc, char **argv)
     Output->type = TYPE_STRING;
     Output->type = TYPE_STRING;
     Output->required = YES;
     Output->required = YES;
     Output->multiple = YES;
     Output->multiple = YES;
-    Output->description = "Names of the resulting maps";
+    Output->description = _("Name for output raster map(s)");
     Output->gisprompt = "new,cell,raster";
     Output->gisprompt = "new,cell,raster";
 
 
     Distance = G_define_option();
     Distance = G_define_option();
@@ -75,15 +71,16 @@ int main(int argc, char **argv)
     Distance->required = NO;
     Distance->required = NO;
     Distance->multiple = NO;
     Distance->multiple = NO;
     Distance->description =
     Distance->description =
-	"Input value: max. distance of spatial correlation (value >= 0.0, default [0.0])";
+	_("Maximum distance of spatial correlation (value >= 0.0)");
+    Distance->answer = "0.0";
 
 
     Exponent = G_define_option();
     Exponent = G_define_option();
     Exponent->key = "exponent";
     Exponent->key = "exponent";
     Exponent->type = TYPE_DOUBLE;
     Exponent->type = TYPE_DOUBLE;
     Exponent->multiple = NO;
     Exponent->multiple = NO;
     Exponent->required = NO;
     Exponent->required = NO;
-    Exponent->description =
-	"Input value: distance decay exponent (value > 0.0), default [1.0])";
+    Exponent->description = _("Distance decay exponent (value > 0.0)");
+    Exponent->answer = "1.0";
 
 
     Weight = G_define_option();
     Weight = G_define_option();
     Weight->key = "flat";
     Weight->key = "flat";
@@ -91,39 +88,44 @@ int main(int argc, char **argv)
     Weight->multiple = NO;
     Weight->multiple = NO;
     Weight->required = NO;
     Weight->required = NO;
     Weight->description =
     Weight->description =
-	"Input value: distance filter remains flat before beginning exponent, default [0.0]";
+	_("Distance filter remains flat before beginning exponent");
+    Weight->answer = "0.0";
 
 
     SeedStuff = G_define_option();
     SeedStuff = G_define_option();
     SeedStuff->key = "seed";
     SeedStuff->key = "seed";
     SeedStuff->type = TYPE_INTEGER;
     SeedStuff->type = TYPE_INTEGER;
     SeedStuff->required = NO;
     SeedStuff->required = NO;
     SeedStuff->description =
     SeedStuff->description =
-	"Input value: random seed (SEED_MIN >= value >= SEED_MAX), default [random]";
+	_("Random seed (SEED_MIN >= value >= SEED_MAX), default [random]");
 
 
     range_high_stuff = G_define_option();
     range_high_stuff = G_define_option();
     range_high_stuff->key = "high";
     range_high_stuff->key = "high";
     range_high_stuff->type = TYPE_INTEGER;
     range_high_stuff->type = TYPE_INTEGER;
     range_high_stuff->required = NO;
     range_high_stuff->required = NO;
-    range_high_stuff->description =
-	"Input value: maximum cell value of distribution, default [255]";
+    range_high_stuff->description = _("Maximum cell value of distribution");
+    range_high_stuff->answer = "255";
 
 
     Uniform = G_define_flag();
     Uniform = G_define_flag();
     Uniform->key = 'u';
     Uniform->key = 'u';
-    Uniform->description = "Uniformly distributed cell values";
+    Uniform->description = _("Uniformly distributed cell values");
 
 
     if (G_parser(argc, argv))
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 	exit(EXIT_FAILURE);
 
 
+    Init();
+
     if (Uniform->answer)
     if (Uniform->answer)
 	GenNorm();
 	GenNorm();
+
     CalcSD();
     CalcSD();
+
     for (DoMap = 0; DoMap < NumMaps; DoMap++) {
     for (DoMap = 0; DoMap < NumMaps; DoMap++) {
 	OutFD = G_open_cell_new(OutNames[DoMap]);
 	OutFD = G_open_cell_new(OutNames[DoMap]);
 	if (OutFD < 0)
 	if (OutFD < 0)
-	    G_fatal_error("%s: unable to open [%s] random raster map",
-			  G_program_name(), OutNames[DoMap]);
+	    G_fatal_error(_("Unable to open raster map <%s>"),
+			  OutNames[DoMap]);
 
 
-	G_message(_("Starting map [%s]"), OutNames[DoMap]);
+	G_message(_("Generating raster map <%s>..."), OutNames[DoMap]);
 
 
 	if (Seeds[DoMap] == SEED_MIN - 1)
 	if (Seeds[DoMap] == SEED_MIN - 1)
 	    Seeds[DoMap] = (int)(ran1() * SEED_MAX);
 	    Seeds[DoMap] = (int)(ran1() * SEED_MAX);
@@ -133,12 +135,11 @@ int main(int argc, char **argv)
 
 
 	for (DoFilter = 0; DoFilter < NumFilters; DoFilter++) {
 	for (DoFilter = 0; DoFilter < NumFilters; DoFilter++) {
 	    CopyFilter(&Filter, AllFilters[DoFilter]);
 	    CopyFilter(&Filter, AllFilters[DoFilter]);
-	    G_message(_("Starting filter #%d, distance: %.*lf, exponent: %.*lf, flat: %.*lf"),
-		      DoFilter, Digits(2.0 * Filter.MaxDist, 6),
-		      2.0 * Filter.MaxDist, Digits(1.0 / Filter.Exp, 6),
-		      1.0 / Filter.Exp, Digits(Filter.Mult, 6), Filter.Mult);
-
-	    G_message(_("Percent done:"));
+	    G_debug(1,
+		    "Starting filter #%d, distance: %.*lf, exponent: %.*lf, flat: %.*lf",
+		    DoFilter, Digits(2.0 * Filter.MaxDist, 6),
+		    2.0 * Filter.MaxDist, Digits(1.0 / Filter.Exp, 6),
+		    1.0 / Filter.Exp, Digits(Filter.Mult, 6), Filter.Mult);
 
 
 	    MakeBigF();
 	    MakeBigF();
 	    CalcSurface();
 	    CalcSurface();
@@ -147,5 +148,7 @@ int main(int argc, char **argv)
 	SaveMap(DoMap, MapSeed);
 	SaveMap(DoMap, MapSeed);
     }
     }
 
 
-    return 0;
+    G_done_msg(" ");
+
+    exit(EXIT_SUCCESS);
 }
 }

+ 5 - 11
raster/r.random.surface/makebigf.c

@@ -1,8 +1,4 @@
 /* makebigf.c                                                           */
 /* makebigf.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
@@ -12,15 +8,16 @@ void MakeBigF(void)
     int R, C;
     int R, C;
     double Dist, RDist, CDist;
     double Dist, RDist, CDist;
 
 
-    FUNCTION(MakeBigF);
+    G_debug(2, "MakeBigF");
+
     for (R = 0; R < BigF.NumR; R++) {
     for (R = 0; R < BigF.NumR; R++) {
 	BigF.LowBF[R] = BigF.HihBF[R] = -1;
 	BigF.LowBF[R] = BigF.HihBF[R] = -1;
 	RDist = (R - BigF.RowPlus) * NS;
 	RDist = (R - BigF.RowPlus) * NS;
 	RDist *= RDist;
 	RDist *= RDist;
 
 
 	for (C = 0; C < BigF.NumC; C++) {
 	for (C = 0; C < BigF.NumC; C++) {
-	    INT(R);
-	    INT(C);
+	    G_debug(3, "(R):%d", R);
+	    G_debug(3, "(C):%d", C);
 	    CDist = (C - BigF.ColPlus) * EW;
 	    CDist = (C - BigF.ColPlus) * EW;
 	    CDist *= CDist;
 	    CDist *= CDist;
 	    Dist = sqrt(CDist + RDist);
 	    Dist = sqrt(CDist + RDist);
@@ -35,13 +32,10 @@ void MakeBigF(void)
 		BigF.HihBF[R] = C;
 		BigF.HihBF[R] = C;
 	    }
 	    }
 
 
-	    DOUBLE(BigF.F[R][C]);
-	    RETURN;
+	    G_debug(3, "(BigF.F[R][C]):%.12lf", BigF.F[R][C]);
 	}
 	}
 
 
 	BigF.LowBF[R] -= BigF.ColPlus;
 	BigF.LowBF[R] -= BigF.ColPlus;
 	BigF.HihBF[R] -= BigF.ColPlus;
 	BigF.HihBF[R] -= BigF.ColPlus;
     }
     }
-
-    FUNCTION(end MakeBigF);
 }
 }

+ 5 - 10
raster/r.random.surface/makepp.c

@@ -1,8 +1,4 @@
 /* makepp.c                                                             */
 /* makepp.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "ransurf.h"
 #include "local_proto.h"
 #include "local_proto.h"
 
 
@@ -14,7 +10,7 @@ double MakePP(int Row, int Col, int OutRows, int OutCols,
     int RRow, RCol;
     int RRow, RCol;
     double Effect, Value;
     double Effect, Value;
 
 
-    FUNCTION(MakePP);
+    G_debug(2, "MakePP()");
 
 
     Value = 0.0;
     Value = 0.0;
     RRow = Row + BigF.RowPlus;
     RRow = Row + BigF.RowPlus;
@@ -25,14 +21,13 @@ double MakePP(int Row, int Col, int OutRows, int OutCols,
 
 
 	for (DCol = RCol - BigF.ColPlus; DCol <= RCol + BigF.ColPlus; DCol++) {
 	for (DCol = RCol - BigF.ColPlus; DCol <= RCol + BigF.ColPlus; DCol++) {
 	    DistDecay(&Effect, RRow - DRow, RCol - DCol);
 	    DistDecay(&Effect, RRow - DRow, RCol - DCol);
-	    INT(RRow - DRow);
-	    INT(RCol - DCol);
-	    DOUBLE(Effect);
-	    RETURN;
+	    G_debug(3, "(RRow - DRow):%d", RRow - DRow);
+	    G_debug(3, "(RCol - DCol):%d", RCol - DCol);
+	    G_debug(3, "(Effect):%.12lf", Effect);
+
 	    Value += Effect * Randoms[DRow][DCol];
 	    Value += Effect * Randoms[DRow][DCol];
 	}
 	}
     }
     }
 
 
     return (Value);
     return (Value);
-    FUNCTION(end MakePP);
 }
 }

+ 100 - 109
raster/r.random.surface/r.random.surface.html

@@ -9,7 +9,7 @@ using filter(s) of diameter distance.  The influence of each random value on
 nearby cells is determined by a distance decay function based on exponent.
 nearby cells is determined by a distance decay function based on exponent.
 If multiple filters are passed over the output maps, each filter is given a
 If multiple filters are passed over the output maps, each filter is given a
 weight based on the weight inputs.  The resulting random surface can have
 weight based on the weight inputs.  The resulting random surface can have
-&quot;any&quot; mean and variance, but the theoretical mean of an infinitely
+<em>any</em> mean and variance, but the theoretical mean of an infinitely
 large map is 0.0 and a variance of 1.0. Description of the algorithm is in
 large map is 0.0 and a variance of 1.0. Description of the algorithm is in
 the <b>NOTES</b> section.
 the <b>NOTES</b> section.
 
 
@@ -17,7 +17,7 @@ the <b>NOTES</b> section.
 The random surface generated are composed of floating point numbers, and
 The random surface generated are composed of floating point numbers, and
 saved in the category description files of the output map(s).  Cell values
 saved in the category description files of the output map(s).  Cell values
 are uniformly or normally distributed between 1 and high values inclusive
 are uniformly or normally distributed between 1 and high values inclusive
-(determined by whether the <em>-u</em> flag is used). The category names
+(determined by whether the <b>-u</b> flag is used). The category names
 indicate the average floating point value and the range of floating point
 indicate the average floating point value and the range of floating point
 values that each cell value represents.
 values that each cell value represents.
 
 
@@ -26,68 +26,68 @@ values that each cell value represents.
 spatial error modeling. A procedure to use <em>r.random.surface</em> in
 spatial error modeling. A procedure to use <em>r.random.surface</em> in
 spatial error modeling is given in the <b>NOTES</b> section.
 spatial error modeling is given in the <b>NOTES</b> section.
 
 
-<h3>Parameters:</h3>
+<h3>Parameters</h3>
 <dl>
 <dl>
-<dt><b>output</b>
-<dd>Output map(s): Random surface(s). The cell values are a random
-distribution between the low and high values inclusive.  The category values
-of the output map(s) are in the form &quot;#.# #.# to #.#&quot; where each
-#.# is a floating point number. The first number is the average of the
-random values the cell value represents. The other two numbers are the range
-of random values for that cell value. The &quot;average&quot; mean value of
-generated <tt>output</tt> map(s) is 0. The &quot;average&quot;
-variance of map(s) generated is 1. The random values represent the standard
-deviation from the mean of that random surface.
-
-<dt><b>distance</b>
-<dd>Input value(s) [default 0.0]: distance determines the spatial dependence
-of the output map(s). The distance value indicates the minimum distance at
-which two map cells have no relationship to each other. A distance value of
-0.0 indicates that there is no spatial dependence (i.e., adjacent cell
-values have no relationship to each other). As the distance value increases,
-adjacent cell values will have values closer to each other. But the range
-and distribution of cell values over the output map(s) will remain the same.
-Visually, the clumps of lower and higher values gets larger as distance
-increases. If multiple values are given, each output map will have multiple
-filters, one for each set of distance, exponent, and weight values.
-
-<dt><b>exponent</b>
-<dd>Input value(s) [default 1.0]: exponent determines the distance decay
-exponent for a particular filter. The exponent value(s) have the property of
-determining the &quot;texture&quot; of the random surface. Texture will
-decrease as the exponent value(s) get closer to 1.0. Normally, exponent will
-be 1.0 or less. If there are no exponent values given, each filter will be
-given an exponent value of 1.0. If there is at least one exponent value
-given, there must be one exponent value for each distance value.
-
-<dt><b>flat</b>
-<dd>Input value(s) [default 0.0]: flat determines the distance at which the
-filter
-
-<dt><b>weight</b>
-<dd>Input value(s) [default 1.0]: weight determines the relative importance
-of each filter. For example, if there were two filters driving the algorithm
-and weight=1.0, 2.0 was given in the command line: The second filter would
-be twice as important as the first filter. If no weight values are given,
-each filter will be just as important as the other filters defining the
-random field. If weight values exist, there must be a weight value for each
-filter of the random field.
-
-<dt><b>high</b>
-<dd>Input value [default 255]: Specifies the high end of the range of cell
-values in the output map(s). Specifying a very large high value will
-minimize the &quot;errors&quot; caused by the random surface's
-discretization. The word errors is in quotes because errors in
-discretization are often going to cancel each other out and the spatial
-statistics are far more sensitive to the initial independent random deviates
-than any potential discretization errors.
-
-<dt><b>seed</b>
-<dd>Input value(s) [default random]: Specifies the random seed(s), one for
-each map, that <em>r.random.surface</em> will use to generate the initial
-set of random values that the resulting map is based on. If the random seed
-is not given, <em>r.random.surface</em> will get a seed from the process ID
-number.
+<dt><b>output</b></dt>
+<dd>Random surface(s). The cell values are a random distribution
+between the low and high values inclusive.  The category values of the
+output map(s) are in the form <em>#.# #.# to #.#</em> where each #.#
+is a floating point number. The first number is the average of the
+random values the cell value represents. The other two numbers are the
+range of random values for that cell value. The <em>average</em> mean
+value of generated <tt>output</tt> map(s) is 0. The <em>average</em>
+variance of map(s) generated is 1. The random values represent the
+standard deviation from the mean of that random surface.</dd>
+
+<dt><b>distance</b></dt>
+<dd>Distance determines the spatial dependence of the output
+map(s). The distance value indicates the minimum distance at which two
+map cells have no relationship to each other. A distance value of 0.0
+indicates that there is no spatial dependence (i.e., adjacent cell
+values have no relationship to each other). As the distance value
+increases, adjacent cell values will have values closer to each
+other. But the range and distribution of cell values over the output
+map(s) will remain the same.  Visually, the clumps of lower and higher
+values gets larger as distance increases. If multiple values are
+given, each output map will have multiple filters, one for each set of
+distance, exponent, and weight values.</dd>
+
+<dt><b>exponent</b></dt>
+<dd>Exponent determines the distance decay exponent for a particular
+filter. The exponent value(s) have the property of determining
+the <em>texture</em> of the random surface. Texture will decrease as
+the exponent value(s) get closer to 1.0. Normally, exponent will be
+1.0 or less. If there are no exponent values given, each filter will
+be given an exponent value of 1.0. If there is at least one exponent
+value given, there must be one exponent value for each distance value.</dd>
+
+<dt><b>flat</b></dt>
+<dd>Flat determines the distance at which the filter.</dd>
+
+<dt><b>weight</b></dt>
+<dd>Weight determines the relative importance of each filter. For
+example, if there were two filters driving the algorithm and
+weight=1.0, 2.0 was given in the command line: The second filter would
+be twice as important as the first filter. If no weight values are
+given, each filter will be just as important as the other filters
+defining the random field. If weight values exist, there must be a
+weight value for each filter of the random field.</dd>
+
+<dt><b>high</b></dt>
+<dd>Specifies the high end of the range of cell values in the output
+map(s). Specifying a very large high value will minimize
+the <em>errors</em> caused by the random surface's discretization. The
+word errors is in quotes because errors in discretization are often
+going to cancel each other out and the spatial statistics are far more
+sensitive to the initial independent random deviates than any
+potential discretization errors.</dd>
+
+<dt><b>seed</b></dt>
+<dd>Specifies the random seed(s), one for each map,
+that <em>r.random.surface</em> will use to generate the initial set of
+random values that the resulting map is based on. If the random seed
+is not given, <em>r.random.surface</em> will get a seed from the
+process ID number.</dd>
 
 
 </dl>
 </dl>
 
 
@@ -110,65 +110,56 @@ ignore the current mask for the same reason.
 <p>
 <p>
 One of the most important uses for <em>r.random.surface</em> is to determine
 One of the most important uses for <em>r.random.surface</em> is to determine
 how the error inherent in raster maps might effect the analyses done with
 how the error inherent in raster maps might effect the analyses done with
-those maps. If you wanted to check to see how sensitive your analysis is to
-the errors in the DEMs in your study area, see:
-
-<p>&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/CGFinal/paper.htm">Visualizing Spatial Data Uncertainty Using Animation (final draft)</a>,&quot; by Charles R. Ehlschlaeger, Ashton M. Shortridge, and Michael F. Goodchild. Submitted to Computers in GeoSciences in September, 1996, accepted October, 1996 for publication in June, 1997.
-
-<p>
-&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/SDH96/paper.html">Modeling Uncertainty in Elevation Data for Geographical Analysis</a>&quot;, by Charles R. Ehlschlaeger, and Ashton M. Shortridge. Proceedings of the 7th International Symposium on Spatial Data Handling, Delft, Netherlands, August 1996. </p>
-
-<p>
-&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing with Uncertainty in Categorical Coverage Maps: Defining, Visualizing, and Managing Data Errors</a>&quot;, by Charles Ehlschlaeger and Michael Goodchild. Proceedings, Workshop on Geographic Information Systems at the Conference on Information and Knowledge Management, Gaithersburg MD, 1994.
-
-<p>
-&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty in Spatial Data: Defining, Visualizing, and Managing Data Errors</a>&quot;, by Charles Ehlschlaeger and Michael Goodchild. Proceedings, GIS/LIS'94, pp. 246-253, Phoenix AZ,
-1994.
-
-<p>
-If you are interested in creating potential realizations of categorical
-coverage maps, see <em>r.random.model</em>.
-
-<h2>SEE ALSO</h2>
-
-<em><a href="r.random.html">r.random</a>, 
-<a href="r.mapcalc.html">r.mapcalc</a>
-</em>
+those maps.
 
 
 <h2>REFERENCES</h2>
 <h2>REFERENCES</h2>
-Random Field Software for GRASS by Chuck Ehlschlaeger<p>
+Random Field Software for GRASS by Chuck Ehlschlaeger
 
 
-<p>As part of my dissertation, I put together several programs that help
+<p>
+  As part of my dissertation, I put together several programs that help
 GRASS (4.1 and beyond) develop uncertainty models of spatial data. I hope
 GRASS (4.1 and beyond) develop uncertainty models of spatial data. I hope
 you find it useful and dependable. The following papers might clarify their
 you find it useful and dependable. The following papers might clarify their
-use: </p>
+use:
 
 
-<p>&quot;<a href="../../CGFinal/paper.htm">Visualizing Spatial Data
-Uncertainty Using Animation (final draft)</a>,&quot; by Charles R.
+<ul>
+<li><a href="../../CGFinal/paper.htm">Visualizing Spatial Data
+Uncertainty Using Animation (final draft)</a>, by Charles R.
 Ehlschlaeger, Ashton M. Shortridge, and Michael F. Goodchild. Submitted to
 Ehlschlaeger, Ashton M. Shortridge, and Michael F. Goodchild. Submitted to
 Computers in GeoSciences in September, 1996, accepted October, 1996 for
 Computers in GeoSciences in September, 1996, accepted October, 1996 for
-publication in June, 1997. </p>
-
-<p>&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/paper.html">Modeling Uncertainty in Elevation Data for
-Geographical Analysis</a>&quot;, by Charles R. Ehlschlaeger, and Ashton M.
-Shortridge. Proceedings of the 7th International Symposium on Spatial Data
-Handling, Delft, Netherlands, August 1996. </p>
+publication in June, 1997.</li>
+
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/paper.html">Modeling
+Uncertainty in Elevation Data for Geographical Analysis</a>, by
+Charles R. Ehlschlaeger, and Ashton M.  Shortridge. Proceedings of the
+7th International Symposium on Spatial Data Handling, Delft,
+Netherlands, August 1996.</li>
+
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing
+with Uncertainty in Categorical Coverage Maps: Defining, Visualizing,
+and Managing Data Errors</a>, by Charles Ehlschlaeger and Michael
+Goodchild.  Proceedings, Workshop on Geographic Information Systems at
+the Conference on Information and Knowledge Management, Gaithersburg
+MD, 1994.</li>
+
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty
+in Spatial Data: Defining, Visualizing, and Managing Data
+Errors</a>, by Charles Ehlschlaeger and Michael
+Goodchild. Proceedings, GIS/LIS'94, pp. 246-253, Phoenix AZ,
+1994.</li>
+</ul>
 
 
-<p>&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing with Uncertainty in
-Categorical Coverage Maps: Defining, Visualizing, and Managing Data
-Errors</a>&quot;, by Charles Ehlschlaeger and Michael Goodchild.
-Proceedings, Workshop on Geographic Information Systems at the Conference on
-Information and Knowledge Management, Gaithersburg MD, 1994. </p>
-
-<p>&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty in Spatial Data:
-Defining, Visualizing, and Managing Data Errors</a>&quot;, by Charles
-Ehlschlaeger and Michael Goodchild. Proceedings, GIS/LIS'94, pp. 246-253,
-Phoenix AZ, 1994. </p>
+<h2>SEE ALSO</h2>
 
 
+<em>
+  <a href="r.random.html">r.random</a>, 
+  <a href="r.random.cell.html">r.random.cell</a>, 
+  <a href="r.mapcalc.html">r.mapcalc</a>
+</em>
 
 
 <h2>AUTHORS</h2>
 <h2>AUTHORS</h2>
 Charles Ehlschlaeger, Michael Goodchild, and Chih-chang Lin; National Center
 Charles Ehlschlaeger, Michael Goodchild, and Chih-chang Lin; National Center
 for Geographic Information and Analysis, University of California, Santa
 for Geographic Information and Analysis, University of California, Santa
 Barbara.
 Barbara.
 
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

+ 1 - 19
raster/r.random.surface/random.c

@@ -1,12 +1,7 @@
 /* random.c                                                             */
 /* random.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include "ransurf.h"
 #include "ransurf.h"
 
 
-
 #define M1 259200
 #define M1 259200
 #define IA1 7141
 #define IA1 7141
 #define IC1 54773
 #define IC1 54773
@@ -19,7 +14,6 @@
 #define IA3 4561
 #define IA3 4561
 #define IC3 51349
 #define IC3 51349
 
 
-
 /* ran1() returns a double with a value between 0.0 and 1.0             */
 /* ran1() returns a double with a value between 0.0 and 1.0             */
 double ran1(void)
 double ran1(void)
 {
 {
@@ -29,7 +23,7 @@ double ran1(void)
     static int iff = 0;
     static int iff = 0;
     int j;
     int j;
 
 
-    FUNCTION(ran1);
+    G_debug(2, "ran1()");
 
 
     if (Seed < 0 || iff == 0) {
     if (Seed < 0 || iff == 0) {
 	iff = 1;
 	iff = 1;
@@ -59,15 +53,3 @@ double ran1(void)
 
 
     return temp;
     return temp;
 }
 }
-
-#undef M1
-#undef IA1
-#undef IC1
-#undef RM1
-#undef M2
-#undef IA2
-#undef IC2
-#undef RM2
-#undef M3
-#undef IA3
-#undef IC3

+ 0 - 21
raster/r.random.surface/ransurf.h

@@ -53,25 +53,4 @@ extern struct Option *Distance, *Exponent, *Weight;
 extern struct Option *Output;
 extern struct Option *Output;
 extern struct Option *range_high_stuff;
 extern struct Option *range_high_stuff;
 extern struct Option *SeedStuff;
 extern struct Option *SeedStuff;
-
-#ifdef DEBUG
-#define INDX(a,b) (printf("(a)[%d]:%lf ",(b),(a)[(b)]))
-#define CHARS(a) (printf("(a):%s ",(a)))
-#define DOUBLE(a) (printf("(a):%.12lf ",(a)))
-#define INT(a) (printf("(a):%d ",(a)))
-#define RETURN (printf("\n"))
-#else
-#define INDX(a,b)
-#define CHARS(a)
-#define DOUBLE(a)
-#define INT(a)
-#define RETURN
-#endif
-
-#ifdef TRACE
-#define FUNCTION(a) (printf("Function:(a)\n"))
-#else
-#define FUNCTION(a)
-#endif
-
 #endif
 #endif

+ 15 - 20
raster/r.random.surface/save.c

@@ -1,8 +1,4 @@
 /* save.c                                                               */
 /* save.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
 #include <string.h>
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
 #include <grass/glocale.h>
@@ -19,15 +15,15 @@ void SaveMap(int NumMap, int MapSeed)
     char String[80], Label[240];
     char String[80], Label[240];
     struct History history;
     struct History history;
 
 
-    FUNCTION(SaveMap);
+    G_debug(2, "SaveMap()");
 
 
     OutFD = G_open_cell_new(OutNames[NumMap]);
     OutFD = G_open_cell_new(OutNames[NumMap]);
     if (OutFD < 0)
     if (OutFD < 0)
-	G_fatal_error("%s: unable to open new raster map [%s]",
-		      G_program_name(), OutNames[NumMap]);
+	G_fatal_error(_("Unable to create raster map <%s>"),
+		      OutNames[NumMap]);
 
 
     MeanMod = 0.0;
     MeanMod = 0.0;
-    INT(FDM);
+    G_debug(3, "(FDM):%d", FDM);
     if (FDM == -1) {
     if (FDM == -1) {
 	for (Row = 0; Row < Rs; Row++) {
 	for (Row = 0; Row < Rs; Row++) {
 	    for (Col = 0; Col < Cs; Col++) {
 	    for (Col = 0; Col < Cs; Col++) {
@@ -70,12 +66,12 @@ void SaveMap(int NumMap, int MapSeed)
 	}
 	}
 
 
 	MeanMod /= MapCount;
 	MeanMod /= MapCount;
-	DOUBLE(MeanMod);
-	DOUBLE(FilterSD);
+	G_debug(3, "(MeanMod):%.12lf", MeanMod);
+	G_debug(3, "(FilterSD):%.12lf", FilterSD);
 	/* Value = (Value - MeanMod) / FilterSD + MeanMod / FilterSD; */
 	/* Value = (Value - MeanMod) / FilterSD + MeanMod / FilterSD; */
 	Value /= FilterSD;
 	Value /= FilterSD;
-	DOUBLE(Value);
-	RETURN;
+	G_debug(3, "(Value):%.12lf", Value);
+
 	DownInterval = UpInterval = Value;
 	DownInterval = UpInterval = Value;
 
 
 	for (Row = 0; Row < Rs; Row++) {
 	for (Row = 0; Row < Rs; Row++) {
@@ -100,8 +96,7 @@ void SaveMap(int NumMap, int MapSeed)
 	}
 	}
     }
     }
 
 
-    G_message(_("%s: saving [%s] raster map layer.\nPercent complete:"),
-	      G_program_name(), OutNames[NumMap]);
+    G_message(_("Writing raster map <%s>..."), OutNames[NumMap]);
 
 
     for (Index = 0; Index < CatInfo.NumCat; Index++) {
     for (Index = 0; Index < CatInfo.NumCat; Index++) {
 	CatInfo.Max[Index] = DownInterval;
 	CatInfo.Max[Index] = DownInterval;
@@ -114,7 +109,6 @@ void SaveMap(int NumMap, int MapSeed)
 	UpInterval += .1;
 	UpInterval += .1;
 
 
     if (!Uniform->answer) {
     if (!Uniform->answer) {
-	FUNCTION(NOT_UNIFORM);
 	/* normal distribution */
 	/* normal distribution */
 	for (Row = 0; Row < Rs; Row++) {
 	for (Row = 0; Row < Rs; Row++) {
 	    for (Col = 0; Col < Cs; Col++) {
 	    for (Col = 0; Col < Cs; Col++) {
@@ -170,12 +164,13 @@ void SaveMap(int NumMap, int MapSeed)
     }
     }
 
 
     for (Row = 0; Row < Rs; Row++) {
     for (Row = 0; Row < Rs; Row++) {
+	G_percent(Row, Rs, 2);
 	for (Col = 0; Col < Cs; Col++) {
 	for (Col = 0; Col < Cs; Col++) {
 	    CellBuffer[Col] = (CELL) Surface[Row][Col];
 	    CellBuffer[Col] = (CELL) Surface[Row][Col];
 	}
 	}
 	G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
 	G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
-	G_percent(Row + 1, Rs, 1);
     }
     }
+    G_percent(1, 1, 1);
 
 
     G_close_cell(OutFD);
     G_close_cell(OutFD);
     G_short_history(OutNames[NumMap], "raster", &history);
     G_short_history(OutNames[NumMap], "raster", &history);
@@ -212,13 +207,13 @@ void SaveMap(int NumMap, int MapSeed)
 	LowColor = 0;
 	LowColor = 0;
     if (Uniform->answer || HighColor > 255)
     if (Uniform->answer || HighColor > 255)
 	HighColor = 255;
 	HighColor = 255;
-    INT(LowColor);
-    INT(HighColor);
+    G_debug(3, "(LowColor):%d", LowColor);
+    G_debug(3, "(HighColor):%d", HighColor);
 
 
     G_add_color_rule(1, LowColor, LowColor, LowColor,
     G_add_color_rule(1, LowColor, LowColor, LowColor,
 		     High, HighColor, HighColor, HighColor, &Colr);
 		     High, HighColor, HighColor, HighColor, &Colr);
 
 
     if (G_write_colors(OutNames[NumMap], G_mapset(), &Colr) == -1)
     if (G_write_colors(OutNames[NumMap], G_mapset(), &Colr) == -1)
-	G_warning("%s: unable to write colr file for %s\n",
-		  G_program_name(), OutNames[NumMap]);
+	G_warning(_("Unable to write color table for raster map <%s>"),
+		  OutNames[NumMap]);
 }
 }

+ 1 - 1
raster/r.random.surface/zero.c

@@ -10,7 +10,7 @@ void ZeroMapCells(void)
 {
 {
     int Row, Col;
     int Row, Col;
 
 
-    FUNCTION(ZeroMapCells);
+    G_debug(2, "ZeroMapCells()");
 
 
     for (Row = 0; Row < Rs; Row++) {
     for (Row = 0; Row < Rs; Row++) {
 	for (Col = 0; Col < Cs; Col++)
 	for (Col = 0; Col < Cs; Col++)