[GRASS-SVN] r53158 - grass/trunk/raster/r.slope.aspect

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 10 16:47:11 PDT 2012


Author: hamish
Date: 2012-09-10 16:47:11 -0700 (Mon, 10 Sep 2012)
New Revision: 53158

Removed:
   grass/trunk/raster/r.slope.aspect/local_proto.h
   grass/trunk/raster/r.slope.aspect/opennew.c
Modified:
   grass/trunk/raster/r.slope.aspect/main.c
   grass/trunk/raster/r.slope.aspect/r.slope.aspect.html
Log:
prec= renamed to precision=; CELL,FCELL,DCELL instead of int,float,double for raster map type

Deleted: grass/trunk/raster/r.slope.aspect/local_proto.h
===================================================================
--- grass/trunk/raster/r.slope.aspect/local_proto.h	2012-09-10 23:19:06 UTC (rev 53157)
+++ grass/trunk/raster/r.slope.aspect/local_proto.h	2012-09-10 23:47:11 UTC (rev 53158)
@@ -1,2 +0,0 @@
-/* opennew.c */
-int opennew(const char *, RASTER_MAP_TYPE);

Modified: grass/trunk/raster/r.slope.aspect/main.c
===================================================================
--- grass/trunk/raster/r.slope.aspect/main.c	2012-09-10 23:19:06 UTC (rev 53157)
+++ grass/trunk/raster/r.slope.aspect/main.c	2012-09-10 23:47:11 UTC (rev 53158)
@@ -28,7 +28,6 @@
 #include <grass/gis.h>
 #include <grass/raster.h>
 #include <grass/glocale.h>
-#include "local_proto.h"
 
 /* 10/99 from GMSL, updated to new GRASS 5 code style , changed default "prec" to float */
 
@@ -86,7 +85,7 @@
     void *dyy_raster, *dyy_ptr = NULL;
     void *dxy_raster, *dxy_ptr = NULL;
     int i;
-    RASTER_MAP_TYPE out_type = 0, data_type;
+    RASTER_MAP_TYPE out_type, data_type;
     int Wrap;			/* global wraparound */
     struct Cell_head window, cellhd;
     struct History hist;
@@ -179,13 +178,12 @@
     parm.slope_fmt->guisection = _("Settings");
 
     parm.out_precision = G_define_option();
-    parm.out_precision->key = "prec";
+    parm.out_precision->key = "precision";
     parm.out_precision->type = TYPE_STRING;
-    parm.out_precision->required = NO;
-    parm.out_precision->answer = "float";
-    parm.out_precision->options = "default,double,float,int";
+    parm.out_precision->options = "CELL,FCELL,DCELL";
     parm.out_precision->description =
 	_("Type of output aspect and slope maps");
+    parm.out_precision->answer = "FCELL";
     parm.out_precision->guisection = _("Settings");
 
     parm.pcurv = G_define_standard_option(G_OPT_R_OUTPUT);
@@ -262,6 +260,10 @@
     flag.a->guisection = _("Settings");
 
 
+    if (G_parser(argc, argv))
+	exit(EXIT_FAILURE);
+
+
     radians_to_degrees = 180.0 / M_PI;
     degrees_to_radians = M_PI / 180.0;
 
@@ -285,8 +287,6 @@
 	answer[i] = tan_ans * tan_ans;
     }
 
-    if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);
 
     elev_name = parm.elevation->answer;
     slope_name = parm.slope->answer;
@@ -346,22 +346,19 @@
 	Rast_set_window(&window);
     }
 
-    if (strcmp(parm.out_precision->answer, "double") == 0)
+    if (strcmp(parm.out_precision->answer, "DCELL") == 0)
 	out_type = DCELL_TYPE;
-    else if (strcmp(parm.out_precision->answer, "float") == 0)
+    else if (strcmp(parm.out_precision->answer, "FCELL") == 0)
 	out_type = FCELL_TYPE;
-    else if (strcmp(parm.out_precision->answer, "int") == 0)
+    else if (strcmp(parm.out_precision->answer, "CELL") == 0)
 	out_type = CELL_TYPE;
-    else if (strcmp(parm.out_precision->answer, "default") == 0)
-	out_type = -1;
     else
 	G_fatal_error(_("Wrong raster type: %s"), parm.out_precision->answer);
 
     data_type = out_type;
-    if (data_type < 0)
-	data_type = DCELL_TYPE;
     /* data type is the type of data being processed,
        out_type is type of map being created */
+    /* ? why not use Rast_map_type() then ? */
 
     G_get_set_window(&window);
 
@@ -423,7 +420,7 @@
     Rast_set_d_null_value(elev_cell[2], ncols);
 
     if (slope_name != NULL) {
-	slope_fd = opennew(slope_name, out_type);
+	slope_fd = Rast_open_new(slope_name, out_type);
 	slp_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(slp_raster, Rast_window_cols(), data_type);
 	Rast_put_row(slope_fd, slp_raster, data_type);
@@ -434,7 +431,7 @@
     }
 
     if (aspect_name != NULL) {
-	aspect_fd = opennew(aspect_name, out_type);
+	aspect_fd = Rast_open_new(aspect_name, out_type);
 	asp_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(asp_raster, Rast_window_cols(), data_type);
 	Rast_put_row(aspect_fd, asp_raster, data_type);
@@ -445,7 +442,7 @@
     }
 
     if (pcurv_name != NULL) {
-	pcurv_fd = opennew(pcurv_name, out_type);
+	pcurv_fd = Rast_open_new(pcurv_name, out_type);
 	pcurv_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(pcurv_raster, Rast_window_cols(), data_type);
 	Rast_put_row(pcurv_fd, pcurv_raster, data_type);
@@ -456,7 +453,7 @@
     }
 
     if (tcurv_name != NULL) {
-	tcurv_fd = opennew(tcurv_name, out_type);
+	tcurv_fd = Rast_open_new(tcurv_name, out_type);
 	tcurv_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(tcurv_raster, Rast_window_cols(), data_type);
 	Rast_put_row(tcurv_fd, tcurv_raster, data_type);
@@ -467,7 +464,7 @@
     }
 
     if (dx_name != NULL) {
-	dx_fd = opennew(dx_name, out_type);
+	dx_fd = Rast_open_new(dx_name, out_type);
 	dx_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(dx_raster, Rast_window_cols(), data_type);
 	Rast_put_row(dx_fd, dx_raster, data_type);
@@ -478,7 +475,7 @@
     }
 
     if (dy_name != NULL) {
-	dy_fd = opennew(dy_name, out_type);
+	dy_fd = Rast_open_new(dy_name, out_type);
 	dy_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(dy_raster, Rast_window_cols(), data_type);
 	Rast_put_row(dy_fd, dy_raster, data_type);
@@ -489,7 +486,7 @@
     }
 
     if (dxx_name != NULL) {
-	dxx_fd = opennew(dxx_name, out_type);
+	dxx_fd = Rast_open_new(dxx_name, out_type);
 	dxx_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(dxx_raster, Rast_window_cols(), data_type);
 	Rast_put_row(dxx_fd, dxx_raster, data_type);
@@ -500,7 +497,7 @@
     }
 
     if (dyy_name != NULL) {
-	dyy_fd = opennew(dyy_name, out_type);
+	dyy_fd = Rast_open_new(dyy_name, out_type);
 	dyy_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(dyy_raster, Rast_window_cols(), data_type);
 	Rast_put_row(dyy_fd, dyy_raster, data_type);
@@ -511,7 +508,7 @@
     }
 
     if (dxy_name != NULL) {
-	dxy_fd = opennew(dxy_name, out_type);
+	dxy_fd = Rast_open_new(dxy_name, out_type);
 	dxy_raster = Rast_allocate_buf(data_type);
 	Rast_set_null_value(dxy_raster, Rast_window_cols(), data_type);
 	Rast_put_row(dxy_fd, dxy_raster, data_type);

Deleted: grass/trunk/raster/r.slope.aspect/opennew.c
===================================================================
--- grass/trunk/raster/r.slope.aspect/opennew.c	2012-09-10 23:19:06 UTC (rev 53157)
+++ grass/trunk/raster/r.slope.aspect/opennew.c	2012-09-10 23:47:11 UTC (rev 53158)
@@ -1,13 +0,0 @@
-#include <stdlib.h>
-#include <grass/gis.h>
-#include <grass/raster.h>
-#include <grass/glocale.h>
-
-
-int opennew(const char *name, RASTER_MAP_TYPE wr_type)
-{
-    if (wr_type < 0)		/* default fp type */
-	return Rast_open_fp_new(name);
-    else
-	return Rast_open_new(name, wr_type);
-}

Modified: grass/trunk/raster/r.slope.aspect/r.slope.aspect.html
===================================================================
--- grass/trunk/raster/r.slope.aspect/r.slope.aspect.html	2012-09-10 23:19:06 UTC (rev 53157)
+++ grass/trunk/raster/r.slope.aspect/r.slope.aspect.html	2012-09-10 23:47:11 UTC (rev 53158)
@@ -7,22 +7,26 @@
 <i>format</i> for slope (degrees, percent; default=degrees), and the 
 <i>zfactor</i>: multiplicative factor to convert elevation units to meters;
 (default 1.0).
-<p>The <i>elevation</i> input raster map specified by the user must contain true
+<p>
+The <i>elevation</i> input raster map specified by the user must contain true
 elevation values, <b>not</b> rescaled or categorized data. If the elevation
 values are in feet or other units than meters (with a conversion factor
 <i>meters:</i>, defined in PROJ_UNITS), they must be converted to meters using
 the parameter <i>zfactor</i>.
-<p>The <i>aspect</i> output raster map indicates the direction that slopes are
+<p>
+The <i>aspect</i> output raster map indicates the direction that slopes are
 facing. The aspect categories represent the number degrees of east. Category
 and color table files are also generated for the aspect map layer. The aspect
 categories represent the number degrees of east and they increase
 counterclockwise: 90deg is North, 180 is West, 270 is South 360 is East. The
 aspect value 0 is used to indicate undefined aspect in flat areas with slope=0.
-<p>The <i>slope</i> output raster map contains slope values, stated in degrees of
+<p>
+The <i>slope</i> output raster map contains slope values, stated in degrees of
 inclination from the horizontal if <i>format</i>=degrees option (the default)
 is chosen, and in percent rise if <i>format</i>=percent option is chosen.
 Category and color table files are generated.
-<p>Profile and tangential curvatures are the curvatures in the direction of
+<p>
+Profile and tangential curvatures are the curvatures in the direction of
 steepest slope and in the direction of the contour tangent respectively. The
 curvatures are expressed as 1/metres, e.g. a curvature of 0.05 corresponds to a
 radius of curvature of 20m. Convex form values are positive and concave form values
@@ -107,6 +111,7 @@
              6       255      0       0
              7         0      0       0</pre></div>
 
+
 <h2>NOTES</h2>
 
 To ensure that the raster elevation map layer is not inappropriately resampled,
@@ -117,22 +122,27 @@
 cells in the elevation map. If the user really wants the elevation map
 resampled to the current region resolution, the -a flag should be specified.
 
-<p>The current mask is ignored.
+<p>
+The current mask is ignored.
 
-<p>The algorithm used to determine slope and aspect uses a 3x3 neighborhood
+<p>
+The algorithm used to determine slope and aspect uses a 3x3 neighborhood
 around each cell in the elevation file. Thus, it is not possible to determine
 slope and aspect for the cells adjacent to the edges in the elevation map
 layer. These cells are assigned a "zero slope" value (category 0) in both
 the slope and aspect raster map layers.
 
-<p>Horn's formula is used to find the first order derivatives in x and y directions.
+<p>
+Horn's formula is used to find the first order derivatives in x and y directions.
 
-<p>Only when using integer elevation models, the aspect is biased in 0,
+<p>
+Only when using integer elevation models, the aspect is biased in 0,
 45, 90, 180, 225, 270, 315, and 360 directions; i.e., the distribution
 of aspect categories is very uneven, with peaks at 0, 45,..., 360 categories.
 When working with floating point elevation models, no such aspect bias occurs.
 
-<p>Because most cells with a very small slope end up having category 0,
+<p>
+Because most cells with a very small slope end up having category 0,
 45, ..., 360, it is sometimes possible to reduce the bias in these directions
 by filtering out the aspect in areas where the terrain is almost flat. A new
 option <i>min_slp_allowed</i> was added to specify the minimum slope for which
@@ -153,14 +163,18 @@
 <a href="http://www.geomorphometry.org">http://www.geomorphometry.org</a>
 </ul>
 
+
 <h2>SEE ALSO</h2>
+
 <em><a href="r.mapcalc.html">r.mapcalc</a></em>,
 <em><a href="r.neighbors.html">r.neighbors</a></em>,
 <em><a href="r.reclass.html">r.reclass</a></em>,
 <em><a href="r.rescale.html">r.rescale</a></em>
 
+
 <h2>AUTHORS</h2>
 Michael Shapiro, U.S.Army Construction Engineering Research Laboratory<br>
 Olga Waupotitsch, U.S.Army Construction Engineering Research Laboratory
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>



More information about the grass-commit mailing list