parser_standard_options.c 27 KB

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