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