user_input.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. ************************************************************
  3. * MODULE: r.le.trace/user_input.c *
  4. * Version 5.0 Nov. 1, 2001 *
  5. * *
  6. * AUTHOR: W.L. Baker, University of Wyoming *
  7. * BAKERWL@UWYO.EDU *
  8. * *
  9. * PURPOSE: To obtain information from the user about what *
  10. * information is desired *
  11. * *
  12. * COPYRIGHT: (C) 2001 by W.L. Baker *
  13. * *
  14. * This program is free software under the GNU General *
  15. * Public License(>=v2). Read the file COPYING that comes *
  16. * with GRASS for details *
  17. * *
  18. ************************************************************/
  19. #include <grass/config.h>
  20. #include <grass/glocale.h>
  21. #include "r.le.trace.h"
  22. extern struct CHOICE *choice;
  23. void user_input(int argc, char **argv)
  24. {
  25. struct Flag *bound;
  26. struct Flag *trace;
  27. struct Option *name;
  28. struct Option *out;
  29. bound = G_define_flag();
  30. bound->key = 'p';
  31. bound->description = _("Include sampling area boundary as perimeter");
  32. trace = G_define_flag();
  33. trace->key = 't';
  34. trace->description = _("Use 4 neighbor tracing instead of 8 neighbor");
  35. name = G_define_standard_option(G_OPT_R_MAP);
  36. name->description = _("Raster map to be analyzed");
  37. out = G_define_standard_option(G_OPT_F_OUTPUT);
  38. out->description = _("Name of output file to store patch data");
  39. out->required = NO;
  40. if (G_parser(argc, argv))
  41. exit(EXIT_FAILURE);
  42. strcpy(choice->fn, name->answer);
  43. if (out->answer)
  44. strcpy(choice->out, out->answer);
  45. else
  46. strcpy(choice->out, "");
  47. /* if the 4 neighbor tracing flag -t
  48. is specified, then set the
  49. choice->trace flag to 1 */
  50. choice->trace = 1;
  51. if (trace->answer)
  52. choice->trace = 0;
  53. /* if the -p flag is specified, then
  54. set the choice->perim2 flag to 0 */
  55. if (bound->answer)
  56. choice->perim2 = 0;
  57. else
  58. choice->perim2 = 1;
  59. }