[GRASS-SVN] r53440 - grass-addons/grass7/raster/r.sun.angle

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 17 07:57:53 PDT 2012


Author: mmetz
Date: 2012-10-17 07:57:53 -0700 (Wed, 17 Oct 2012)
New Revision: 53440

Modified:
   grass-addons/grass7/raster/r.sun.angle/main.c
Log:
r.sun.angle: sscanf -> atoi

Modified: grass-addons/grass7/raster/r.sun.angle/main.c
===================================================================
--- grass-addons/grass7/raster/r.sun.angle/main.c	2012-10-17 13:16:00 UTC (rev 53439)
+++ grass-addons/grass7/raster/r.sun.angle/main.c	2012-10-17 14:57:53 UTC (rev 53440)
@@ -37,7 +37,7 @@
     {
 	struct Option *elev, *azimuth, *sunhours, *year,
 	    *month, *day, *hour, *minutes, *seconds;
-	struct Flag *gst_time, *solpos;
+	struct Flag *lst_time, *no_solpos;
     } parm;
     struct Cell_head window;
     FCELL *elevbuf, *azimuthbuf, *sunhourbuf;
@@ -69,7 +69,7 @@
     module = G_define_module();
     G_add_keyword(_("raster"));
     G_add_keyword(_("solar"));
-    module->label = _("Calculates solar elevation and azimuth.");
+    module->label = _("Calculates solar elevation, solar azimuth, and sun hours.");
     module->description = _("Solar elevation: the angle between the direction of the geometric center "
 			    "of the sun's apparent disk and the (idealized) horizon. "
 			    "Solar azimuth: the angle from due north in clockwise direction.");
@@ -104,7 +104,7 @@
     parm.month->required = NO;
     parm.month->label = _("Month");
     parm.month->description = _("If not given, day is interpreted as day of the year");
-    parm.month->options = "0-12";
+    parm.month->options = "1-12";
     parm.month->guisection = _("Time");
 
     parm.day = G_define_option();
@@ -112,13 +112,13 @@
     parm.day->type = TYPE_INTEGER;
     parm.day->required = YES;
     parm.day->description = _("Day");
-    parm.day->options = "0-365";
+    parm.day->options = "1-366";
     parm.day->guisection = _("Time");
 
     parm.hour = G_define_option();
     parm.hour->key = "hour";
     parm.hour->type = TYPE_INTEGER;
-    parm.hour->required = YES;
+    parm.hour->required = NO;
     parm.hour->description = _("Hour");
     parm.hour->options = "0-24";
     parm.hour->answer = "12";
@@ -127,7 +127,7 @@
     parm.minutes = G_define_option();
     parm.minutes->key = "minute";
     parm.minutes->type = TYPE_INTEGER;
-    parm.minutes->required = YES;
+    parm.minutes->required = NO;
     parm.minutes->description = _("Minutes");
     parm.minutes->options = "0-60";
     parm.minutes->answer = "0";
@@ -136,19 +136,19 @@
     parm.seconds = G_define_option();
     parm.seconds->key = "second";
     parm.seconds->type = TYPE_INTEGER;
-    parm.seconds->required = YES;
+    parm.seconds->required = NO;
     parm.seconds->description = _("Seconds");
     parm.seconds->options = "0-60";
     parm.seconds->answer = "0";
     parm.seconds->guisection = _("Time");
 
-    parm.gst_time = G_define_flag();
-    parm.gst_time->key = 't';
-    parm.gst_time->description = _("Time is Greenwich standard time, not local sidereal time");
+    parm.lst_time = G_define_flag();
+    parm.lst_time->key = 't';
+    parm.lst_time->description = _("Time is local sidereal time, not Greenwich standard time");
 
-    parm.solpos = G_define_flag();
-    parm.solpos->key = 's';
-    parm.solpos->description = _("Use solpos algorithm of NREL");
+    parm.no_solpos = G_define_flag();
+    parm.no_solpos->key = 's';
+    parm.no_solpos->description = _("Do not use solpos algorithm of NREL");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -162,19 +162,20 @@
     if (!elev_name && !azimuth_name && !sunhour_name)
 	G_fatal_error(_("No output requested, exiting."));
 
-    sscanf(parm.year->answer, "%i", &year);
+    year = atoi(parm.year->answer);
     if (parm.month->answer)
-	sscanf(parm.month->answer, "%i", &month);
+	month = atoi(parm.month->answer);
     else
 	month = -1;
-    sscanf(parm.day->answer, "%i", &day);
-    sscanf(parm.hour->answer, "%i", &hour);
-    sscanf(parm.minutes->answer, "%i", &minutes);
-    sscanf(parm.seconds->answer, "%i", &seconds);
 
-    lst_time = (parm.gst_time->answer == 0);
-    use_solpos = parm.solpos->answer;
+    day = atoi(parm.day->answer);
+    hour = atoi(parm.hour->answer);
+    minutes = atoi(parm.minutes->answer);
+    seconds = atoi(parm.seconds->answer);
 
+    lst_time = (parm.lst_time->answer != 0);
+    use_solpos = (parm.no_solpos->answer == 0);
+
     /* init variables */
     ha = 180;
     ha_cos = 0;
@@ -197,7 +198,7 @@
 	    G_message(_("Time will be interpreted as Greenwich standard time."));
 	
 	if (sunhour_name)
-	    G_fatal_error(_("Sunshine hours require solpos"));
+	    G_fatal_error(_("Sunshine hours require NREL solpos."));
     }
 
     if ((G_projection() != PROJECTION_LL)) {
@@ -208,13 +209,13 @@
 
 	/* read current projection info */
 	if ((in_proj_info = G_get_projinfo()) == NULL)
-	    G_fatal_error(_("Can't get projection info of current location"));
+	    G_fatal_error(_("Can't get projection info of current location."));
 
 	if ((in_unit_info = G_get_projunits()) == NULL)
-	    G_fatal_error(_("Can't get projection units of current location"));
+	    G_fatal_error(_("Can't get projection units of current location."));
 
 	if (pj_get_kv(&iproj, in_proj_info, in_unit_info) < 0)
-	    G_fatal_error(_("Can't get projection key values of current location"));
+	    G_fatal_error(_("Can't get projection key values of current location."));
 
 	G_free_key_value(in_proj_info);
 	G_free_key_value(in_unit_info);
@@ -224,7 +225,7 @@
 	oproj.meters = 1.;
 	sprintf(oproj.proj, "ll");
 	if ((oproj.pj = pj_latlong_from_proj(iproj.pj)) == NULL)
-	    G_fatal_error(_("Unable to update lat/long projection parameters"));
+	    G_fatal_error(_("Unable to update lat/long projection parameters."));
     }
 
     /* always init pd */



More information about the grass-commit mailing list