瀏覽代碼

parser: add standard option for 2D raster map type

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68867 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 8 年之前
父節點
當前提交
ff9a83b163

+ 1 - 0
general/g.parser/standard_option.c

@@ -22,6 +22,7 @@ static char* STD_OPT_STRINGS[] = {"G_OPT_UNDEFINED",
                                   "G_OPT_R_COVER",
                                   "G_OPT_R_ELEV",
                                   "G_OPT_R_ELEVS",
+                                  "G_OPT_R_TYPE",
                                   "G_OPT_R_INTERP_TYPE",
                                   "G_OPT_R_BASENAME_INPUT",
                                   "G_OPT_R_BASENAME_OUTPUT",

+ 1 - 0
include/gis.h

@@ -231,6 +231,7 @@ typedef enum
     G_OPT_R_COVER,		/*!< old input cover raster map */
     G_OPT_R_ELEV,		/*!< old input elevation raster map */
     G_OPT_R_ELEVS,		/*!< old input elevation raster maps */
+    G_OPT_R_TYPE,               /*!< raster map type */
     G_OPT_R_INTERP_TYPE,        /*!< interpolation type */
     G_OPT_R_BASENAME_INPUT,     /*!< old input basename raster maps */
     G_OPT_R_BASENAME_OUTPUT,    /*!< new output basename raster maps */

+ 15 - 0
lib/gis/parser_standard_options.c

@@ -60,6 +60,7 @@
    - G_OPT_R_COVER
    - G_OPT_R_ELEV
    - G_OPT_R_ELEVS
+   - G_OPT_R_TYPE
    - G_OPT_R_INTERP_TYPE
    - G_OPT_R_BASENAME_INPUT
    - G_OPT_R_BASENAME_OUTPUT
@@ -325,6 +326,20 @@ struct Option *G_define_standard_option(int opt)
 	Opt->gisprompt = "old,cell,raster";
 	Opt->description = _("Name of input elevation raster map(s)");
 	break;
+    case G_OPT_R_TYPE:
+        Opt->key = "type";
+        Opt->type = TYPE_STRING;
+        Opt->required = YES;
+        Opt->multiple = NO;
+        Opt->label = _("Type of raster map to be created");
+        Opt->description = _("Storage type for resultant raster map");
+        Opt->options = "CELL,FCELL,DCELL";
+        G_asprintf((char **) &(Opt->descriptions),
+                   "CELL;%s;FCELL;%s;DCELL;%s",
+                   _("Integer"),
+                   _("Single precision floating point"),
+                   _("Double precision floating point"));
+        break;
     case G_OPT_R_INTERP_TYPE:
         Opt->key = "method";
         Opt->type = TYPE_STRING;

+ 2 - 6
raster/r.in.ascii/main.c

@@ -80,14 +80,10 @@ int main(int argc, char *argv[])
 
     parm.output = G_define_standard_option(G_OPT_R_OUTPUT);
 
-    parm.type = G_define_option();
-    parm.type->key = "type";
-    parm.type->type = TYPE_STRING;
+    parm.type = G_define_standard_option(G_OPT_R_TYPE);
     parm.type->required = NO;
-    parm.type->options = "CELL,FCELL,DCELL";
-    parm.type->label = _("Storage type for resultant raster map");
     parm.type->description = _("Default: CELL for integer values, DCELL for floating-point values");
-    
+
     parm.title = G_define_option();
     parm.title->key = "title";
     parm.title->key_desc = "phrase";

+ 1 - 5
raster/r.in.lidar/main.c

@@ -167,13 +167,9 @@ int main(int argc, char *argv[])
                _("Skewness of point values in cell"),
                _("Trimmed mean of point values in cell"));
 
-    type_opt = G_define_option();
-    type_opt->key = "type";
-    type_opt->type = TYPE_STRING;
+    type_opt = G_define_standard_option(G_OPT_R_TYPE);
     type_opt->required = NO;
-    type_opt->options = "CELL,FCELL,DCELL";
     type_opt->answer = "FCELL";
-    type_opt->description = _("Storage type for resultant raster map");
 
     base_raster_opt = G_define_standard_option(G_OPT_R_INPUT);
     base_raster_opt->key = "base_raster";

+ 1 - 5
raster/r.in.poly/main.c

@@ -49,12 +49,8 @@ int main(int argc, char *argv[])
     title->required = NO;
     title->description = _("Title for resultant raster map");
 
-    type = G_define_option();
-    type->key = "type";
-    type->type = TYPE_STRING;
+    type = G_define_standard_option(G_OPT_R_TYPE);
     type->required = NO;
-    type->description = _("Output raster type");
-    type->options = "CELL,FCELL,DCELL";
     type->answer = "CELL";
 
     nulls = G_define_option();

+ 1 - 5
raster/r.in.xyz/main.c

@@ -209,13 +209,9 @@ int main(int argc, char *argv[])
                _("Skewness of point values in cell"),
                _("Trimmed mean of point values in cell"));
 
-    type_opt = G_define_option();
-    type_opt->key = "type";
-    type_opt->type = TYPE_STRING;
+    type_opt = G_define_standard_option(G_OPT_R_TYPE);
     type_opt->required = NO;
-    type_opt->options = "CELL,FCELL,DCELL";
     type_opt->answer = "FCELL";
-    type_opt->description = _("Storage type for resultant raster map");
 
     delim_opt = G_define_standard_option(G_OPT_F_SEP);
     delim_opt->guisection = _("Input");

+ 3 - 4
raster/r.slope.aspect/main.c

@@ -180,11 +180,10 @@ int main(int argc, char *argv[])
     parm.slope_fmt->description = _("Format for reporting the slope");
     parm.slope_fmt->guisection = _("Settings");
 
-    parm.out_precision = G_define_option();
+    parm.out_precision = G_define_standard_option(G_OPT_R_TYPE);
     parm.out_precision->key = "precision";
-    parm.out_precision->type = TYPE_STRING;
-    parm.out_precision->options = "CELL,FCELL,DCELL";
-    parm.out_precision->description =
+    parm.out_precision->required = NO;
+    parm.out_precision->label =
 	_("Type of output aspect and slope maps");
     parm.out_precision->answer = "FCELL";
     parm.out_precision->guisection = _("Settings");

+ 2 - 5
scripts/r.plane/r.plane.py

@@ -57,12 +57,9 @@
 #% description: Elevation coordinate of a point on the plane
 #% required : yes
 #%end
-#%option
-#% key: type
-#% type: string
-#% options: CELL,FCELL,DCELL
-#% description: Type of raster map to be created
+#%option G_OPT_R_TYPE
 #% answer: FCELL
+#% required: no
 #%end
 
 import math