Pārlūkot izejas kodu

Call G_parser() before querying GRASS environment, region, etc

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34734 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 gadi atpakaļ
vecāks
revīzija
5cb476c3c1
2 mainītis faili ar 46 papildinājumiem un 47 dzēšanām
  1. 30 30
      raster/r.horizon/main.c
  2. 16 17
      raster/r.sun2/main.c

+ 30 - 30
raster/r.horizon/main.c

@@ -188,36 +188,6 @@ int main(int argc, char *argv[])
 	 " 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 @@ int main(int argc, char *argv[])
     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;
 
 

+ 16 - 17
raster/r.sun2/main.c

@@ -90,7 +90,6 @@ const char *glob_rad = NULL;
 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 @@ int main(int argc, char *argv[])
 
 
     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 @@ int main(int argc, char *argv[])
 	 "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 @@ int main(int argc, char *argv[])
 	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);
 
     /*