[GRASS-SVN] r58547 - grass/branches/releasebranch_6_4/raster/r.horizon
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 29 13:35:46 PST 2013
Author: neteler
Date: 2013-12-29 13:35:45 -0800 (Sun, 29 Dec 2013)
New Revision: 58547
Modified:
grass/branches/releasebranch_6_4/raster/r.horizon/description.html
grass/branches/releasebranch_6_4/raster/r.horizon/main.c
Log:
r.horizon: added sanity check for dist parameter; fixed wrong user msg; minor sync with develbranch_6; fixed manual examples
Modified: grass/branches/releasebranch_6_4/raster/r.horizon/description.html
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.horizon/description.html 2013-12-29 21:34:36 UTC (rev 58546)
+++ grass/branches/releasebranch_6_4/raster/r.horizon/description.html 2013-12-29 21:35:45 UTC (rev 58547)
@@ -9,7 +9,7 @@
heights in the specified directions from the given point. The results are
written to the stdout.
<li> raster: in this case the output is
-one or more rasters, with each point in a raster giving the horizon
+one or more raster maps, with each point in a raster giving the horizon
height in a specific direction. One raster is created for each direction.
</ul>
@@ -30,7 +30,7 @@
<h3>Flags:</h3>
<dl>
<dt><b>-d</b>
- <dd>Output horizon height in degrees (the default is radians)</dl>
+ <dd>Output horizon height in degrees (the default is radians)</dd>
</dl>
@@ -43,7 +43,7 @@
<p>The <I>horizonstep</I> parameter gives the angle step (in degrees)
between successive azimuthal directions for the calculation of the
horizon. Thus, a value of 5 for the <I>horizonstep</I> will give a total of
-360/5=72 directions (72 rasters if used in the raster mode).
+360/5=72 directions (72 raster maps if used in the raster mode).
<p>The <I>direction</I> parameter gives the initial direction of the
first output. This parameter acts as an direction angle offset. For
@@ -51,7 +51,8 @@
degrees, the <I>direction</I> should be set to 45 and <I>horizonstep</I> to
180. If you only want one single direction, use this parameter to
specify desired direction of horizon angle, and set the <I>horizonstep</I>
-size to 0 degrees.
+size to 0 degrees. Otherwise all angles for a given starting <i>direction</i>
+with step of <i>horizon_step</i> are calculated.
<p>The <I>dist </I>controls the sampling distance step size for the
search for horizon along the line of sight. The default value is 1.0
@@ -118,20 +119,24 @@
-<h2>EXAMPLE</h2>
+<h2>EXAMPLES</h2>
Single point mode:
<div class="code"><pre>
-r.horizon elevin=DEM horizonstep=30 direction=15 bufferzone=200 \
- coord=47.302,7.365 dist=0.7 > horizon.out
-</pre></div>
+# determine horizon in 225 degree direction:
+r.horizon elevin=elevation direction=215 horizonstep=0 bufferzone=200 \
+ coordinate=638871.6,223384.4
+# determine horizon values starting at 215 deg, with step size of 30 deg:
+r.horizon elevin=elevation direction=215 horizonstep=30 bufferzone=200 \
+ coordinate=637500.0,221750.0</pre></div>
+
Raster map mode (for r.sun):
<div class="code"><pre>
# we put a bufferzone of 10% of maxdistance around the study area
-r.horizon elevin=DEM horizonstep=30 bufferzone=200 horizon=horangle \
- dist=0.7 maxdistance=2000
+r.horizon elevin=elevation horizonstep=30 bufferzone=200 horizon=horangle \
+ maxdistance=2000
</pre></div>
@@ -140,7 +145,8 @@
<em>
<a href="r.sun.html">r.sun</a>,
<a href="r.sunmask.html">r.sunmask</a>,
-<a href="r.los.html">r.los</a></em>
+<a href="r.los.html">r.los</a>
+</em>
<h2>REFERENCES</h2>
Modified: grass/branches/releasebranch_6_4/raster/r.horizon/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.horizon/main.c 2013-12-29 21:34:36 UTC (rev 58546)
+++ grass/branches/releasebranch_6_4/raster/r.horizon/main.c 2013-12-29 21:35:45 UTC (rev 58547)
@@ -140,7 +140,8 @@
int ll_correction = FALSE;
double coslatsq;
-/* use G_distance() instead ??!?! */
+/* why not use G_distance() here which switches to geodesic/great
+ circle distance as needed? */
double distance(double x1, double x2, double y1, double y2)
{
if (ll_correction) {
@@ -338,9 +339,8 @@
else {
setMode(SINGLE_POINT);
if (sscanf(parm.coord->answer, "%lf,%lf", &xcoord, &ycoord) != 2) {
- G_fatal_error
- ("Can't read the coordinates from the \"coord\" option.");
-
+ G_fatal_error(
+ _("Can't read the coordinates from the \"coord\" option."));
}
/* Transform the coordinates to row/column */
@@ -357,15 +357,13 @@
if (isMode(WHOLE_RASTER)) {
if ((parm.direction->answer == NULL) && (parm.step->answer == NULL)) {
- G_fatal_error
- (_("You didn't specify a direction value or step size. Aborting."));
+ G_fatal_error(
+ _("You didn't specify a direction value or step size. Aborting."));
}
-
if (parm.horizon->answer == NULL) {
- G_fatal_error
- (_("You didn't specify a horizon raster name. Aborting."));
-
+ G_fatal_error(
+ _("You didn't specify a horizon raster name. Aborting."));
}
horizon = parm.horizon->answer;
if (parm.step->answer != NULL)
@@ -374,9 +372,8 @@
else {
if (parm.step->answer == NULL) {
- G_fatal_error
- (_("You didn't specify an angle step size. Aborting."));
-
+ G_fatal_error(
+ _("You didn't specify an angle step size. Aborting."));
}
sscanf(parm.step->answer, "%lf", &step);
@@ -429,6 +426,7 @@
sscanf(parm.dist->answer, "%lf", &dist);
+ if (dist < 0.5 || dist > 1.5 ) G_fatal_error(_("The distance value must be 0.5-1.5. Aborting."));
stepxy = dist * 0.5 * (stepx + stepy);
distxy = dist;
@@ -475,15 +473,15 @@
struct Key_Value *in_proj_info, *in_unit_info;
if ((in_proj_info = G_get_projinfo()) == NULL)
- G_fatal_error
- (_("Can't get projection info of current location: please set latitude via 'lat' or 'latin' option!"));
+ G_fatal_error(
+ _("Can't get projection info of current location"));
if ((in_unit_info = G_get_projunits()) == NULL)
G_fatal_error(_("Can't get projection units of current location"));
if (pj_get_kv(&iproj, in_proj_info, in_unit_info) < 0)
- G_fatal_error
- (_("Can't get projection key values of current location"));
+ G_fatal_error(
+ _("Can't get projection key values of current location"));
G_free_key_value(in_proj_info);
G_free_key_value(in_unit_info);
@@ -501,6 +499,7 @@
INPUT();
+ G_debug(3, "calculate() starts...");
calculate(xcoord, ycoord, (int)(ebufferZone / stepx),
(int)(wbufferZone / stepx), (int)(sbufferZone / stepy),
(int)(nbufferZone / stepy));
@@ -618,7 +617,6 @@
G_fatal_error(_("Unable to create raster map %s"), shad_filename);
}
-
if (numrows != G_window_rows())
G_fatal_error(_("OOPS: rows changed from %d to %d"), numrows,
G_window_rows());
@@ -1127,12 +1125,13 @@
if (step != 0.0)
sprintf(shad_filename, formatString, horizon, k);
+
angle = (single_direction * deg2rad) + (dfr_rad * k);
/*
com_par(angle);
*/
- G_message(_("Calculating map %01d of %01d (angle %lf, raster map <%s>)"), (k + 1), arrayNumInt,
- angle * rad2deg, shad_filename);
+ G_message(_("Calculating map %01d of %01d (angle %lf, raster map <%s>)"),
+ (k + 1), arrayNumInt, angle * rad2deg, shad_filename);
for (j = hor_row_start; j < hor_row_end; j++) {
G_percent(j - hor_row_start, hor_numrows - 1, 2);
@@ -1239,6 +1238,7 @@
}
}
+ G_debug(3, "OUTGR() starts...");
OUTGR(cellhd.rows, cellhd.cols);
/* empty array */
More information about the grass-commit
mailing list