[GRASS-SVN] r44258 - grass/branches/releasebranch_6_4/raster/r.sunmask

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 8 16:07:45 EST 2010


Author: martinl
Date: 2010-11-08 13:07:45 -0800 (Mon, 08 Nov 2010)
New Revision: 44258

Modified:
   grass/branches/releasebranch_6_4/raster/r.sunmask/main.c
Log:
r.sunmask backported from devbr6


Modified: grass/branches/releasebranch_6_4/raster/r.sunmask/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.sunmask/main.c	2010-11-08 21:05:17 UTC (rev 44257)
+++ grass/branches/releasebranch_6_4/raster/r.sunmask/main.c	2010-11-08 21:07:45 UTC (rev 44258)
@@ -6,7 +6,7 @@
  *               update to FP by Huidae Cho <grass4u gmail.com> 2001
  *               added solpos algorithm feature by Markus Neteler 2001
  *               Brad Douglas <rez touchofmadness.com>, Glynn Clements <glynn gclements.plus.com>,
- *               Hamish Bowman <hamish_nospam yahoo.com>, Paul Kelly <paul-grass stjohnspoint.co.uk>
+ *               Hamish Bowman <hamish_b yahoo.com>, Paul Kelly <paul-grass stjohnspoint.co.uk>
  * PURPOSE:      
  * COPYRIGHT:    (C) 1999-2006 by the GRASS Development Team
  *
@@ -112,36 +112,24 @@
     G_gisinit(argv[0]);
 
     module = G_define_module();
-    module->keywords = _("raster");
-    module->description =
-	_("Calculates cast shadow areas from sun position and DEM. Either "
-	  "A: exact sun position is specified, or B: date/time to calculate "
-	  "the sun position by r.sunmask itself.");
-
-    parm.opt1 = G_define_option();
-    parm.opt1->key = "elev";
-    parm.opt1->type = TYPE_STRING;
-    parm.opt1->required = YES;
-    parm.opt1->multiple = NO;
-    parm.opt1->gisprompt = "old,cell,raster";
-    parm.opt1->description = _("Name of elevation raster map");
-
-    parm.opt2 = G_define_option();
-    parm.opt2->key = "output";
-    parm.opt2->type = TYPE_STRING;
-    parm.opt2->required = YES;
-    parm.opt2->multiple = NO;
-    parm.opt2->gisprompt = "new,cell,raster";
-    parm.opt2->description = _("Output raster map having shadows");
-
+    module->keywords = _("raster, sun position");
+    module->label = _("Calculates cast shadow areas from sun position and elevation raster map.");
+    module->description = _("Either exact sun position (A) is specified, or date/time to calculate "
+			    "the sun position (B) by r.sunmask itself.");
+    
+    parm.opt1 = G_define_standard_option(G_OPT_R_ELEV);
+    
+    parm.opt2 = G_define_standard_option(G_OPT_R_OUTPUT);
+    parm.opt2->required = NO;
+    
     parm.opt3 = G_define_option();
     parm.opt3->key = "altitude";
     parm.opt3->type = TYPE_DOUBLE;
     parm.opt3->required = NO;
     parm.opt3->options = "0-89.999";
     parm.opt3->description =
-	_("A: altitude of the sun above horizon, degrees");
-    parm.opt3->guisection = _("By_position");
+	_("Altitude of the sun above horizon, degrees (A)");
+    parm.opt3->guisection = _("Position");
 
     parm.opt4 = G_define_option();
     parm.opt4->key = "azimuth";
@@ -149,78 +137,89 @@
     parm.opt4->required = NO;
     parm.opt4->options = "0-360";
     parm.opt4->description =
-	_("A: azimuth of the sun from the north, degrees");
-    parm.opt4->guisection = _("By_position");
+	_("Azimuth of the sun from the north, degrees (A)");
+    parm.opt4->guisection = _("Position");
 
     parm.year = G_define_option();
     parm.year->key = "year";
     parm.year->type = TYPE_INTEGER;
     parm.year->required = NO;
-    parm.year->description = _("B: year (1950..2050)");
-    parm.year->guisection = _("By_time");
+    parm.year->description = _("Year (B)");
+    parm.year->options = "1950-2050";
+    parm.year->guisection = _("Time");
 
     parm.month = G_define_option();
     parm.month->key = "month";
     parm.month->type = TYPE_INTEGER;
     parm.month->required = NO;
-    parm.month->description = _("B: month (0..12)");
-    parm.month->guisection = _("By_time");
+    parm.month->description = _("Month (B)");
+    parm.month->options = "0-12";
+    parm.month->guisection = _("Time");
 
     parm.day = G_define_option();
     parm.day->key = "day";
     parm.day->type = TYPE_INTEGER;
     parm.day->required = NO;
-    parm.day->description = _("B: day (0..31)");
-    parm.day->guisection = _("By_time");
+    parm.day->description = _("Day (B)");
+    parm.day->options = "0-31";
+    parm.day->guisection = _("Time");
 
     parm.hour = G_define_option();
     parm.hour->key = "hour";
     parm.hour->type = TYPE_INTEGER;
     parm.hour->required = NO;
-    parm.hour->description = _("B: hour (0..24)");
-    parm.hour->guisection = _("By_time");
+    parm.hour->description = _("Hour (B)");
+    parm.hour->options = "0-24";
+    parm.hour->guisection = _("Time");
 
     parm.minutes = G_define_option();
     parm.minutes->key = "minute";
     parm.minutes->type = TYPE_INTEGER;
     parm.minutes->required = NO;
-    parm.minutes->description = _("B: minutes (0..60)");
-    parm.minutes->guisection = _("By_time");
+    parm.minutes->description = _("Minutes (B)");
+    parm.minutes->options = "0-60";
+    parm.minutes->guisection = _("Time");
 
     parm.seconds = G_define_option();
     parm.seconds->key = "second";
     parm.seconds->type = TYPE_INTEGER;
     parm.seconds->required = NO;
-    parm.seconds->description = _("B: seconds (0..60)");
-    parm.seconds->guisection = _("By_time");
+    parm.seconds->description = _("Seconds (B)");
+    parm.seconds->options = "0-60";
+    parm.seconds->guisection = _("Time");
 
     parm.timezone = G_define_option();
     parm.timezone->key = "timezone";
     parm.timezone->type = TYPE_INTEGER;
     parm.timezone->required = NO;
-    parm.timezone->description =
-	_("B: timezone (east positive, offset from GMT, also use to adjust daylight savings)");
-    parm.timezone->guisection = _("By_time");
+    parm.timezone->label =
+	_("Timezone");
+    parm.timezone->description = _("East positive, offset from GMT, also use to adjust daylight savings");
+    parm.timezone->guisection = _("Time");
 
     parm.east = G_define_option();
     parm.east->key = "east";
     parm.east->key_desc = "value";
     parm.east->type = TYPE_STRING;
     parm.east->required = NO;
-    parm.east->description =
-	_("East coordinate (point of interest, default: map center)");
+    parm.east->label =
+	_("Easting coordinate (point of interest)");
+    parm.east->description = _("Default: map center");
+    parm.east->guisection = _("Position");
 
     parm.north = G_define_option();
     parm.north->key = "north";
     parm.north->key_desc = "value";
     parm.north->type = TYPE_STRING;
     parm.north->required = NO;
-    parm.north->description =
-	_("North coordinate (point of interest, default: map center)");
+    parm.north->label =
+	_("Northing coordinate (point of interest)");
+    parm.north->description = _("Default: map center");
+    parm.north->guisection = _("Position");
 
     flag1 = G_define_flag();
     flag1->key = 'z';
-    flag1->description = _("Zero is a real elevation");
+    flag1->description = _("Don't ignore zero elevation");
 
     flag2 = G_define_flag();
     flag2->key = 'v';
@@ -230,11 +229,13 @@
     flag3 = G_define_flag();
     flag3->key = 's';
     flag3->description = _("Calculate sun position only and exit");
-
+    flag3->guisection = _("Print");
+    
     flag4 = G_define_flag();
     flag4->key = 'g';
     flag4->description =
 	_("Print the sun position output in shell script style");
+    flag4->guisection = _("Print");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -342,7 +343,7 @@
 	if (retval == 0) {	/* error check */
 	    if (flag2->answer || (flag3->answer && !flag2->answer)) {
 		if (flag4->answer) {
-		    fprintf(stdout, "date=%d.%02d.%02d\n", pdat->year,
+		    fprintf(stdout, "date=%d/%02d/%02d\n", pdat->year,
 			    pdat->month, pdat->day);
 		    fprintf(stdout, "daynum=%d\n", pdat->daynum);
 		    fprintf(stdout, "time=%02i:%02i:%02i\n", pdat->hour,
@@ -366,24 +367,24 @@
 		    }
 		}
 		else {
-		    G_message(_("%d.%02d.%02d, daynum %d, time: %02i:%02i:%02i (decimal time: %f)"),
-			      pdat->year, pdat->month, pdat->day,
-			      pdat->daynum, pdat->hour, pdat->minute,
-			      pdat->second,
-			      pdat->hour + (pdat->minute * 100.0 / 60.0 +
-					    pdat->second * 100.0 / 3600.0) /
-			      100.);
-		    G_message(_("long: %f, lat: %f, timezone: %f"),
-			      pdat->longitude, pdat->latitude,
-			      pdat->timezone);
-		    G_message(_("Solar position: sun azimuth: %f, sun angle above horz.(refraction corrected): %f"),
-			      pdat->azim, pdat->elevref);
-
+		    fprintf(stdout, "%d/%02d/%02d, daynum: %d, time: %02i:%02i:%02i (decimal time: %f)\n",
+			    pdat->year, pdat->month, pdat->day,
+			    pdat->daynum, pdat->hour, pdat->minute,
+			    pdat->second,
+			    pdat->hour + (pdat->minute * 100.0 / 60.0 +
+					  pdat->second * 100.0 / 3600.0) /
+			    100.);
+		    fprintf(stdout, "long: %f, lat: %f, timezone: %f\n",
+			    pdat->longitude, pdat->latitude,
+			    pdat->timezone);
+		    fprintf(stdout, "Solar position: sun azimuth: %f, sun angle above horz. (refraction corrected): %f\n",
+			    pdat->azim, pdat->elevref);
+		    
 		    if (sretr / 60 <= 24.0) {
-			G_message(_("Sunrise time (without refraction): %02d:%02d:%02d\n"),
-				  sretr / 60, sretr % 60, sretr_sec);
-			G_message(_("Sunset time  (without refraction): %02d:%02d:%02d\n"),
-				  ssetr / 60, ssetr % 60, ssetr_sec);
+			fprintf(stdout, "Sunrise time (without refraction): %02d:%02d:%02d\n",
+				sretr / 60, sretr % 60, sretr_sec);
+			fprintf(stdout, "Sunset time  (without refraction): %02d:%02d:%02d\n",
+				ssetr / 60, ssetr % 60, ssetr_sec);
 		    }
 		}
 	    }
@@ -429,7 +430,6 @@
     }
 
     if (flag3->answer && (use_solpos == 1)) {	/* we only want the sun position */
-	G_message(_("No map calculation requested. Finished."));
 	exit(EXIT_SUCCESS);
     }
     else if (flag3->answer && (use_solpos == 0)) {
@@ -438,6 +438,9 @@
 	exit(EXIT_SUCCESS);
     }
 
+    if (!outname)
+	G_fatal_error(_("Option <%s> required"), parm.opt2->key);
+    
     /* Search for output layer in all mapsets ? yes. */
     mapset = G_find_cell2(name, "");
 
@@ -470,7 +473,6 @@
     row1 = 0;
 
     G_message(_("Calculating shadows from DEM..."));
-
     while (row1 < window.rows) {
 	G_percent(row1, window.rows, 2);
 	col1 = 0;
@@ -524,6 +526,7 @@
 	G_put_raster_row(output_fd, outbuf.c, CELL_TYPE);
 	row1 += 1;
     }
+    G_percent(1, 1, 1);
 
     G_close_cell(output_fd);
     G_close_cell(elev_fd);



More information about the grass-commit mailing list