user_input.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 "r.le.trace.h"
  21. extern struct CHOICE *choice;
  22. void user_input(int argc, char **argv)
  23. {
  24. struct Flag *bound;
  25. struct Flag *trace;
  26. struct Option *name;
  27. struct Option *out;
  28. bound = G_define_flag();
  29. bound->key = 'p';
  30. bound->description = "Include sampling area boundary as perimeter";
  31. trace = G_define_flag();
  32. trace->key = 't';
  33. trace->description = "Use 4 neighbor tracing instead of 8 neighbor";
  34. name = G_define_option();
  35. name->key = "map";
  36. name->description = "Raster map to be analyzed";
  37. name->type = TYPE_STRING;
  38. name->gisprompt = "old,cell,raster";
  39. name->required = YES;
  40. out = G_define_option();
  41. out->key = "out";
  42. out->description = "Name of output file to store patch data";
  43. out->type = TYPE_STRING;
  44. out->required = NO;
  45. if (G_parser(argc, argv))
  46. exit(EXIT_FAILURE);
  47. strcpy(choice->fn, name->answer);
  48. if (out->answer)
  49. strcpy(choice->out, out->answer);
  50. else
  51. strcpy(choice->out, "");
  52. /* if the 4 neighbor tracing flag -t
  53. is specified, then set the
  54. choice->trace flag to 1 */
  55. choice->trace = 1;
  56. if (trace->answer)
  57. choice->trace = 0;
  58. /* if the -p flag is specified, then
  59. set the choice->perim2 flag to 0 */
  60. if (bound->answer)
  61. choice->perim2 = 0;
  62. else
  63. choice->perim2 = 1;
  64. }