[GRASS-SVN] r63777 - in grass/trunk/raster: r.ros r.spread
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 26 20:51:57 PST 2014
Author: wenzeslaus
Date: 2014-12-26 20:51:57 -0800 (Fri, 26 Dec 2014)
New Revision: 63777
Modified:
grass/trunk/raster/r.ros/main.c
grass/trunk/raster/r.spread/main.c
Log:
r.ros and r.spread: replace basename/prefix by separate options
* basename with small number of clearly defined maps does not make sense because it is just harder to understand and parse
* also sync r.ros output option names with r.spread inputs
* use full(er) names where possible
* introduction of separate option for spotting removes the need for -s flag in r.ros (the same could be potentially done for r.spread too)
Modified: grass/trunk/raster/r.ros/main.c
===================================================================
--- grass/trunk/raster/r.ros/main.c 2014-12-26 23:50:11 UTC (rev 63776)
+++ grass/trunk/raster/r.ros/main.c 2014-12-27 04:51:57 UTC (rev 63777)
@@ -175,7 +175,7 @@
elev_fd = 0, slope_fd = 0, aspect_fd = 0,
base_fd = 0, max_fd = 0, maxdir_fd = 0, spotdist_fd = 0;
- char name_base[60], name_max[60], name_maxdir[60], name_spotdist[60];
+ char *name_base, *name_max, *name_maxdir, *name_spotdist;
CELL *fuel, /*cell buffer for fuel model map layer */
*mois_1h, /*cell buffer for 1-hour fuel moisture map layer */
@@ -198,7 +198,7 @@
{
struct Option *model,
*mois_1h, *mois_10h, *mois_100h, *mois_live,
- *vel, *dir, *elev, *slope, *aspect, *output;
+ *vel, *dir, *elev, *slope, *aspect, *base, *max, *maxdir, *spotdist;
} parm;
/* please, remove before GRASS 7 released */
@@ -314,27 +314,55 @@
parm.elev = G_define_standard_option(G_OPT_R_ELEV);
parm.elev->required = NO;
parm.elev->label =
- _("Raster map containing elevation (m, required with -s)");
+ _("Raster map containing elevation (m, required for spotting)");
parm.elev->description =
_("Name of an existing raster map "
"layer in the user's current mapset search path containing elevation (meters). "
"Option is required from spotting distance computation "
- "(when -s flag is enabled)");
+ "(when spotting_distance option is provided)");
- parm.output = G_define_standard_option(G_OPT_R_OUTPUT);
- parm.output->description =
- _("Prefix for output raster maps (.base, .max, .maxdir, .spotdist)");
+ parm.base = G_define_standard_option(G_OPT_R_OUTPUT);
+ parm.base->key = "base_ros";
+ parm.base->required = YES;
+ parm.base->label =
+ _("Output raster map containing base ROS (cm/min)");
+ parm.base->description =
+ _("Base (perpendicular) rate of spread (ROS)");
- flag_s = G_define_flag();
- flag_s->key = 's';
- flag_s->description = _("Also produce maximum spotting distance");
+ parm.max = G_define_standard_option(G_OPT_R_OUTPUT);
+ parm.max->key = "max_ros";
+ parm.max->required = YES;
+ parm.max->label =
+ _("Output raster map containing maximal ROS (cm/min)");
+ parm.max->description =
+ _("The maximum (forward) rate of spread (ROS)");
+ parm.maxdir = G_define_standard_option(G_OPT_R_OUTPUT);
+ parm.maxdir->key = "direction_ros";
+ parm.maxdir->required = YES;
+ parm.maxdir->label =
+ _("Output raster map containing directions of maximal ROS (degree)");
+ parm.maxdir->description =
+ _("The direction of the maximal (forward) rate of spread (ROS)");
+
+ parm.spotdist = G_define_standard_option(G_OPT_R_OUTPUT);
+ parm.spotdist->key = "spotting_distance";
+ parm.spotdist->required = NO;
+ parm.spotdist->label =
+ _("Output raster map containing maximal spotting distance (m)");
+ parm.spotdist->description =
+ _("The maximal potential spotting distance raster will be also generated"
+ " (requires elevation raster map to be provided).");
+
/* Parse command line */
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
-
- spotting = flag_s->answer;
+ if (parm.spotdist->answer)
+ spotting = 1;
+ else
+ spotting = 0;
+
/* Check if input layers exists in data base */
if (G_find_raster2(parm.model->answer, "") == NULL)
G_fatal_error(_("Raster map <%s> not found"), parm.model->answer);
@@ -417,9 +445,9 @@
}
/*assign names of the three output ROS layers */
- sprintf(name_base, "%s.base", parm.output->answer);
- sprintf(name_max, "%s.max", parm.output->answer);
- sprintf(name_maxdir, "%s.maxdir", parm.output->answer);
+ name_base = parm.base->answer;
+ name_max = parm.max->answer;
+ name_maxdir = parm.maxdir->answer;
/*check if the output layer names EXIST */
if (G_check_overwrite(argc, argv) == 0) {
@@ -437,7 +465,7 @@
/*assign a name to output SPOTTING distance layer */
if (spotting) {
- sprintf(name_spotdist, "%s.spotdist", parm.output->answer);
+ name_spotdist = parm.spotdist->answer;
if (G_find_raster2(name_spotdist, G_mapset()))
G_fatal_error(_("Raster map <%s> already exists in mapset <%s>"),
name_spotdist, G_mapset());
Modified: grass/trunk/raster/r.spread/main.c
===================================================================
--- grass/trunk/raster/r.spread/main.c 2014-12-26 23:50:11 UTC (rev 63776)
+++ grass/trunk/raster/r.spread/main.c 2014-12-27 04:51:57 UTC (rev 63777)
@@ -116,8 +116,22 @@
"coordinates for tracing spread paths. "
"Usable for fire spread simulations.");
+ parm.base = G_define_option();
+ parm.base->key = "base_ros";
+ parm.base->type = TYPE_STRING;
+ parm.base->required = YES;
+ parm.base->gisprompt = "old,cell,raster";
+ parm.base->guisection = _("Input");
+ parm.base->label =
+ _("Raster map containing base ROS (cm/min)");
+ parm.base->description =
+ _("Name of an existing raster map layer in the user's "
+ "current mapset search path containing the ROS values in the directions "
+ "perpendicular to maximum ROSes' (cm/minute). These ROSes are also the ones "
+ "without the effect of directional factors.");
+
parm.max = G_define_option();
- parm.max->key = "max";
+ parm.max->key = "max_ros";
parm.max->type = TYPE_STRING;
parm.max->required = YES;
parm.max->gisprompt = "old,cell,raster";
@@ -129,7 +143,7 @@
"mapset search path containing the maximum ROS values (cm/minute).");
parm.dir = G_define_option();
- parm.dir->key = "dir";
+ parm.dir->key = "direction_ros";
parm.dir->type = TYPE_STRING;
parm.dir->required = YES;
parm.dir->gisprompt = "old,cell,raster";
@@ -141,20 +155,6 @@
"current mapset search path containing directions of the maximum ROSes, "
"clockwise from north (degree)."); /* TODO: clockwise from north? see r.ros */
- parm.base = G_define_option();
- parm.base->key = "base";
- parm.base->type = TYPE_STRING;
- parm.base->required = YES;
- parm.base->gisprompt = "old,cell,raster";
- parm.base->guisection = _("Input");
- parm.base->label =
- _("Raster map containing base ROS (cm/min)");
- parm.base->description =
- _("Name of an existing raster map layer in the user's "
- "current mapset search path containing the ROS values in the directions "
- "perpendicular to maximum ROSes' (cm/minute). These ROSes are also the ones "
- "without the effect of directional factors.");
-
parm.start = G_define_option();
parm.start->key = "start";
parm.start->type = TYPE_STRING;
@@ -170,7 +170,7 @@
"starting sources (seeds).");
parm.spotdist = G_define_option();
- parm.spotdist->key = "spot_dist";
+ parm.spotdist->key = "spotting_distance";
parm.spotdist->type = TYPE_STRING;
parm.spotdist->gisprompt = "old,cell,raster";
parm.spotdist->guisection = _("Input");
@@ -182,7 +182,7 @@
"spotting distances (meters).");
parm.velocity = G_define_option();
- parm.velocity->key = "w_speed";
+ parm.velocity->key = "wind_speed";
parm.velocity->type = TYPE_STRING;
parm.velocity->gisprompt = "old,cell,raster";
parm.velocity->guisection = _("Input");
@@ -194,7 +194,7 @@
"the average flame height (feet/minute).");
parm.mois = G_define_option();
- parm.mois->key = "f_mois";
+ parm.mois->key = "fuel_moisture";
parm.mois->type = TYPE_STRING;
parm.mois->gisprompt = "old,cell,raster";
parm.mois->guisection = _("Input");
More information about the grass-commit
mailing list