浏览代码

r.horizon: implement -c flag for compass oriented output

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@63996 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 10 年之前
父节点
当前提交
dbfb0f6e7e
共有 2 个文件被更改,包括 24 次插入12 次删除
  1. 18 3
      raster/r.horizon/main.c
  2. 6 9
      raster/r.horizon/r.horizon.html

+ 18 - 3
raster/r.horizon/main.c

@@ -107,7 +107,7 @@ void calculate(double xcoord, double ycoord, int buffer_e, int buffer_w,
 
 
 int ip, jp, ip100, jp100;
 int ip, jp, ip100, jp100;
 int n, m, m100, n100;
 int n, m, m100, n100;
-int degreeOutput = FALSE;
+int degreeOutput, compassOutput = FALSE;
 float **z, **z100, **horizon_raster;
 float **z, **z100, **horizon_raster;
 double stepx, stepy, stepxhalf, stepyhalf, stepxy, xp, yp, op, dp, xg0, xx0,
 double stepx, stepy, stepxhalf, stepyhalf, stepxy, xp, yp, op, dp, xg0, xx0,
     yg0, yy0, deltx, delty;
     yg0, yy0, deltx, delty;
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
 
 
     struct
     struct
     {
     {
-	struct Flag *degreeOutput;
+	struct Flag *degreeOutput, *compassOutput;
     }
     }
     flag;
     flag;
 
 
@@ -308,6 +308,11 @@ int main(int argc, char *argv[])
     flag.degreeOutput->description =
     flag.degreeOutput->description =
 	_("Write output in degrees (default is radians)");
 	_("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))
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 	exit(EXIT_FAILURE);
@@ -343,6 +348,7 @@ int main(int argc, char *argv[])
     delty = fabs(cellhd.north - cellhd.south);
     delty = fabs(cellhd.north - cellhd.south);
 
 
     degreeOutput = flag.degreeOutput->answer;
     degreeOutput = flag.degreeOutput->answer;
+    compassOutput = flag.compassOutput->answer;
 
 
     if (G_projection() == PROJECTION_LL)
     if (G_projection() == PROJECTION_LL)
         G_important_message(_("Note: In latitude-longitude coordinate system specify buffers in degree unit"));
         G_important_message(_("Note: In latitude-longitude coordinate system specify buffers in degree unit"));
@@ -865,7 +871,16 @@ void calculate_shadow()
 	else if (printangle >= 360.)
 	else if (printangle >= 360.)
 	    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;
 	angle += dfr_rad;
 
 

+ 6 - 9
raster/r.horizon/r.horizon.html

@@ -24,15 +24,11 @@ and columns of the raster map. This correction implies that the
 resulting cardinal directions represent true orientation towards the
 resulting cardinal directions represent true orientation towards the
 East, North, West and South. The only exception of this feature is
 East, North, West and South. The only exception of this feature is
 LOCATION with x,y coordinate system, where this correction is
 LOCATION with x,y coordinate system, where this correction is
-not applied. 
-
-
-<h3>Flags:</h3>
-<dl>
-  <dt><b>-d</b>
-  <dd>Output horizon height in degrees (the default is radians)</dd>
-</dl>
+not applied.
 
 
+<p>
+Using the <b>-c</b> flag, the azimuthal angles will be printed in compass
+orientation (North=0, clockwise).
 
 
 <h3>Input parameters:</h3>
 <h3>Input parameters:</h3>
 <p>The <i>elevation</i> parameter is an input elevation raster map. If
 <p>The <i>elevation</i> parameter is an input elevation raster map. If
@@ -46,7 +42,8 @@ horizon. Thus, a value of 5 for the <i>step</i> will give a total of
 360/5=72 directions (72 raster maps if used in the raster map mode). 
 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)
 <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)
 <p>The <i>end</i> parameter gives the angle end (in degrees)
 for the calculation of the horizon. The end point is omitted!
 for the calculation of the horizon. The end point is omitted!