[GRASS-SVN] r34734 - in grass/trunk/raster: r.horizon r.sun2

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 4 22:50:53 EST 2008


Author: glynn
Date: 2008-12-04 22:50:53 -0500 (Thu, 04 Dec 2008)
New Revision: 34734

Modified:
   grass/trunk/raster/r.horizon/main.c
   grass/trunk/raster/r.sun2/main.c
Log:
Call G_parser() before querying GRASS environment, region, etc


Modified: grass/trunk/raster/r.horizon/main.c
===================================================================
--- grass/trunk/raster/r.horizon/main.c	2008-12-05 02:18:45 UTC (rev 34733)
+++ grass/trunk/raster/r.horizon/main.c	2008-12-05 03:50:53 UTC (rev 34734)
@@ -188,36 +188,6 @@
 	 " The input for this is the angle (in degrees), which is measured "
 	 " counterclockwise with east=0, north=90 etc. The output is the horizon height in radians.");
 
-    G_get_set_window(&cellhd);
-
-    stepx = cellhd.ew_res;
-    stepy = cellhd.ns_res;
-    stepxhalf = stepx / 2.;
-    stepyhalf = stepy / 2.;
-    invstepx = 1. / stepx;
-    invstepy = 1. / stepy;
-    /*
-       offsetx = 2. *  invstepx;
-       offsety = 2. * invstepy;
-       offsetx = 0.5*stepx;
-       offsety = 0.5*stepy;
-     */
-    offsetx = 0.5;
-    offsety = 0.5;
-
-    n /*n_cols */  = cellhd.cols;
-    m /*n_rows */  = cellhd.rows;
-
-    n100 = ceil(n / 100.);
-    m100 = ceil(m / 100.);
-
-    xmin = cellhd.west;
-    ymin = cellhd.south;
-    xmax = cellhd.east;
-    ymax = cellhd.north;
-    deltx = fabs(cellhd.east - cellhd.west);
-    delty = fabs(cellhd.north - cellhd.south);
-
     parm.elevin = G_define_option();
     parm.elevin->key = "elevin";
     parm.elevin->type = TYPE_STRING;
@@ -329,6 +299,36 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+    G_get_set_window(&cellhd);
+
+    stepx = cellhd.ew_res;
+    stepy = cellhd.ns_res;
+    stepxhalf = stepx / 2.;
+    stepyhalf = stepy / 2.;
+    invstepx = 1. / stepx;
+    invstepy = 1. / stepy;
+    /*
+       offsetx = 2. *  invstepx;
+       offsety = 2. * invstepy;
+       offsetx = 0.5*stepx;
+       offsety = 0.5*stepy;
+     */
+    offsetx = 0.5;
+    offsety = 0.5;
+
+    n /*n_cols */  = cellhd.cols;
+    m /*n_rows */  = cellhd.rows;
+
+    n100 = ceil(n / 100.);
+    m100 = ceil(m / 100.);
+
+    xmin = cellhd.west;
+    ymin = cellhd.south;
+    xmax = cellhd.east;
+    ymax = cellhd.north;
+    deltx = fabs(cellhd.east - cellhd.west);
+    delty = fabs(cellhd.north - cellhd.south);
+
     degreeOutput = flag.degreeOutput->answer;
 
 

Modified: grass/trunk/raster/r.sun2/main.c
===================================================================
--- grass/trunk/raster/r.sun2/main.c	2008-12-05 02:18:45 UTC (rev 34733)
+++ grass/trunk/raster/r.sun2/main.c	2008-12-05 03:50:53 UTC (rev 34734)
@@ -90,7 +90,6 @@
 const char *mapset = NULL;
 const char *per;
 const char *shade;
-char mapname[1024];
 
 struct Cell_head cellhd;
 struct pj_info iproj;
@@ -221,8 +220,8 @@
 
 
     G_gisinit(argv[0]);
-    module = G_define_module();
 
+    module = G_define_module();
     module->description =
 	_("Computes direct (beam), diffuse and reflected solar irradiation raster "
 	 "maps for given day, latitude, surface and atmospheric conditions. Solar "
@@ -232,21 +231,6 @@
 	 "incidence angle and/or irradiance raster maps. The shadowing effect of "
 	 "the topography is optionally incorporated.");
 
-    G_get_set_window(&cellhd);
-
-    gridGeom.stepx = cellhd.ew_res;
-    gridGeom.stepy = cellhd.ns_res;
-    invstepx = 1. / gridGeom.stepx;
-    invstepy = 1. / gridGeom.stepy;
-    n /*n_cols */  = cellhd.cols;
-    m /*n_rows */  = cellhd.rows;
-    xmin = cellhd.west;
-    ymin = cellhd.south;
-    xmax = cellhd.east;
-    ymax = cellhd.north;
-    gridGeom.deltx = fabs(cellhd.east - cellhd.west);
-    gridGeom.delty = fabs(cellhd.north - cellhd.south);
-
     parm.elevin = G_define_option();
     parm.elevin->key = "elevin";
     parm.elevin->type = TYPE_STRING;
@@ -511,6 +495,21 @@
 	exit(EXIT_FAILURE);
 
 
+    G_get_set_window(&cellhd);
+
+    gridGeom.stepx = cellhd.ew_res;
+    gridGeom.stepy = cellhd.ns_res;
+    invstepx = 1. / gridGeom.stepx;
+    invstepy = 1. / gridGeom.stepy;
+    n /*n_cols */  = cellhd.cols;
+    m /*n_rows */  = cellhd.rows;
+    xmin = cellhd.west;
+    ymin = cellhd.south;
+    xmax = cellhd.east;
+    ymax = cellhd.north;
+    gridGeom.deltx = fabs(cellhd.east - cellhd.west);
+    gridGeom.delty = fabs(cellhd.north - cellhd.south);
+
     setUseShadow(flag.shade->answer);
 
     /*



More information about the grass-commit mailing list