[GRASS-SVN] r58546 - grass/branches/develbranch_6/raster/r.horizon

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 29 13:34:36 PST 2013


Author: neteler
Date: 2013-12-29 13:34:36 -0800 (Sun, 29 Dec 2013)
New Revision: 58546

Modified:
   grass/branches/develbranch_6/raster/r.horizon/description.html
   grass/branches/develbranch_6/raster/r.horizon/main.c
Log:
r.horizon: added sanity check for dist parameter; fixed wrong user msg; fixed manual examples

Modified: grass/branches/develbranch_6/raster/r.horizon/description.html
===================================================================
--- grass/branches/develbranch_6/raster/r.horizon/description.html	2013-12-29 15:43:44 UTC (rev 58545)
+++ grass/branches/develbranch_6/raster/r.horizon/description.html	2013-12-29 21:34:36 UTC (rev 58546)
@@ -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/develbranch_6/raster/r.horizon/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.horizon/main.c	2013-12-29 15:43:44 UTC (rev 58545)
+++ grass/branches/develbranch_6/raster/r.horizon/main.c	2013-12-29 21:34:36 UTC (rev 58546)
@@ -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) {
@@ -421,6 +422,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;
@@ -468,8 +470,7 @@
 
     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!"));
+	    _("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"));
@@ -494,6 +495,7 @@
 
 
     INPUT();
+    G_debug(3, "calculate() starts...");
     calculate(xcoord, ycoord, (int)(ebufferZone / stepx),
 	      (int)(wbufferZone / stepx), (int)(sbufferZone / stepy),
 	      (int)(nbufferZone / stepy));
@@ -1232,6 +1234,7 @@
 		}
 	    }
 
+        G_debug(3, "OUTGR() starts...");
 	    OUTGR(cellhd.rows, cellhd.cols);
 
 	    /* empty array */



More information about the grass-commit mailing list