[GRASS-SVN] r61098 - grass/trunk/raster/r.sun

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 1 02:29:47 PDT 2014


Author: zarch
Date: 2014-07-01 02:29:47 -0700 (Tue, 01 Jul 2014)
New Revision: 61098

Modified:
   grass/trunk/raster/r.sun/main.c
Log:
r.sun: Change parameters name as discussed in #2338 and read the new r.horizon outputs

Modified: grass/trunk/raster/r.sun/main.c
===================================================================
--- grass/trunk/raster/r.sun/main.c	2014-07-01 09:27:17 UTC (rev 61097)
+++ grass/trunk/raster/r.sun/main.c	2014-07-01 09:29:47 UTC (rev 61098)
@@ -98,6 +98,10 @@
 const char *mapset = NULL;
 const char *per;
 
+size_t decimals;
+char *str_step;
+
+
 struct Cell_head cellhd;
 struct pj_info iproj;
 struct pj_info oproj;
@@ -202,8 +206,6 @@
 }
 
 
-
-
 int main(int argc, char *argv[])
 {
     double singleSlope;
@@ -249,7 +251,7 @@
 	 "the topography is optionally incorporated.");
 
     parm.elevin = G_define_option();
-    parm.elevin->key = "elev_in";
+    parm.elevin->key = "elevation";
     parm.elevin->type = TYPE_STRING;
     parm.elevin->required = YES;
     parm.elevin->gisprompt = "old,cell,raster";
@@ -258,7 +260,7 @@
     parm.elevin->guisection = _("Input options");
 
     parm.aspin = G_define_option();
-    parm.aspin->key = "asp_in";
+    parm.aspin->key = "aspect";
     parm.aspin->type = TYPE_STRING;
     parm.aspin->required = NO;
     parm.aspin->gisprompt = "old,cell,raster";
@@ -267,7 +269,7 @@
     parm.aspin->guisection = _("Input options");
 
     parm.aspect = G_define_option();
-    parm.aspect->key = "aspect";
+    parm.aspect->key = "aspect_value";
     parm.aspect->type = TYPE_DOUBLE;
     parm.aspect->answer = ASPECT;
     parm.aspect->required = NO;
@@ -276,7 +278,7 @@
     parm.aspect->guisection = _("Input options");
 
     parm.slopein = G_define_option();
-    parm.slopein->key = "slope_in";
+    parm.slopein->key = "slope";
     parm.slopein->type = TYPE_STRING;
     parm.slopein->required = NO;
     parm.slopein->gisprompt = "old,cell,raster";
@@ -285,7 +287,7 @@
     parm.slopein->guisection = _("Input options");
 
     parm.slope = G_define_option();
-    parm.slope->key = "slope";
+    parm.slope->key = "slope_value";
     parm.slope->type = TYPE_DOUBLE;
     parm.slope->answer = SLOPE;
     parm.slope->required = NO;
@@ -293,7 +295,7 @@
     parm.slope->guisection = _("Input options");
 
     parm.linkein = G_define_option();
-    parm.linkein->key = "linke_in";
+    parm.linkein->key = "linke";
     parm.linkein->type = TYPE_STRING;
     parm.linkein->required = NO;
     parm.linkein->gisprompt = "old,cell,raster";
@@ -333,7 +335,7 @@
     }
 
     parm.latin = G_define_option();
-    parm.latin->key = "lat_in";
+    parm.latin->key = "lat";
     parm.latin->type = TYPE_STRING;
     parm.latin->required = NO;
     parm.latin->gisprompt = "old,cell,raster";
@@ -342,7 +344,7 @@
     parm.latin->guisection = _("Input options");
 
     parm.longin = G_define_option();
-    parm.longin->key = "long_in";
+    parm.longin->key = "long";
     parm.longin->type = TYPE_STRING;
     parm.longin->required = NO;
     parm.longin->gisprompt = "old,cell,raster";
@@ -368,12 +370,11 @@
 	_("Name of real-sky diffuse radiation coefficient (haze) input raster map [0-1]");
     parm.coefdh->guisection = _("Input options");
 
-    parm.horizon = G_define_option();
-    parm.horizon->key = "horizon";
-    parm.horizon->type = TYPE_STRING;
+    parm.horizon = G_define_standard_option(G_OPT_R_BASENAME_INPUT);
+    parm.horizon->key = "horizon_basename";
     parm.horizon->required = NO;
     parm.horizon->gisprompt = "old,cell,raster";
-    parm.horizon->description = _("The horizon information input map prefix");
+    parm.horizon->description = _("The horizon information input map basename");
     parm.horizon->guisection = _("Input options");
 
     parm.horizonstep = G_define_option();
@@ -599,6 +600,7 @@
     if (parm.horizonstep->answer != NULL) {
 	if (sscanf(parm.horizonstep->answer, "%lf", &horizonStep) != 1)
 	    G_fatal_error(_("Error reading horizon step size"));
+        str_step = parm.horizonstep->answer;
 	if (horizonStep > 0.)
 	    setHorizonInterval(deg2rad * horizonStep);
 	else
@@ -784,8 +786,9 @@
     static int *fd_shad;
     int fr1 = -1, fr2 = -1;
     int l, i, j;
-    char shad_filename[256];
+    char *shad_filename;
     char formatString[10];
+    double angle_deg = 0.;
 
     finalRow = m - offset - m / numPartitions;
     if (finalRow < 0) {
@@ -917,13 +920,24 @@
 	 * else
 	 * {
 	 */
-	numDigits = (int)(log10(1. * arrayNumInt)) + 1;
+        decimals = G_get_num_decimals(str_step);
+        angle_deg = 0;
+        for (i = 0; i < arrayNumInt; i++) {
+            horizonbuf[i] = Rast_allocate_f_buf();
+            shad_filename = G_generate_basename(horizon, angle_deg, 
+                                                3, decimals);
+            fd_shad[i] = Rast_open_old(shad_filename, "");
+            angle_deg += horizonStep;
+            G_free(shad_filename);
+        }
+        /*
+        numDigits = (int)(log10(1. * arrayNumInt)) + 1;
 	sprintf(formatString, "%%s_%%0%dd", numDigits);
 	for (i = 0; i < arrayNumInt; i++) {
 	    horizonbuf[i] = Rast_allocate_f_buf();
 	    sprintf(shad_filename, formatString, horizon, i);
 	    fd_shad[i] = Rast_open_old(shad_filename, "");
-	}
+	} */
     }
     /*
      * }



More information about the grass-commit mailing list