[GRASS-SVN] r63995 - grass/trunk/raster/r.horizon

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 8 05:56:07 PST 2015


Author: neteler
Date: 2015-01-08 05:56:07 -0800 (Thu, 08 Jan 2015)
New Revision: 63995

Modified:
   grass/trunk/raster/r.horizon/main.c
   grass/trunk/raster/r.horizon/r.horizon.html
Log:
r.horizon: implement -c flag for compass oriented output

Modified: grass/trunk/raster/r.horizon/main.c
===================================================================
--- grass/trunk/raster/r.horizon/main.c	2015-01-08 10:58:05 UTC (rev 63994)
+++ grass/trunk/raster/r.horizon/main.c	2015-01-08 13:56:07 UTC (rev 63995)
@@ -107,7 +107,7 @@
 
 int ip, jp, ip100, jp100;
 int n, m, m100, n100;
-int degreeOutput = FALSE;
+int degreeOutput, compassOutput = FALSE;
 float **z, **z100, **horizon_raster;
 double stepx, stepy, stepxhalf, stepyhalf, stepxy, xp, yp, op, dp, xg0, xx0,
     yg0, yy0, deltx, delty;
@@ -171,7 +171,7 @@
 
     struct
     {
-	struct Flag *degreeOutput;
+	struct Flag *degreeOutput, *compassOutput;
     }
     flag;
 
@@ -308,7 +308,12 @@
     flag.degreeOutput->description =
 	_("Write output in degrees (default is radians)");
 
+    flag.compassOutput = G_define_flag();
+    flag.compassOutput->key = 'c';
+    flag.compassOutput->description =
+	_("Write output in compass orientation (default is CCW, East=0)");
 
+
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -343,6 +348,7 @@
     delty = fabs(cellhd.north - cellhd.south);
 
     degreeOutput = flag.degreeOutput->answer;
+    compassOutput = flag.compassOutput->answer;
 
     if (G_projection() == PROJECTION_LL)
         G_important_message(_("Note: In latitude-longitude coordinate system specify buffers in degree unit"));
@@ -865,7 +871,16 @@
 	else if (printangle >= 360.)
 	    printangle -= 360;
 
-	fprintf(fp, "%lf,%lf\n", printangle, shadow_angle);
+	if(compassOutput ){
+	    double tmpangle;
+	    
+	    tmpangle = 360. - printangle + 90.;
+	    if (tmpangle >= 360.)
+		tmpangle = tmpangle - 360.;
+	    fprintf(fp, "%lf,%lf\n", tmpangle, shadow_angle);
+	} else {
+	    fprintf(fp, "%lf,%lf\n", printangle, shadow_angle);
+	}
 
 	angle += dfr_rad;
 

Modified: grass/trunk/raster/r.horizon/r.horizon.html
===================================================================
--- grass/trunk/raster/r.horizon/r.horizon.html	2015-01-08 10:58:05 UTC (rev 63994)
+++ grass/trunk/raster/r.horizon/r.horizon.html	2015-01-08 13:56:07 UTC (rev 63995)
@@ -24,16 +24,12 @@
 resulting cardinal directions represent true orientation towards the
 East, North, West and South. The only exception of this feature is
 LOCATION with x,y coordinate system, where this correction is
-not applied. 
+not applied.
 
+<p>
+Using the <b>-c</b> flag, the azimuthal angles will be printed in compass
+orientation (North=0, clockwise).
 
-<h3>Flags:</h3>
-<dl>
-  <dt><b>-d</b>
-  <dd>Output horizon height in degrees (the default is radians)</dd>
-</dl>
-
-
 <h3>Input parameters:</h3>
 <p>The <i>elevation</i> parameter is an input elevation raster map. If
 the buffer options are used (see below), this raster should extend
@@ -46,7 +42,8 @@
 360/5=72 directions (72 raster maps if used in the raster map mode). 
 
 <p>The <i>start</i> parameter gives the angle start (in degrees)
-for the calculation of the horizon. The default value is 0.
+for the calculation of the horizon. The default value is 0 (East with
+North being 90 etc.).
 
 <p>The <i>end</i> parameter gives the angle end (in degrees)
 for the calculation of the horizon. The end point is omitted!



More information about the grass-commit mailing list