[GRASS-SVN] r44254 - grass/branches/develbranch_6/raster/r.sunmask
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 8 15:58:28 EST 2010
Author: martinl
Date: 2010-11-08 12:58:28 -0800 (Mon, 08 Nov 2010)
New Revision: 44254
Modified:
grass/branches/develbranch_6/raster/r.sunmask/main.c
Log:
r.sunmask: 'output' optional (not required for '-s')
Modified: grass/branches/develbranch_6/raster/r.sunmask/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.sunmask/main.c 2010-11-08 20:36:14 UTC (rev 44253)
+++ grass/branches/develbranch_6/raster/r.sunmask/main.c 2010-11-08 20:58:28 UTC (rev 44254)
@@ -112,15 +112,15 @@
G_gisinit(argv[0]);
module = G_define_module();
- module->keywords = _("raster");
+ 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.");
+ "the sun position (B) by r.sunmask itself.");
parm.opt1 = G_define_standard_option(G_OPT_R_ELEV);
- parm.opt1->key = "elev";
-
+
parm.opt2 = G_define_standard_option(G_OPT_R_OUTPUT);
+ parm.opt2->required = NO;
parm.opt3 = G_define_option();
parm.opt3->key = "altitude";
@@ -229,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);
@@ -341,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,
@@ -365,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);
}
}
}
@@ -428,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)) {
@@ -437,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, "");
@@ -469,7 +473,6 @@
row1 = 0;
G_message(_("Calculating shadows from DEM..."));
-
while (row1 < window.rows) {
G_percent(row1, window.rows, 2);
col1 = 0;
@@ -523,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