parser_wps.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. #include "parser_local_proto.h"
  2. /* Defines and prototypes for WPS process_description XML document generation
  3. */
  4. #define TYPE_OTHER -1
  5. #define TYPE_RASTER 0
  6. #define TYPE_VECTOR 1
  7. #define TYPE_PLAIN_TEXT 2
  8. #define TYPE_RANGE 3
  9. #define TYPE_LIST 4
  10. #define WPS_INPUT 0
  11. #define WPS_OUTPUT 1
  12. static void wps_print_process_descriptions_begin(void);
  13. static void wps_print_process_descriptions_end(void);
  14. static void wps_print_process_description_begin(int , int , const char *, const char *, const char *, const char **, int );
  15. static void wps_print_process_description_end(void);
  16. static void wps_print_data_inputs_begin(void);
  17. static void wps_print_data_inputs_end(void);
  18. static void wps_print_process_outputs_begin(void);
  19. static void wps_print_process_outputs_end(void);
  20. static void wps_print_bounding_box_data(void);
  21. static void wps_print_mimetype_text_plain(void);
  22. static void wps_print_mimetype_raster_tiff(void);
  23. static void wps_print_mimetype_raster_png(void);
  24. static void wps_print_mimetype_raster_grass_binary(void);
  25. static void wps_print_mimetype_raster_grass_ascii(void);
  26. static void wps_print_mimetype_vector_gml310(void);
  27. static void wps_print_mimetype_vector_grass_ascii(void);
  28. static void wps_print_mimetype_vector_grass_binary(void);
  29. static void wps_print_ident_title_abstract(const char *, const char *, const char *);
  30. static void wps_print_complex_input(int , int , const char *, const char *, const char *, int , int );
  31. static void wps_print_complex_output(const char *, const char *, const char *, int );
  32. static void wps_print_comlpex_input_output(int , int , int , const char *, const char *, const char *, int , int );
  33. static void wps_print_literal_input_output(int , int , int , const char *,
  34. const char *, const char *, const char *, int ,
  35. const char **, int , const char *, int );
  36. static void print_escaped_for_xml(FILE * fp, const char *str)
  37. {
  38. for (; *str; str++) {
  39. switch (*str) {
  40. case '&':
  41. fputs("&", fp);
  42. break;
  43. case '<':
  44. fputs("&lt;", fp);
  45. break;
  46. case '>':
  47. fputs("&gt;", fp);
  48. break;
  49. default:
  50. fputc(*str, fp);
  51. }
  52. }
  53. }
  54. /*!
  55. * \brief Print the WPS 1.0.0 process description XML document to stdout
  56. *
  57. * A module started with the parameter "--wps-process-description"
  58. * will write a process description XML document to stdout and exit.
  59. *
  60. * Currently only raster and vector modules are supported, but the
  61. * generation works with any module (more or less meaningful).
  62. * Most of the input options are catched:
  63. * * single and multiple raster and vector maps
  64. * * single and multiple string, float and integer data with default
  65. * values and value options (range is missing)
  66. * Flags are supported as boolean values.
  67. *
  68. * The mime types for vector maps are GML 3.1 and grass ascii and binary vectors.
  69. * mime type: application/grass-vector-ascii -> a text file generated with v.out.asci
  70. * Example.: urn:file:///path/name
  71. * mime type: application/grass-vector-binary -> the binary vectors must be addressed with a non standard urn:
  72. * Example: urn:grass:vector:location/mapset/name
  73. *
  74. * The mime types for raster maps are tiff and png as well as grass ascii
  75. * and binary raster maps, following the same scheme as the vector maps
  76. *
  77. * The mime types are reflecting the capabilities of gdal and may be extended.
  78. *
  79. * BoundignBox support is currently not available for inputs and outputs.
  80. * Literal data output (string, float or integer) is currently not supported.
  81. *
  82. * In case no output parameter was set (new raster of vector map) the stdout output
  83. * is noticed as output parameter of mime type text/plain.
  84. *
  85. * Multiple vector or raster map outputs marked as one option are not supported (wps 1.0.0 specification
  86. * does not allow multiple outputs with only one identifier).
  87. * Multiple outputs must be wrapped via a python script.
  88. *
  89. * There is not support for optional outputs.
  90. *
  91. * */
  92. void G__wps_print_process_description(void)
  93. {
  94. struct Option *opt;
  95. struct Flag *flag;
  96. char *type;
  97. char *s, *top;
  98. const char *value = NULL;
  99. int i;
  100. char *encoding;
  101. int new_prompt = 0;
  102. int store = 1;
  103. int status = 1;
  104. const char *identifier = NULL;
  105. const char *title = NULL;
  106. const char *abstract = NULL;
  107. const char **keywords = NULL;
  108. int data_type, is_input, is_output;
  109. int min = 0, max = 0;
  110. int num_keywords = 0;
  111. int found_output = 0;
  112. new_prompt = G__uses_new_gisprompt();
  113. /* gettext converts strings to encoding returned by nl_langinfo(CODESET) */
  114. #if defined(HAVE_LANGINFO_H)
  115. encoding = nl_langinfo(CODESET);
  116. if (!encoding || strlen(encoding) == 0) {
  117. encoding = "UTF-8";
  118. }
  119. #elif defined(__MINGW32__) && defined(USE_NLS)
  120. encoding = locale_charset();
  121. if (!encoding || strlen(encoding) == 0) {
  122. encoding = "UTF-8";
  123. }
  124. #else
  125. encoding = "UTF-8";
  126. #endif
  127. if (!st->pgm_name)
  128. st->pgm_name = G_program_name();
  129. if (!st->pgm_name)
  130. st->pgm_name = "??";
  131. /* the identifier of the process is the module name */
  132. identifier = st->pgm_name;
  133. if (st->module_info.description) {
  134. title = st->module_info.description;
  135. abstract = st->module_info.description;
  136. }
  137. if (st->module_info.keywords) {
  138. keywords = st->module_info.keywords;
  139. num_keywords = st->n_keys;
  140. }
  141. wps_print_process_descriptions_begin();
  142. /* store and status are supported as default. The WPS server should change this if nessessary */
  143. wps_print_process_description_begin(store, status, identifier, title, abstract, keywords, num_keywords);
  144. wps_print_data_inputs_begin();
  145. /* We have two default options, which define the resolution of the created mapset */
  146. wps_print_literal_input_output(WPS_INPUT, 0, 1, "resolution_ns", "Resolution of the mapset in north-south direction in [m] or [°]",
  147. "This parameter defines the north-south resolution of the mapset in meter or degrees, which should be used ot process the input and output raster data. To enable this setting, you need to specify north-south and east-west resolution.",
  148. "float", 0, NULL, 0, "25", TYPE_OTHER);
  149. wps_print_literal_input_output(WPS_INPUT, 0, 1, "resolution_ew", "Resolution of the mapset in east-west direction in [m] or [°]",
  150. "This parameter defines the east-west resolution of the mapset in meters or degrees, which should be used ot process the input and output raster data. To enable this setting, you need to specify north-south and east-west resolution.",
  151. "float", 0, NULL, 0, "25", TYPE_OTHER);
  152. /* Print the bounding box element with all the coordinate reference systems, which are supported by grass*/
  153. /* Currently Disabled! A list of all proj4 supported EPSG coordinate reference systems must be implemented*/
  154. if(1 == 0)
  155. wps_print_bounding_box_data();
  156. /* We parse only the inputs at the beginning */
  157. if (st->n_opts) {
  158. opt = &st->first_option;
  159. while (opt != NULL) {
  160. identifier = NULL;
  161. title = NULL;
  162. abstract = NULL;
  163. keywords = NULL;
  164. num_keywords = 0;
  165. value = NULL;
  166. is_input = 1;
  167. data_type = TYPE_OTHER;
  168. if (opt->gisprompt) {
  169. const char *atts[] = { "age", "element", "prompt", NULL };
  170. top = G_calloc(strlen(opt->gisprompt) + 1, 1);
  171. strcpy(top, opt->gisprompt);
  172. s = strtok(top, ",");
  173. for (i = 0; s != NULL && atts[i] != NULL; i++) {
  174. char *token = G_store(s);
  175. /* we print only input parameter, sort out the output parameter */
  176. if(strcmp(token, "new") == 0)
  177. is_input = 0;
  178. if(strcmp(token, "raster") == 0)
  179. {
  180. data_type = TYPE_RASTER;
  181. }
  182. if(strcmp(token, "vector") == 0)
  183. {
  184. data_type = TYPE_VECTOR;
  185. }
  186. if(strcmp(token, "file") == 0)
  187. {
  188. data_type = TYPE_PLAIN_TEXT;
  189. }
  190. s = strtok(NULL, ",");
  191. G_free(token);
  192. }
  193. G_free(top);
  194. }
  195. /* We have an input option */
  196. if(is_input == 1)
  197. {
  198. switch (opt->type) {
  199. case TYPE_INTEGER:
  200. type = "integer";
  201. break;
  202. case TYPE_DOUBLE:
  203. type = "float";
  204. break;
  205. case TYPE_STRING:
  206. type = "string";
  207. break;
  208. default:
  209. type = "string";
  210. break;
  211. }
  212. identifier = opt->key;
  213. if(opt->required == YES)
  214. min = 1;
  215. else
  216. min = 0;
  217. if(opt->multiple == YES)
  218. max = 1024;
  219. else
  220. max = 1;
  221. if (opt->description) {
  222. title = opt->description;
  223. abstract = opt->description;
  224. }
  225. if (opt->def) {
  226. value = opt->def;
  227. }
  228. if (opt->options) {
  229. /* TODO:
  230. * add something like
  231. * <range min="xxx" max="xxx"/>
  232. * to <values> */
  233. i = 0;
  234. while (opt->opts[i]) {
  235. i++;
  236. }
  237. keywords = opt->opts;
  238. num_keywords = i;
  239. }
  240. if(data_type == TYPE_RASTER || data_type == TYPE_VECTOR || data_type == TYPE_PLAIN_TEXT)
  241. {
  242. /* 2048 is the maximum size of the map in mega bytes */
  243. wps_print_complex_input(min, max, identifier, title, NULL, 2048, data_type);
  244. }
  245. else
  246. {
  247. /* The keyword array is missused for options, type means the type of the value (integer, float ... )*/
  248. wps_print_literal_input_output(WPS_INPUT, min, max, identifier, title, NULL, type, 0, keywords, num_keywords, value, TYPE_OTHER);
  249. }
  250. }
  251. opt = opt->next_opt;
  252. }
  253. }
  254. /* Flags are always input options and can be false or true (boolean) */
  255. if (st->n_flags) {
  256. flag = &st->first_flag;
  257. while (flag != NULL) {
  258. /* The identifier is the flag "-x" */
  259. char* ident = (char*)G_calloc(3, sizeof(char));
  260. ident[0] = '-';
  261. ident[1] = flag->key;
  262. ident[2] = '\0';
  263. title = NULL;
  264. abstract = NULL;
  265. if (flag->description) {
  266. title = flag->description;
  267. abstract = flag->description;
  268. }
  269. const char *val[] = {"true","false"};
  270. wps_print_literal_input_output(WPS_INPUT, 0, 1, ident, title, NULL, "boolean", 0, val, 2, "false", TYPE_OTHER);
  271. flag = flag->next_flag;
  272. }
  273. }
  274. /* End of inputs */
  275. wps_print_data_inputs_end();
  276. /* Start of the outputs */
  277. wps_print_process_outputs_begin();
  278. found_output = 0;
  279. /*parse the ouput. only raster and vector map and stdout are supported */
  280. if (st->n_opts) {
  281. opt = &st->first_option;
  282. while (opt != NULL) {
  283. identifier = NULL;
  284. title = NULL;
  285. abstract = NULL;
  286. value = NULL;
  287. is_output = 0;
  288. data_type = TYPE_OTHER;
  289. if (opt->gisprompt) {
  290. const char *atts[] = { "age", "element", "prompt", NULL };
  291. top = G_calloc(strlen(opt->gisprompt) + 1, 1);
  292. strcpy(top, opt->gisprompt);
  293. s = strtok(top, ",");
  294. for (i = 0; s != NULL && atts[i] != NULL; i++) {
  295. char *token = G_store(s);
  296. /* we print only the output parameter */
  297. if(strcmp(token, "new") == 0)
  298. is_output = 1;
  299. if(strcmp(token, "raster") == 0)
  300. {
  301. data_type = TYPE_RASTER;
  302. }
  303. if(strcmp(token, "vector") == 0)
  304. {
  305. data_type = TYPE_VECTOR;
  306. }
  307. if(strcmp(token, "file") == 0)
  308. {
  309. data_type = TYPE_PLAIN_TEXT;
  310. }
  311. s = strtok(NULL, ",");
  312. G_free(token);
  313. }
  314. G_free(top);
  315. }
  316. /* Only single module output is supported */
  317. if(is_output == 1 && opt->multiple == NO)
  318. {
  319. identifier = opt->key;
  320. if (opt->description) {
  321. title = opt->description;
  322. abstract = opt->description;
  323. }
  324. /* Only file, raster and vector output is supported by option */
  325. if(data_type == TYPE_RASTER || data_type == TYPE_VECTOR || data_type == TYPE_PLAIN_TEXT)
  326. {
  327. wps_print_complex_output(identifier, title, NULL, data_type);
  328. found_output = 1;
  329. }
  330. }
  331. opt = opt->next_opt;
  332. }
  333. /* we assume the computatuon output on stdout, if no raster/vector output was found*/
  334. if(found_output == 0)
  335. wps_print_complex_output("stdout", "Module output on stdout", "The output of the module written to stdout", TYPE_PLAIN_TEXT);
  336. }
  337. wps_print_process_outputs_end();
  338. wps_print_process_description_end();
  339. wps_print_process_descriptions_end();
  340. }
  341. /**************************************************************************
  342. *
  343. * The remaining routines are all local (static) routines used to support
  344. * the the creation of the WPS process_description document.
  345. *
  346. **************************************************************************/
  347. static void wps_print_process_descriptions_begin(void)
  348. {
  349. fprintf(stdout, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
  350. fprintf(stdout, "<wps:ProcessDescriptions xmlns:wps=\"http://www.opengis.net/wps/1.0.0\"\n");
  351. fprintf(stdout, "xmlns:ows=\"http://www.opengis.net/ows/1.1\"\n");
  352. fprintf(stdout, "xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n");
  353. fprintf(stdout, "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
  354. fprintf(stdout, "xsi:schemaLocation=\"http://www.opengis.net/wps/1.0.0\n http://schemas.opengis.net/wps/1.0.0/wpsDescribeProcess_response.xsd\"\n service=\"WPS\" version=\"1.0.0\" xml:lang=\"en-US\"> \n");
  355. }
  356. /* ************************************************************************** */
  357. static void wps_print_process_descriptions_end(void)
  358. {
  359. fprintf(stdout,"</wps:ProcessDescriptions>\n");
  360. }
  361. /* ************************************************************************** */
  362. static void wps_print_process_description_begin(int store, int status, const char *identifier,
  363. const char *title, const char *abstract,
  364. const char **keywords, int num_keywords)
  365. {
  366. int i;
  367. fprintf(stdout,"\t<ProcessDescription wps:processVersion=\"1\" storeSupported=\"%s\" statusSupported=\"%s\">\n", (store?"true":"false"), (status?"true":"false"));
  368. if(identifier)
  369. {
  370. fprintf(stdout,"\t\t<ows:Identifier>");
  371. print_escaped_for_xml(stdout, identifier);
  372. fprintf(stdout,"</ows:Identifier>\n");
  373. }
  374. if(title)
  375. {
  376. fprintf(stdout,"\t\t<ows:Title>");
  377. print_escaped_for_xml(stdout, title);
  378. fprintf(stdout, "</ows:Title>\n");
  379. }
  380. if(abstract)
  381. {
  382. fprintf(stdout,"\t\t<ows:Abstract>\n");
  383. fprintf(stdout, "\t\t\tThe manual page of this module is available here:\n");
  384. fprintf(stdout, "\t\t\thttp://grass.osgeo.org/grass70/manuals/html70_user/%s.html\n", identifier);
  385. fprintf(stdout, "\t\t</ows:Abstract>\n");
  386. }
  387. for(i = 0; i < num_keywords; i++)
  388. {
  389. fprintf(stdout,"\t\t<ows:Metadata xlink:title=\"");
  390. print_escaped_for_xml(stdout, keywords[i]);
  391. fprintf(stdout, "\" />\n");
  392. }
  393. }
  394. /* ************************************************************************** */
  395. static void wps_print_process_description_end(void)
  396. {
  397. fprintf(stdout,"\t</ProcessDescription>\n");
  398. }
  399. /* ************************************************************************** */
  400. static void wps_print_data_inputs_begin(void)
  401. {
  402. fprintf(stdout,"\t\t<DataInputs>\n");
  403. }
  404. /* ************************************************************************** */
  405. static void wps_print_data_inputs_end(void)
  406. {
  407. fprintf(stdout,"\t\t</DataInputs>\n");
  408. }
  409. /* ************************************************************************** */
  410. static void wps_print_process_outputs_begin(void)
  411. {
  412. fprintf(stdout,"\t\t<ProcessOutputs>\n");
  413. }
  414. /* ************************************************************************** */
  415. static void wps_print_process_outputs_end(void)
  416. {
  417. fprintf(stdout,"\t\t</ProcessOutputs>\n");
  418. }
  419. /* ************************************************************************** */
  420. static void wps_print_complex_input(int min, int max, const char *identifier, const char *title, const char *abstract, int megs, int type)
  421. {
  422. wps_print_comlpex_input_output(WPS_INPUT, min, max, identifier, title, abstract, megs, type);
  423. }
  424. /* ************************************************************************** */
  425. static void wps_print_complex_output(const char *identifier, const char *title, const char *abstract, int type)
  426. {
  427. wps_print_comlpex_input_output(WPS_OUTPUT, 0, 0, identifier, title, abstract, 0, type);
  428. }
  429. /* ************************************************************************** */
  430. static void wps_print_comlpex_input_output(int inout_type, int min, int max, const char *identifier, const char *title, const char *abstract, int megs, int type)
  431. {
  432. if(inout_type == WPS_INPUT)
  433. fprintf(stdout,"\t\t\t<Input minOccurs=\"%i\" maxOccurs=\"%i\">\n", min, max);
  434. else if(inout_type == WPS_OUTPUT)
  435. fprintf(stdout,"\t\t\t<Output>\n");
  436. wps_print_ident_title_abstract(identifier, title, abstract);
  437. if(inout_type == WPS_INPUT)
  438. fprintf(stdout,"\t\t\t\t<ComplexData maximumMegabytes=\"%i\">\n", megs);
  439. else if(inout_type == WPS_OUTPUT)
  440. fprintf(stdout,"\t\t\t\t<ComplexOutput>\n");
  441. fprintf(stdout,"\t\t\t\t\t<Default>\n");
  442. if(type == TYPE_RASTER)
  443. {
  444. wps_print_mimetype_raster_tiff();
  445. }
  446. else if(type == TYPE_VECTOR)
  447. {
  448. wps_print_mimetype_vector_gml310();
  449. }
  450. else if(type == TYPE_PLAIN_TEXT)
  451. {
  452. wps_print_mimetype_text_plain();
  453. }
  454. fprintf(stdout,"\t\t\t\t\t</Default>\n");
  455. fprintf(stdout,"\t\t\t\t\t<Supported>\n");
  456. if(type == TYPE_RASTER)
  457. {
  458. wps_print_mimetype_raster_tiff();
  459. /* These mime types are currently not meaningful */
  460. if(1 == 0) {
  461. wps_print_mimetype_raster_png();
  462. wps_print_mimetype_raster_grass_ascii();
  463. wps_print_mimetype_raster_grass_binary();
  464. }
  465. }
  466. else if(type == TYPE_VECTOR)
  467. {
  468. wps_print_mimetype_vector_gml310();
  469. /* These mime types are currently not meaningful */
  470. if(1 == 0) {
  471. wps_print_mimetype_vector_grass_ascii();
  472. wps_print_mimetype_vector_grass_binary();
  473. }
  474. }
  475. else if(type == TYPE_PLAIN_TEXT)
  476. {
  477. wps_print_mimetype_text_plain();
  478. }
  479. fprintf(stdout,"\t\t\t\t\t</Supported>\n");
  480. if(inout_type == WPS_INPUT)
  481. fprintf(stdout,"\t\t\t\t</ComplexData>\n");
  482. else if(inout_type == WPS_OUTPUT)
  483. fprintf(stdout,"\t\t\t\t</ComplexOutput>\n");
  484. if(inout_type == WPS_INPUT)
  485. fprintf(stdout,"\t\t\t</Input>\n");
  486. else if(inout_type == WPS_OUTPUT)
  487. fprintf(stdout,"\t\t\t</Output>\n");
  488. }
  489. /* ************************************************************************** */
  490. static void wps_print_ident_title_abstract(const char *identifier, const char *title, const char *abstract)
  491. {
  492. if(identifier)
  493. {
  494. fprintf(stdout,"\t\t\t\t<ows:Identifier>");
  495. print_escaped_for_xml(stdout, identifier);
  496. fprintf(stdout,"</ows:Identifier>\n");
  497. }
  498. if(title)
  499. {
  500. fprintf(stdout,"\t\t\t\t<ows:Title>");
  501. print_escaped_for_xml(stdout, title);
  502. fprintf(stdout, "</ows:Title>\n");
  503. }
  504. if(abstract)
  505. {
  506. fprintf(stdout,"\t\t\t\t<ows:Abstract>");
  507. print_escaped_for_xml(stdout, abstract);
  508. fprintf(stdout, "</ows:Abstract>\n");
  509. }
  510. }
  511. /* ************************************************************************** */
  512. static void wps_print_literal_input_output(int inout_type, int min, int max, const char *identifier,
  513. const char *title, const char *abstract, const char *datatype, int unitofmesure,
  514. const char **choices, int num_choices, const char *default_value, int type)
  515. {
  516. int i;
  517. if(inout_type == WPS_INPUT)
  518. fprintf(stdout,"\t\t\t<Input minOccurs=\"%i\" maxOccurs=\"%i\">\n", min, max);
  519. else if(inout_type == WPS_OUTPUT)
  520. fprintf(stdout,"\t\t\t<Output>\n");
  521. wps_print_ident_title_abstract(identifier, title, abstract);
  522. fprintf(stdout,"\t\t\t\t<LiteralData>\n");
  523. if(datatype)
  524. fprintf(stdout,"\t\t\t\t\t<ows:DataType ows:reference=\"xs:%s\">%s</ows:DataType>\n", datatype, datatype);
  525. if(unitofmesure)
  526. {
  527. fprintf(stdout,"\t\t\t\t\t<UOMs>\n");
  528. fprintf(stdout,"\t\t\t\t\t<Default>\n");
  529. fprintf(stdout,"\t\t\t\t\t\t<ows:UOM>meters</ows:UOM>\n");
  530. fprintf(stdout,"\t\t\t\t\t</Default>\n");
  531. fprintf(stdout,"\t\t\t\t\t<Supported>\n");
  532. fprintf(stdout,"\t\t\t\t\t\t<ows:UOM>meters</ows:UOM>\n");
  533. fprintf(stdout,"\t\t\t\t\t</Supported>\n");
  534. fprintf(stdout,"\t\t\t\t\t</UOMs>\n");
  535. }
  536. if(num_choices == 0 || choices == NULL)
  537. fprintf(stdout,"\t\t\t\t\t<ows:AnyValue/>\n");
  538. else
  539. {
  540. fprintf(stdout,"\t\t\t\t\t<ows:AllowedValues>\n");
  541. if(type == TYPE_RANGE && num_choices > 1)
  542. {
  543. fprintf(stdout,"\t\t\t\t\t\t<ows:Range ows:rangeClosure=\"%s\">\n", "0");
  544. fprintf(stdout,"\t\t\t\t\t\t\t<ows:MinimumValue>%s</ows:MinimumValue>\n", choices[0]);
  545. fprintf(stdout,"\t\t\t\t\t\t\t<ows:MaximumValue>%s</ows:MaximumValue>\n", choices[1]);
  546. fprintf(stdout,"\t\t\t\t\t\t</ows:Range>\n");
  547. }
  548. else
  549. {
  550. for(i = 0; i < num_choices; i++)
  551. {
  552. fprintf(stdout,"\t\t\t\t\t\t<ows:Value>");
  553. print_escaped_for_xml(stdout, choices[i]);
  554. fprintf(stdout,"</ows:Value>\n");
  555. }
  556. }
  557. fprintf(stdout,"\t\t\t\t\t</ows:AllowedValues>\n");
  558. }
  559. if(default_value)
  560. {
  561. fprintf(stdout,"\t\t\t\t\t<DefaultValue>");
  562. print_escaped_for_xml(stdout, default_value);
  563. fprintf(stdout,"</DefaultValue>\n");
  564. }
  565. fprintf(stdout,"\t\t\t\t</LiteralData>\n");
  566. if(inout_type == WPS_INPUT)
  567. fprintf(stdout,"\t\t\t</Input>\n");
  568. else if(inout_type == WPS_OUTPUT)
  569. fprintf(stdout,"\t\t\t</Output>\n");
  570. }
  571. /* ************************************************************************** */
  572. static void wps_print_mimetype_text_plain(void)
  573. {
  574. fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
  575. fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>text/plain</MimeType>\n");
  576. fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
  577. }
  578. /* ************************************************************************** */
  579. static void wps_print_mimetype_raster_tiff(void)
  580. {
  581. fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
  582. fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>image/tiff</MimeType>\n");
  583. fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
  584. }
  585. /* ************************************************************************** */
  586. static void wps_print_mimetype_raster_png(void)
  587. {
  588. fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
  589. fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>image/png</MimeType>\n");
  590. fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
  591. }
  592. /* *** Native GRASS raster format urn:grass:raster:location/mapset/raster *** */
  593. static void wps_print_mimetype_raster_grass_binary(void)
  594. {
  595. fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
  596. fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>application/grass-raster-binary</MimeType>\n");
  597. fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
  598. }
  599. /* *** GRASS raster maps exported via r.out.ascii ************************** */
  600. static void wps_print_mimetype_raster_grass_ascii(void)
  601. {
  602. fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
  603. fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>application/grass-raster-ascii</MimeType>\n");
  604. fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
  605. }
  606. /* ************************************************************************** */
  607. static void wps_print_mimetype_vector_gml310(void)
  608. {
  609. fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
  610. fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>text/xml</MimeType>\n");
  611. fprintf(stdout,"\t\t\t\t\t\t\t<Encoding>UTF-8</Encoding>\n");
  612. fprintf(stdout,"\t\t\t\t\t\t\t<Schema>http://schemas.opengis.net/gml/3.1.0/polygon.xsd</Schema>\n");
  613. fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
  614. }
  615. /* *** GRASS vector format exported via v.out.ascii ************************** */
  616. static void wps_print_mimetype_vector_grass_ascii(void)
  617. {
  618. fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
  619. fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>application/grass-vector-ascii</MimeType>\n");
  620. fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
  621. }
  622. /* *** Native GRASS vector format urn:grass:vector:location/mapset/vector *** */
  623. static void wps_print_mimetype_vector_grass_binary(void)
  624. {
  625. fprintf(stdout,"\t\t\t\t\t\t<Format>\n");
  626. fprintf(stdout,"\t\t\t\t\t\t\t<MimeType>application/grass-vector-binary</MimeType>\n");
  627. fprintf(stdout,"\t\t\t\t\t\t</Format>\n");
  628. }
  629. /* Bounding box data input. Do not use! Under construction. A list of coordinate reference systems must be created.*/
  630. static void wps_print_bounding_box_data(void)
  631. {
  632. int i;
  633. fprintf(stdout,"\t\t\t<Input minOccurs=\"0\" maxOccurs=\"1\">\n");
  634. wps_print_ident_title_abstract("BoundingBox", "Bounding box to process data",
  635. "The bounding box is uesed to create the reference coordinate system in grass, as well as the lower left and upper right corner of the processing area.");
  636. fprintf(stdout,"\t\t\t\t<BoundingBoxData>\n");
  637. /* A meaningful default boundingbox should be chosen*/
  638. fprintf(stdout,"\t\t\t\t\t<Default>\n");
  639. fprintf(stdout,"\t\t\t\t\t\t<CRS>urn:ogc:def:crs,crs:EPSG:6.3:32760</CRS>\n");
  640. fprintf(stdout,"\t\t\t\t\t</Default>\n");
  641. /* A list of all proj4 supported EPSG coordinate systems should be created */
  642. fprintf(stdout,"\t\t\t\t\t<Supported>\n");
  643. for(i = 0; i < 1; i++)
  644. fprintf(stdout,"\t\t\t\t\t\t<CRS>urn:ogc:def:crs,crs:EPSG:6.3:32760</CRS>\n");
  645. fprintf(stdout,"\t\t\t\t\t</Supported>\n");
  646. fprintf(stdout,"\t\t\t\t</BoundingBoxData>\n");
  647. fprintf(stdout,"\t\t\t</Input>\n");
  648. }