GRASS GIS 8 Programmer's Manual  8.5.0dev(2025)-565e82de51
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parser_standard_options.c
Go to the documentation of this file.
1 /*!
2  \file lib/gis/parser_standard_options.c
3 
4  \brief GIS Library - Argument parsing functions (standard options)
5 
6  (C) 2001-2019 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Original author CERL
12  \author Soeren Gebbert added Dec. 2009 WPS process_description document
13  \author Luca Delucchi added Aug 2011 G_OPT_M_DIR
14  */
15 
16 #include <grass/gis.h>
17 #include <grass/glocale.h>
18 
19 #include "parser_local_proto.h"
20 
21 /*!
22  \brief Create standardised Option structure.
23 
24  This function will create a standardised Option structure defined by
25  parameter <i>opt</i>.
26 
27  Valid parameters are defined by the STD_OPT enum in the file gis.h.
28  A list of valid parameter values sorted to groups is below.
29 
30  This function allocates memory for the Option structure and returns a
31  pointer to this memory.
32 
33  If an invalid parameter was specified a empty Option structure will
34  be returned (not NULL).
35 
36  Values also need to be added to general/g.parser/standard_option.c
37 
38  \par List of STD_OPT values sorted by module group
39  - database:
40  - G_OPT_DB_SQL
41  - G_OPT_DB_WHERE
42  - G_OPT_DB_TABLE
43  - G_OPT_DB_DRIVER
44  - G_OPT_DB_DATABASE
45  - G_OPT_DB_SCHEMA
46  - G_OPT_DB_COLUMN
47  - G_OPT_DB_COLUMNS
48  - G_OPT_DB_KEYCOLUMN
49 
50  - imagery:
51  - G_OPT_I_GROUP
52  - G_OPT_I_SUBGROUP
53 
54  - raster:
55  - G_OPT_MEMORYMB
56  - G_OPT_R_INPUT
57  - G_OPT_R_INPUTS
58  - G_OPT_R_OUTPUT
59  - G_OPT_R_MAP
60  - G_OPT_R_MAPS
61  - G_OPT_R_BASE
62  - G_OPT_R_COVER
63  - G_OPT_R_ELEV
64  - G_OPT_R_ELEVS
65  - G_OPT_R_TYPE
66  - G_OPT_R_INTERP_TYPE
67  - G_OPT_R_BASENAME_INPUT
68  - G_OPT_R_BASENAME_OUTPUT
69 
70  - raster3d:
71  - G_OPT_R3_INPUT
72  - G_OPT_R3_INPUTS
73  - G_OPT_R3_OUTPUT
74  - G_OPT_R3_MAP
75  - G_OPT_R3_MAPS
76 
77  - vector:
78  - G_OPT_V_INPUT
79  - G_OPT_V_INPUTS
80  - G_OPT_V_OUTPUT
81  - G_OPT_V_MAP
82  - G_OPT_V_MAPS
83  - G_OPT_V_TYPE
84  - G_OPT_V_FIELD
85  - G_OPT_V_FIELD_ALL
86  - G_OPT_V_CAT
87  - G_OPT_V_CATS
88  - G_OPT_V_ID
89  - G_OPT_V_IDS
90 
91  - files
92  - G_OPT_F_INPUT
93  - G_OPT_F_BIN_INPUT
94  - G_OPT_F_OUTPUT
95  - G_OPT_F_SEP
96 
97  - colors
98  - G_OPT_C
99  - G_OPT_CN
100  - G_OPT_C_FORMAT
101 
102  - misc
103  - G_OPT_M_DIR
104  - G_OPT_M_UNITS
105  - G_OPT_M_DATATYPE
106  - G_OPT_M_MAPSET
107  - G_OPT_M_LOCATION
108  - G_OPT_M_DBASE
109  - G_OPT_M_COORDS
110  - G_OPT_M_COLR
111  - G_OPT_M_REGION
112  - G_OPT_M_NULL_VALUE
113  - G_OPT_M_NPROCS
114  - G_OPT_M_SEED
115 
116  - temporal GIS framework
117  - G_OPT_STDS_INPUT
118  - G_OPT_STDS_INPUTS
119  - G_OPT_STDS_OUTPUT
120  - G_OPT_STRDS_INPUT
121  - G_OPT_STRDS_INPUTS
122  - G_OPT_STRDS_OUTPUT
123  - G_OPT_STRDS_OUTPUTS
124  - G_OPT_STR3DS_INPUT
125  - G_OPT_STR3DS_INPUTS
126  - G_OPT_STR3DS_OUTPUT
127  - G_OPT_STVDS_INPUT
128  - G_OPT_STVDS_INPUTS
129  - G_OPT_STVDS_OUTPUT
130  - G_OPT_MAP_INPUT
131  - G_OPT_MAP_INPUTS
132  - G_OPT_STDS_TYPE
133  - G_OPT_MAP_TYPE
134  - G_OPT_T_TYPE
135  - G_OPT_T_WHERE
136 
137  \param opt type of Option struct to create specified by STD_OPT enum
138 
139  \return pointer to an Option struct
140  */
142 {
143  struct Option *Opt;
144  char *memstr;
145 
146  Opt = G_define_option();
147 
148  switch (opt) {
149  case G_OPT_DB_SQL:
150  Opt->key = "sql";
151  Opt->type = TYPE_STRING;
152  Opt->key_desc = "sql_query";
153  Opt->required = NO;
154  Opt->label = _("SQL SELECT statement");
155  Opt->description =
156  _("Example: select * from towns where population > 10000");
157  break;
158  case G_OPT_DB_WHERE:
159  Opt->key = "where";
160  Opt->type = TYPE_STRING;
161  Opt->gisprompt = "old,sql_query,sql_query";
162  Opt->key_desc = "sql_query";
163  Opt->required = NO;
164  Opt->label =
165  _("WHERE conditions of SQL statement without 'where' keyword");
166  Opt->description = _("Example: income < 1000 and population >= 10000");
167  break;
168  case G_OPT_DB_TABLE:
169  Opt->key = "table";
170  Opt->type = TYPE_STRING;
171  Opt->key_desc = "name";
172  Opt->required = NO;
173  Opt->multiple = NO;
174  Opt->description = _("Name of attribute table");
175  Opt->gisprompt = "old,dbtable,dbtable";
176  break;
177  case G_OPT_DB_DRIVER:
178  Opt->key = "driver";
179  Opt->type = TYPE_STRING;
180  Opt->key_desc = "name";
181  Opt->required = NO;
182  Opt->multiple = NO;
183  Opt->description = _("Name of database driver");
184  Opt->gisprompt = "old,dbdriver,dbdriver";
185  break;
186  case G_OPT_DB_DATABASE:
187  Opt->key = "database";
188  Opt->type = TYPE_STRING;
189  Opt->key_desc = "name";
190  Opt->required = NO;
191  Opt->multiple = NO;
192  Opt->description = _("Name of database");
193  Opt->gisprompt = "old,dbname,dbname";
194  break;
195  case G_OPT_DB_SCHEMA:
196  Opt->key = "schema";
197  Opt->type = TYPE_STRING;
198  Opt->key_desc = "name";
199  Opt->required = NO;
200  Opt->multiple = NO;
201  Opt->label = _("Database schema");
202  Opt->description = _("Do not use this option if schemas "
203  "are not supported by driver/database server");
204  break;
205  case G_OPT_DB_COLUMN:
206  Opt->key = "column";
207  Opt->type = TYPE_STRING;
208  Opt->key_desc = "name";
209  Opt->required = NO;
210  Opt->multiple = NO;
211  Opt->description = _("Name of attribute column");
212  Opt->gisprompt = "old,dbcolumn,dbcolumn";
213  break;
214  case G_OPT_DB_COLUMNS:
215  Opt->key = "columns";
216  Opt->type = TYPE_STRING;
217  Opt->key_desc = "name";
218  Opt->required = NO;
219  Opt->multiple = YES;
220  Opt->description = _("Name of attribute column(s)");
221  Opt->gisprompt = "old,dbcolumn,dbcolumn";
222  break;
223  case G_OPT_DB_KEYCOLUMN:
224  Opt->key = "key";
225  Opt->type = TYPE_STRING;
226  Opt->key_desc = "name";
227  Opt->required = NO;
228  Opt->multiple = NO;
229  Opt->label = _("Name of key column");
230  Opt->description = _("Must refer to an integer column");
231  /* Opt->gisprompt = "old,dbcolumn,dbcolumn"; */
232  Opt->answer = GV_KEY_COLUMN;
233  break;
234 
235  /* imagery group */
236  case G_OPT_I_GROUP:
237  Opt->key = "group";
238  Opt->type = TYPE_STRING;
239  Opt->key_desc = "name";
240  Opt->required = YES;
241  Opt->gisprompt = "old,group,group";
242  Opt->description = _("Name of input imagery group");
243  break;
244  case G_OPT_I_SUBGROUP:
245  Opt->key = "subgroup";
246  Opt->type = TYPE_STRING;
247  Opt->key_desc = "name";
248  Opt->required = YES;
249  Opt->gisprompt = "old,subgroup,subgroup";
250  Opt->description = _("Name of input imagery subgroup");
251  break;
252 
253  /* raster maps */
254  case G_OPT_MEMORYMB:
255  Opt->key = "memory";
256  Opt->type = TYPE_INTEGER;
257  Opt->key_desc = "memory in MB";
258  Opt->required = NO;
259  Opt->multiple = NO;
260  Opt->answer = "300";
261  /* start dynamic answer */
262  /* check MEMORYMB in GISRC, set with g.gisenv */
263  memstr = G_store(G_getenv_nofatal("MEMORYMB"));
264  if (memstr && *memstr)
265  Opt->answer = memstr;
266  /* end dynamic answer */
267  Opt->label = _("Maximum memory to be used (in MB)");
268  Opt->description = _("Cache size for raster rows");
269  break;
270  case G_OPT_R_INPUT:
271  Opt->key = "input";
272  Opt->type = TYPE_STRING;
273  Opt->key_desc = "name";
274  Opt->required = YES;
275  Opt->gisprompt = "old,cell,raster";
276  Opt->description = _("Name of input raster map");
277  break;
278  case G_OPT_R_INPUTS:
279  Opt->key = "input";
280  Opt->type = TYPE_STRING;
281  Opt->key_desc = "name";
282  Opt->required = YES;
283  Opt->multiple = YES;
284  Opt->gisprompt = "old,cell,raster";
285  Opt->description = _("Name of input raster map(s)");
286  break;
287  case G_OPT_R_OUTPUT:
288  Opt->key = "output";
289  Opt->type = TYPE_STRING;
290  Opt->key_desc = "name";
291  Opt->required = YES;
292  Opt->gisprompt = "new,cell,raster";
293  Opt->description = _("Name for output raster map");
294  break;
295  case G_OPT_R_OUTPUTS:
296  Opt->key = "output";
297  Opt->type = TYPE_STRING;
298  Opt->key_desc = "name";
299  Opt->required = YES;
300  Opt->multiple = YES;
301  Opt->gisprompt = "new,cell,raster";
302  Opt->description = _("Name for output raster map(s)");
303  break;
304  case G_OPT_R_MAP:
305  Opt->key = "map";
306  Opt->type = TYPE_STRING;
307  Opt->key_desc = "name";
308  Opt->required = YES;
309  Opt->gisprompt = "old,cell,raster";
310  Opt->description = _("Name of raster map");
311  break;
312  case G_OPT_R_MAPS:
313  Opt->key = "map";
314  Opt->type = TYPE_STRING;
315  Opt->key_desc = "name";
316  Opt->required = YES;
317  Opt->multiple = YES;
318  Opt->gisprompt = "old,cell,raster";
319  Opt->description = _("Name of raster map(s)");
320  break;
321  case G_OPT_R_BASE:
322  Opt->key = "base";
323  Opt->type = TYPE_STRING;
324  Opt->key_desc = "name";
325  Opt->required = YES;
326  Opt->gisprompt = "old,cell,raster";
327  Opt->description = _("Name of base raster map");
328  break;
329  case G_OPT_R_COVER:
330  Opt->key = "cover";
331  Opt->type = TYPE_STRING;
332  Opt->key_desc = "name";
333  Opt->required = YES;
334  Opt->gisprompt = "old,cell,raster";
335  Opt->description = _("Name of cover raster map");
336  break;
337  case G_OPT_R_ELEV:
338  Opt->key = "elevation";
339  Opt->type = TYPE_STRING;
340  Opt->key_desc = "name";
341  Opt->required = YES;
342  Opt->gisprompt = "old,cell,raster";
343  Opt->description = _("Name of input elevation raster map");
344  break;
345  case G_OPT_R_ELEVS:
346  Opt->key = "elevation";
347  Opt->type = TYPE_STRING;
348  Opt->key_desc = "name";
349  Opt->required = YES;
350  Opt->multiple = YES;
351  Opt->gisprompt = "old,cell,raster";
352  Opt->description = _("Name of input elevation raster map(s)");
353  break;
354  case G_OPT_R_TYPE:
355  Opt->key = "type";
356  Opt->type = TYPE_STRING;
357  Opt->required = YES;
358  Opt->multiple = NO;
359  Opt->label = _("Type of raster map to be created");
360  Opt->description = _("Storage type for resultant raster map");
361  Opt->options = "CELL,FCELL,DCELL";
362  G_asprintf((char **)&(Opt->descriptions), "CELL;%s;FCELL;%s;DCELL;%s",
363  _("Integer"), _("Single precision floating point"),
364  _("Double precision floating point"));
365  break;
366  case G_OPT_R_INTERP_TYPE:
367  Opt->key = "method";
368  Opt->type = TYPE_STRING;
369  Opt->required = NO;
370  Opt->description = _("Sampling interpolation method");
371  Opt->options = "nearest,bilinear,bicubic";
372  G_asprintf((char **)&(Opt->descriptions),
373  "nearest;%s;bilinear;%s;bicubic;%s",
374  _("Nearest-neighbor interpolation"),
375  _("Bilinear interpolation"), _("Bicubic interpolation"));
376  break;
378  Opt->key = "input";
379  Opt->type = TYPE_STRING;
380  Opt->key_desc = "basename";
381  Opt->required = YES;
382  Opt->multiple = NO;
383  Opt->gisprompt = "old,cell,raster";
384  Opt->description = _("Name of input basename raster map(s)");
385  break;
387  Opt->key = "output";
388  Opt->type = TYPE_STRING;
389  Opt->key_desc = "basename";
390  Opt->required = YES;
391  Opt->multiple = NO;
392  Opt->gisprompt = "new,cell,raster";
393  Opt->description = _("Name for output basename raster map(s)");
394  break;
395 
396  /*g3d maps */
397  case G_OPT_R3_INPUT:
398  Opt->key = "input";
399  Opt->type = TYPE_STRING;
400  Opt->key_desc = "name";
401  Opt->required = YES;
402  Opt->gisprompt = "old,grid3,raster_3d";
403  Opt->description = _("Name of input 3D raster map");
404  break;
405  case G_OPT_R3_INPUTS:
406  Opt->key = "input";
407  Opt->type = TYPE_STRING;
408  Opt->key_desc = "name";
409  Opt->required = YES;
410  Opt->multiple = YES;
411  Opt->gisprompt = "old,grid3,raster_3d";
412  Opt->description = _("Name of input 3D raster map(s)");
413  break;
414  case G_OPT_R3_OUTPUT:
415  Opt->key = "output";
416  Opt->type = TYPE_STRING;
417  Opt->key_desc = "name";
418  Opt->required = YES;
419  Opt->gisprompt = "new,grid3,raster_3d";
420  Opt->description = _("Name for output 3D raster map");
421  break;
422  case G_OPT_R3_MAP:
423  Opt->key = "map";
424  Opt->type = TYPE_STRING;
425  Opt->key_desc = "name";
426  Opt->required = YES;
427  Opt->gisprompt = "old,grid3,raster_3d";
428  Opt->description = _("Name of 3D raster map");
429  break;
430  case G_OPT_R3_MAPS:
431  Opt->key = "map";
432  Opt->type = TYPE_STRING;
433  Opt->key_desc = "name";
434  Opt->required = YES;
435  Opt->multiple = YES;
436  Opt->gisprompt = "old,grid3,raster_3d";
437  Opt->description = _("Name of 3D raster map(s)");
438  break;
439  case G_OPT_R3_TYPE:
440  Opt->key = "type";
441  Opt->type = TYPE_STRING;
442  Opt->required = NO;
443  Opt->multiple = NO;
444  Opt->answer = "default";
445  Opt->options = "default,double,float";
446  Opt->description = _("Data type used in the output raster3d map");
447  break;
448  case G_OPT_R3_PRECISION:
449  Opt->key = "precision";
450  Opt->type = TYPE_STRING;
451  Opt->required = NO;
452  Opt->multiple = NO;
453  Opt->answer = "default";
454  Opt->description =
455  _("Number of digits used as mantissa in the internal map storage, "
456  "0 -23 for float, 0 - 52 for double, max or default");
457  break;
459  Opt->key = "compression";
460  Opt->type = TYPE_STRING;
461  Opt->required = NO;
462  Opt->multiple = NO;
463  Opt->answer = "default";
464  Opt->options = "default,zip,none";
465  Opt->description =
466  _("The compression method used in the output raster3d map");
467  break;
469  Opt->key = "tiledimension";
470  Opt->type = TYPE_STRING;
471  Opt->required = NO;
472  Opt->multiple = NO;
473  Opt->key_desc = "XxYxZ";
474  Opt->answer = "default";
475  Opt->description = _("The dimensions of the tiles used in the output "
476  "raster3d map (XxYxZ or default: 16x16x8)");
477  break;
478 
479  /*vector maps */
480  case G_OPT_V_INPUT:
481  Opt->key = "input";
482  Opt->type = TYPE_STRING;
483  Opt->key_desc = "name";
484  Opt->required = YES;
485  Opt->gisprompt = "old,vector,vector";
486  Opt->label = _("Name of input vector map");
487  Opt->description = _("Or data source for direct OGR access");
488  break;
489  case G_OPT_V_INPUTS:
490  Opt->key = "input";
491  Opt->type = TYPE_STRING;
492  Opt->key_desc = "name";
493  Opt->required = YES;
494  Opt->multiple = YES;
495  Opt->gisprompt = "old,vector,vector";
496  Opt->label = _("Name of input vector map(s)");
497  Opt->description = _("Or data source(s) for direct OGR access");
498  break;
499  case G_OPT_V_OUTPUT:
500  Opt->key = "output";
501  Opt->type = TYPE_STRING;
502  Opt->key_desc = "name";
503  Opt->required = YES;
504  Opt->gisprompt = "new,vector,vector";
505  Opt->description = _("Name for output vector map");
506  break;
507  case G_OPT_V_MAP:
508  Opt->key = "map";
509  Opt->type = TYPE_STRING;
510  Opt->key_desc = "name";
511  Opt->required = YES;
512  Opt->gisprompt = "old,vector,vector";
513  Opt->label = _("Name of vector map");
514  Opt->description = _("Or data source for direct OGR access");
515  break;
516  case G_OPT_V_MAPS:
517  Opt->key = "map";
518  Opt->type = TYPE_STRING;
519  Opt->key_desc = "name";
520  Opt->required = YES;
521  Opt->multiple = YES;
522  Opt->gisprompt = "old,vector,vector";
523  Opt->description = _("Name of vector map(s)");
524  break;
525  case G_OPT_V_TYPE:
526  Opt->key = "type";
527  Opt->type = TYPE_STRING;
528  Opt->required = NO;
529  Opt->multiple = YES;
530  Opt->answer = "point,line,boundary,centroid,area";
531  Opt->options = "point,line,boundary,centroid,area";
532  Opt->description = _("Input feature type");
533  break;
534  case G_OPT_V3_TYPE:
535  Opt->key = "type";
536  Opt->type = TYPE_STRING;
537  Opt->required = NO;
538  Opt->multiple = YES;
539  Opt->answer = "point,line,boundary,centroid,area,face,kernel";
540  Opt->options = "point,line,boundary,centroid,area,face,kernel";
541  Opt->description = _("Input feature type");
542  break;
543  case G_OPT_V_FIELD:
544  Opt->key = "layer";
545  Opt->type = TYPE_STRING;
546  Opt->required = NO;
547  Opt->answer = "1";
548  Opt->label = _("Layer number or name");
549  Opt->description =
550  _("Vector features can have category values in different layers."
551  " This number determines which layer to use. "
552  "When used with direct OGR access this is the layer name.");
553  Opt->gisprompt = "old,layer,layer";
554  break;
555  case G_OPT_V_FIELD_ALL:
556  Opt->key = "layer";
557  Opt->type = TYPE_STRING;
558  Opt->required = NO;
559  Opt->answer = "-1";
560  Opt->label = _("Layer number or name ('-1' for all layers)");
561  Opt->description =
562  _("A single vector map can be connected to multiple database "
563  "tables. This number determines which table to use. "
564  "When used with direct OGR access this is the layer name.");
565  Opt->gisprompt = "old,layer_all,layer";
566  break;
567  case G_OPT_V_CAT:
568  Opt->key = "cat";
569  Opt->type = TYPE_INTEGER;
570  Opt->required = NO;
571  Opt->description = _("Category value");
572  Opt->gisprompt = "old,cat,cats";
573  break;
574  case G_OPT_V_CATS:
575  Opt->key = "cats";
576  Opt->type = TYPE_STRING;
577  Opt->key_desc = "range";
578  Opt->required = NO;
579  Opt->label = _("Category values");
580  Opt->description = _("Example: 1,3,7-9,13");
581  Opt->gisprompt = "old,cats,cats";
582  break;
583  case G_OPT_V_ID:
584  Opt->key = "id";
585  Opt->type = TYPE_INTEGER;
586  Opt->required = NO;
587  Opt->description = _("Feature id");
588  break;
589  case G_OPT_V_IDS:
590  Opt->key = "ids";
591  Opt->type = TYPE_STRING;
592  Opt->key_desc = "range";
593  Opt->required = NO;
594  Opt->label = _("Feature ids");
595  Opt->description = _("Example: 1,3,7-9,13");
596  break;
597 
598  /* files */
599  case G_OPT_F_INPUT:
600  Opt->key = "input";
601  Opt->type = TYPE_STRING;
602  Opt->key_desc = "name";
603  Opt->required = YES;
604  Opt->gisprompt = "old,file,file";
605  Opt->description = _("Name of input file");
606  break;
607  case G_OPT_F_BIN_INPUT:
608  Opt->key = "input";
609  Opt->type = TYPE_STRING;
610  Opt->key_desc = "name";
611  Opt->required = YES;
612  Opt->gisprompt = "old,bin,file";
613  Opt->description = _("Name of input file");
614  break;
615  case G_OPT_F_OUTPUT:
616  Opt->key = "output";
617  Opt->type = TYPE_STRING;
618  Opt->key_desc = "name";
619  Opt->required = YES;
620  Opt->gisprompt = "new,file,file";
621  Opt->description = _("Name for output file");
622  break;
623  case G_OPT_F_SEP:
624  Opt->key = "separator";
625  Opt->type = TYPE_STRING;
626  Opt->key_desc = "character";
627  Opt->required = NO;
628  Opt->gisprompt = "old,separator,separator";
629  Opt->answer = "pipe";
630  Opt->label = _("Field separator");
631  Opt->description =
632  _("Special characters: pipe, comma, space, tab, newline");
633  break;
634 
635  /* colors */
636  case G_OPT_C:
637  Opt->key = "color";
638  Opt->type = TYPE_STRING;
639  Opt->key_desc = "name";
640  Opt->required = NO;
641  Opt->answer = DEFAULT_FG_COLOR;
642  Opt->gisprompt = "old,color,color";
643  Opt->label = _("Color");
644  Opt->description = _("Either a standard color name or R:G:B triplet");
645  break;
646  case G_OPT_CN:
647  Opt->key = "color";
648  Opt->type = TYPE_STRING;
649  Opt->key_desc = "name";
650  Opt->required = NO;
651  Opt->answer = DEFAULT_FG_COLOR;
652  Opt->gisprompt = "old,color_none,color";
653  Opt->label = _("Color");
654  Opt->description =
655  _("Either a standard color name, R:G:B triplet, or \"none\"");
656  break;
657  case G_OPT_C_FORMAT:
658  Opt->key = "color_format";
659  Opt->type = TYPE_STRING;
660  Opt->key_desc = "name";
661  Opt->required = YES;
662  Opt->multiple = NO;
663  Opt->answer = "hex";
664  Opt->options = "rgb,hex,hsv,triplet";
665  Opt->label = _("Color format");
666  Opt->description = _("Color format for output values.");
667  G_asprintf(
668  (char **)&(Opt->descriptions), "rgb;%s;hex;%s;hsv;%s;triplet;%s",
669  _("output color in RGB format"), _("output color in HEX format"),
670  _("output color in HSV format (experimental)"),
671  _("output color in colon-separated RGB format"));
672  break;
673 
674  /* misc */
675 
676  case G_OPT_M_DIR:
677  Opt->key = "input";
678  Opt->type = TYPE_STRING;
679  Opt->key_desc = "name";
680  Opt->required = YES;
681  Opt->gisprompt = "old,dir,dir";
682  Opt->description = _("Name of input directory");
683  break;
684 
685  case G_OPT_M_UNITS:
686  Opt->key = "units";
687  Opt->type = TYPE_STRING;
688  Opt->required = NO;
689  Opt->multiple = NO;
690  Opt->options = "miles,feet,meters,kilometers,acres,hectares";
691  Opt->description = _("Units");
692  break;
693 
694  case G_OPT_M_DATATYPE:
695  Opt->key = "type";
696  Opt->key_desc = "datatype";
697  Opt->type = TYPE_STRING;
698  Opt->required = YES;
699  Opt->multiple = YES;
700  Opt->description = _("Data type(s)");
701  break;
702 
703  case G_OPT_M_MAPSET:
704  Opt->key = "mapset";
705  Opt->type = TYPE_STRING;
706  Opt->required = NO;
707  Opt->multiple = NO;
708  Opt->key_desc = "name";
709  Opt->gisprompt = "old,mapset,mapset";
710  Opt->label = _("Name of mapset (default: current search path)");
711  Opt->description = _("'.' for current mapset");
712  break;
713 
714  case G_OPT_M_LOCATION:
715  Opt->key = "project";
716  Opt->type = TYPE_STRING;
717  Opt->required = NO;
718  Opt->multiple = NO;
719  Opt->label = _("Project (location) name");
720  Opt->description = _("Project name (not path to project)");
721  Opt->gisprompt = "old,location,location";
722  Opt->key_desc = "name";
723  break;
724 
725  case G_OPT_M_DBASE:
726  Opt->key = "dbase";
727  Opt->type = TYPE_STRING;
728  Opt->required = NO;
729  Opt->multiple = NO;
730  Opt->label = _("GRASS GIS database directory");
731  Opt->description = _("Default: path to the current GRASS GIS database");
732  Opt->gisprompt = "old,dbase,dbase";
733  Opt->key_desc = "path";
734  break;
735 
736  case G_OPT_M_COORDS:
737  Opt->key = "coordinates";
738  Opt->type = TYPE_DOUBLE;
739  Opt->required = NO;
740  Opt->multiple = NO;
741  Opt->key_desc = "east,north";
742  Opt->gisprompt = "old,coords,coords";
743  Opt->description = _("Coordinates");
744  break;
745 
746  case G_OPT_M_COLR:
747  Opt->key = "color";
748  Opt->key_desc = "style";
749  Opt->type = TYPE_STRING;
750  Opt->required = NO;
752  Opt->description = _("Name of color table");
754  Opt->gisprompt = "old,colortable,colortable";
755  break;
756 
757  case G_OPT_M_NULL_VALUE:
758  Opt->key = "null_value";
759  Opt->key_desc = "string";
760  Opt->type = TYPE_STRING;
761  Opt->required = NO;
762  Opt->multiple = NO;
763  Opt->description = _("String representing NULL value");
764  break;
765 
766  case G_OPT_M_REGION:
767  Opt->key = "region";
768  Opt->type = TYPE_STRING;
769  Opt->key_desc = "name";
770  Opt->required = NO;
771  Opt->gisprompt = "old,windows,region";
772  Opt->description = _("Name of saved region");
773  break;
774 
775  case G_OPT_M_NPROCS:
776  Opt->key = "nprocs";
777  Opt->type = TYPE_INTEGER;
778  Opt->required = NO;
779  Opt->multiple = NO;
780  Opt->answer = "1";
781  /* start dynamic answer */
782  /* check NPROCS in GISRC, set with g.gisenv */
783  memstr = G_store(G_getenv_nofatal("NPROCS"));
784  if (memstr && *memstr)
785  Opt->answer = memstr;
786  /* end dynamic answer */
787  Opt->description = _("Number of threads for parallel computing");
788  break;
789 
790  case G_OPT_M_SEED:
791  Opt->key = "seed";
792  Opt->type = TYPE_INTEGER;
793  Opt->required = NO;
794  Opt->label = _("Seed value for the random number generator");
795  Opt->description =
796  _("Using the same seed ensures identical results, "
797  "while a randomly generated seed produces different outcomes "
798  "in each run.");
799  break;
800 
801  /* Spatio-temporal modules of the temporal GIS framework */
802  case G_OPT_STDS_INPUT:
803  Opt->key = "input";
804  Opt->type = TYPE_STRING;
805  Opt->key_desc = "name";
806  Opt->required = YES;
807  Opt->gisprompt = "old,stds,stds";
808  Opt->description = _("Name of the input space time dataset");
809  break;
810  case G_OPT_STDS_INPUTS:
811  Opt->key = "inputs";
812  Opt->type = TYPE_STRING;
813  Opt->key_desc = "name";
814  Opt->required = YES;
815  Opt->multiple = YES;
816  Opt->gisprompt = "old,stds,stds";
817  Opt->description = _("Name of the input space time datasets");
818  break;
819  case G_OPT_STDS_OUTPUT:
820  Opt->key = "output";
821  Opt->type = TYPE_STRING;
822  Opt->key_desc = "name";
823  Opt->required = YES;
824  Opt->gisprompt = "new,stds,stds";
825  Opt->description = _("Name of the output space time dataset");
826  break;
827  case G_OPT_STRDS_INPUT:
828  Opt->key = "input";
829  Opt->type = TYPE_STRING;
830  Opt->key_desc = "name";
831  Opt->required = YES;
832  Opt->gisprompt = "old,strds,strds";
833  Opt->description = _("Name of the input space time raster dataset");
834  break;
835  case G_OPT_STRDS_INPUTS:
836  Opt->key = "inputs";
837  Opt->type = TYPE_STRING;
838  Opt->key_desc = "name";
839  Opt->required = YES;
840  Opt->multiple = YES;
841  Opt->gisprompt = "old,strds,strds";
842  Opt->description = _("Name of the input space time raster datasets");
843  break;
844  case G_OPT_STRDS_OUTPUT:
845  Opt->key = "output";
846  Opt->type = TYPE_STRING;
847  Opt->key_desc = "name";
848  Opt->required = YES;
849  Opt->gisprompt = "new,strds,strds";
850  Opt->description = _("Name of the output space time raster dataset");
851  break;
852  case G_OPT_STRDS_OUTPUTS:
853  Opt->key = "outputs";
854  Opt->type = TYPE_STRING;
855  Opt->key_desc = "name";
856  Opt->required = YES;
857  Opt->multiple = YES;
858  Opt->gisprompt = "new,strds,strds";
859  Opt->description = _("Name of the output space time raster datasets");
860  break;
861  case G_OPT_STVDS_INPUT:
862  Opt->key = "input";
863  Opt->type = TYPE_STRING;
864  Opt->key_desc = "name";
865  Opt->required = YES;
866  Opt->gisprompt = "old,stvds,stvds";
867  Opt->description = _("Name of the input space time vector dataset");
868  break;
869  case G_OPT_STVDS_INPUTS:
870  Opt->key = "inputs";
871  Opt->type = TYPE_STRING;
872  Opt->key_desc = "name";
873  Opt->required = YES;
874  Opt->multiple = YES;
875  Opt->gisprompt = "old,stvds,stvds";
876  Opt->description = _("Name of the input space time vector datasets");
877  break;
878  case G_OPT_STVDS_OUTPUT:
879  Opt->key = "output";
880  Opt->type = TYPE_STRING;
881  Opt->key_desc = "name";
882  Opt->required = YES;
883  Opt->gisprompt = "new,stvds,stvds";
884  Opt->description = _("Name of the output space time vector dataset");
885  break;
886  case G_OPT_STR3DS_INPUT:
887  Opt->key = "input";
888  Opt->type = TYPE_STRING;
889  Opt->key_desc = "name";
890  Opt->required = YES;
891  Opt->gisprompt = "old,str3ds,str3ds";
892  Opt->description = _("Name of the input space time raster3d dataset");
893  break;
894  case G_OPT_STR3DS_INPUTS:
895  Opt->key = "inputs";
896  Opt->type = TYPE_STRING;
897  Opt->key_desc = "name";
898  Opt->required = YES;
899  Opt->multiple = YES;
900  Opt->gisprompt = "old,str3ds,str3ds";
901  Opt->description = _("Name of the input space time raster3d datasets");
902  break;
903  case G_OPT_STR3DS_OUTPUT:
904  Opt->key = "output";
905  Opt->type = TYPE_STRING;
906  Opt->key_desc = "name";
907  Opt->required = YES;
908  Opt->gisprompt = "new,str3ds,str3ds";
909  Opt->description = _("Name of the output space time raster3d dataset");
910  break;
911  case G_OPT_STDS_TYPE:
912  Opt->key = "type";
913  Opt->type = TYPE_STRING;
914  Opt->key_desc = "name";
915  Opt->required = NO;
916  Opt->answer = "strds";
917  Opt->options = "strds,stvds,str3ds";
918  Opt->description = _("Type of the input space time dataset");
919  break;
920  case G_OPT_MAP_INPUT:
921  Opt->key = "map";
922  Opt->type = TYPE_STRING;
923  Opt->key_desc = "name";
924  Opt->required = YES;
925  Opt->gisprompt = "old,map,map";
926  Opt->description = _("Name of the input map");
927  break;
928  case G_OPT_MAP_INPUTS:
929  Opt->key = "maps";
930  Opt->type = TYPE_STRING;
931  Opt->key_desc = "name";
932  Opt->required = YES;
933  Opt->multiple = YES;
934  Opt->gisprompt = "old,map,map";
935  Opt->description = _("Name of the input maps");
936  break;
937  case G_OPT_MAP_TYPE:
938  Opt->key = "type";
939  Opt->type = TYPE_STRING;
940  Opt->key_desc = "name";
941  Opt->required = NO;
942  Opt->answer = "raster";
943  Opt->options = "raster,vector,raster_3d";
944  Opt->description = _("Type of the input map");
945  break;
946  case G_OPT_T_TYPE:
947  Opt->key = "temporaltype";
948  Opt->type = TYPE_STRING;
949  Opt->key_desc = "name";
950  Opt->required = NO;
951  Opt->answer = "absolute";
952  Opt->options = "absolute,relative";
953  Opt->description = _("The temporal type of the space time dataset");
954  break;
955  case G_OPT_T_WHERE:
956  Opt->key = "where";
957  Opt->type = TYPE_STRING;
958  Opt->key_desc = "sql_query";
959  Opt->required = NO;
960  Opt->label = _("WHERE conditions of SQL statement without 'where' "
961  "keyword used in the temporal GIS framework");
962  Opt->description = _("Example: start_time > '2001-01-01 12:30:00'");
963  break;
964  case G_OPT_T_SAMPLE:
965  Opt->key = "sampling";
966  Opt->type = TYPE_STRING;
967  Opt->key_desc = "name";
968  Opt->required = NO;
969  Opt->multiple = YES;
970  Opt->answer = "start";
971  Opt->options = "start,during,overlap,contain,equal,follows,precedes";
972  Opt->description =
973  _("The method to be used for sampling the input dataset");
974  break;
975  case G_OPT_F_FORMAT:
976  Opt->key = "format";
977  Opt->type = TYPE_STRING;
978  Opt->key_desc = "name";
979  Opt->required = YES;
980  Opt->label = _("Output format");
981  Opt->answer = "plain";
982  Opt->options = "plain,json";
983  Opt->descriptions = _("plain;Plain text output;"
984  "json;JSON (JavaScript Object Notation);");
985  break;
986  }
987 
988  return Opt;
989 }
990 
991 /*!
992  \brief Create standardised Flag structure.
993 
994  This function will create a standardised Flag structure defined by
995  parameter <i>flag</i>. A list of valid parameters below. It
996  allocates memory for the Flag structure and returns a pointer to
997  this memory.
998 
999  If an invalid parameter was specified a empty Flag structure will be
1000  returned (not NULL).
1001 
1002  - G_FLG_V_TABLE (do not create attribute table)
1003  - G_FLG_V_TOPO (do not build topology)
1004 
1005  \param flag type of Flag struct to create specified by STD_FLG enum.
1006 
1007  \return pointer to an Flag struct
1008  */
1009 struct Flag *G_define_standard_flag(int flag)
1010 {
1011  struct Flag *Flg;
1012 
1013  Flg = G_define_flag();
1014 
1015  switch (flag) {
1016  case G_FLG_V_TABLE:
1017  Flg->key = 't';
1018  Flg->description = _("Do not create attribute table");
1019  break;
1020  case G_FLG_V_TOPO:
1021  Flg->key = 'b';
1022  Flg->label = _("Do not build topology");
1023  Flg->description =
1024  _("Advantageous when handling a large number of points");
1025  break;
1026  }
1027 
1028  return Flg;
1029 }
char * G_color_rules_options(void)
Get list of color rules for Option->options.
struct Option * G_define_option(void)
Initializes an Option struct.
Definition: parser.c:211
char * G_color_rules_description_type(void)
Get color rules description for Option->descriptions.
int G_asprintf(char **, const char *,...) __attribute__((format(printf
struct Flag * G_define_flag(void)
Initializes a Flag struct.
Definition: parser.c:157
const char * G_getenv_nofatal(const char *)
Get environment variable.
Definition: env.c:405
char * G_store(const char *)
Copy string to allocated memory.
Definition: strings.c:87
#define DEFAULT_FG_COLOR
Definition: gis.h:400
#define TYPE_STRING
Definition: gis.h:186
#define GV_KEY_COLUMN
Name of default key column.
Definition: gis.h:418
@ G_OPT_STRDS_INPUTS
Definition: gis.h:341
@ G_OPT_M_REGION
Definition: gis.h:331
@ G_OPT_F_BIN_INPUT
Definition: gis.h:315
@ G_OPT_V_IDS
Definition: gis.h:312
@ G_OPT_DB_COLUMNS
Definition: gis.h:265
@ G_OPT_M_DIR
Definition: gis.h:330
@ G_OPT_R_BASENAME_INPUT
Definition: gis.h:285
@ G_OPT_R3_INPUTS
Definition: gis.h:289
@ G_OPT_R_ELEV
Definition: gis.h:281
@ G_OPT_R_MAPS
Definition: gis.h:278
@ G_OPT_V_CAT
Definition: gis.h:309
@ G_OPT_F_SEP
Definition: gis.h:317
@ G_OPT_R_BASENAME_OUTPUT
Definition: gis.h:286
@ G_OPT_STR3DS_INPUT
Definition: gis.h:344
@ G_OPT_R_ELEVS
Definition: gis.h:282
@ G_OPT_R_INPUTS
Definition: gis.h:274
@ G_OPT_STVDS_OUTPUT
Definition: gis.h:349
@ G_OPT_STRDS_OUTPUTS
Definition: gis.h:343
@ G_OPT_T_WHERE
Definition: gis.h:356
@ G_OPT_V_MAP
Definition: gis.h:303
@ G_OPT_DB_WHERE
Definition: gis.h:259
@ G_OPT_T_TYPE
Definition: gis.h:355
@ G_OPT_M_SEED
Definition: gis.h:334
@ G_OPT_V_CATS
Definition: gis.h:310
@ G_OPT_F_FORMAT
Definition: gis.h:359
@ G_OPT_R_COVER
Definition: gis.h:280
@ G_OPT_M_NULL_VALUE
Definition: gis.h:332
@ G_OPT_DB_KEYCOLUMN
Definition: gis.h:266
@ G_OPT_DB_COLUMN
Definition: gis.h:264
@ G_OPT_DB_SQL
Definition: gis.h:258
@ G_OPT_F_INPUT
Definition: gis.h:314
@ G_OPT_STRDS_OUTPUT
Definition: gis.h:342
@ G_OPT_V_INPUTS
Definition: gis.h:301
@ G_OPT_V_FIELD_ALL
Definition: gis.h:308
@ G_OPT_T_SAMPLE
Definition: gis.h:357
@ G_OPT_V3_TYPE
Definition: gis.h:306
@ G_OPT_MAP_INPUT
Definition: gis.h:350
@ G_OPT_R3_TYPE
Definition: gis.h:293
@ G_OPT_V_MAPS
Definition: gis.h:304
@ G_OPT_STVDS_INPUT
Definition: gis.h:347
@ G_OPT_STRDS_INPUT
Definition: gis.h:340
@ G_OPT_M_NPROCS
Definition: gis.h:333
@ G_OPT_STDS_TYPE
Definition: gis.h:352
@ G_OPT_STR3DS_INPUTS
Definition: gis.h:345
@ G_OPT_R_MAP
Definition: gis.h:277
@ G_OPT_C_FORMAT
Definition: gis.h:321
@ G_OPT_M_LOCATION
Definition: gis.h:326
@ G_OPT_M_COLR
Definition: gis.h:329
@ G_OPT_MAP_INPUTS
Definition: gis.h:351
@ G_OPT_V_ID
Definition: gis.h:311
@ G_OPT_M_DBASE
Definition: gis.h:327
@ G_OPT_M_COORDS
Definition: gis.h:328
@ G_OPT_M_MAPSET
Definition: gis.h:325
@ G_OPT_R_BASE
Definition: gis.h:279
@ G_OPT_STVDS_INPUTS
Definition: gis.h:348
@ G_OPT_R3_PRECISION
Definition: gis.h:294
@ G_OPT_R3_MAP
Definition: gis.h:291
@ G_OPT_STDS_INPUT
Definition: gis.h:336
@ G_OPT_C
Definition: gis.h:319
@ G_OPT_R3_OUTPUT
Definition: gis.h:290
@ G_OPT_R3_MAPS
Definition: gis.h:292
@ G_OPT_DB_TABLE
Definition: gis.h:260
@ G_OPT_STDS_INPUTS
Definition: gis.h:338
@ G_OPT_R3_INPUT
Definition: gis.h:288
@ G_OPT_STDS_OUTPUT
Definition: gis.h:339
@ G_OPT_R_TYPE
Definition: gis.h:283
@ G_OPT_V_FIELD
Definition: gis.h:307
@ G_OPT_V_TYPE
Definition: gis.h:305
@ G_OPT_MEMORYMB
Definition: gis.h:271
@ G_OPT_DB_DATABASE
Definition: gis.h:262
@ G_OPT_CN
Definition: gis.h:320
@ G_OPT_R_OUTPUTS
Definition: gis.h:276
@ G_OPT_R_INTERP_TYPE
Definition: gis.h:284
@ G_OPT_MAP_TYPE
Definition: gis.h:354
@ G_OPT_R_INPUT
Definition: gis.h:273
@ G_OPT_R3_TILE_DIMENSION
Definition: gis.h:295
@ G_OPT_F_OUTPUT
Definition: gis.h:316
@ G_OPT_DB_SCHEMA
Definition: gis.h:263
@ G_OPT_M_UNITS
Definition: gis.h:323
@ G_OPT_DB_DRIVER
Definition: gis.h:261
@ G_OPT_I_SUBGROUP
Definition: gis.h:269
@ G_OPT_V_OUTPUT
Definition: gis.h:302
@ G_OPT_R_OUTPUT
Definition: gis.h:275
@ G_OPT_V_INPUT
Definition: gis.h:300
@ G_OPT_M_DATATYPE
Definition: gis.h:324
@ G_OPT_I_GROUP
Definition: gis.h:268
@ G_OPT_STR3DS_OUTPUT
Definition: gis.h:346
@ G_OPT_R3_COMPRESSION
Definition: gis.h:297
#define YES
Definition: gis.h:187
#define TYPE_INTEGER
Definition: gis.h:184
#define NO
Definition: gis.h:188
#define TYPE_DOUBLE
Definition: gis.h:185
@ G_FLG_V_TOPO
Definition: gis.h:374
@ G_FLG_V_TABLE
Definition: gis.h:373
#define _(str)
Definition: glocale.h:10
struct Option * G_define_standard_option(int opt)
Create standardised Option structure.
struct Flag * G_define_standard_flag(int flag)
Create standardised Flag structure.
Structure that stores flag info.
Definition: gis.h:589
const char * description
Definition: gis.h:595
char key
Definition: gis.h:590
const char * label
Definition: gis.h:594
Structure that stores option information.
Definition: gis.h:558
const char * key
Definition: gis.h:559
const char * key_desc
Definition: gis.h:565
const char * gisprompt
Definition: gis.h:576
const char * label
Definition: gis.h:566
int type
Definition: gis.h:560
const char * descriptions
Definition: gis.h:568
const char * description
Definition: gis.h:567
char * answer
Definition: gis.h:572
int required
Definition: gis.h:561
const char * options
Definition: gis.h:563
int multiple
Definition: gis.h:562