main.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /****************************************************************************
  2. *
  3. * MODULE: r.surf.random
  4. * AUTHOR(S): Jo Wood, 19th October, 23rd October 1991 (original contributor)
  5. * Midlands Regional Research Laboratory (ASSIST)
  6. * AUTHOR(S): Markus Neteler <neteler itc.it> (original contributor)
  7. * PURPOSE: produces a raster map layer of uniform random deviates
  8. * COPYRIGHT: (C) 1999-2006, 2010 by the GRASS Development Team
  9. *
  10. * This program is free software under the GNU General Public
  11. * License (>=v2). Read the file COPYING that comes with GRASS
  12. * for details.
  13. *
  14. *****************************************************************************/
  15. #include <stdlib.h>
  16. #include <grass/gis.h>
  17. #include <grass/glocale.h>
  18. #include "local_proto.h"
  19. int main(int argc, char *argv[])
  20. {
  21. /****** INITIALISE ******/
  22. struct GModule *module;
  23. struct Option *out;
  24. struct Option *min;
  25. struct Option *max;
  26. struct Flag *i_flag;
  27. G_gisinit(argv[0]);
  28. module = G_define_module();
  29. G_add_keyword(_("raster"));
  30. G_add_keyword(_("surface"));
  31. G_add_keyword(_("random"));
  32. module->description =
  33. _("Produces a raster surface map of uniform random deviates with defined range.");
  34. out = G_define_standard_option(G_OPT_R_OUTPUT);
  35. min = G_define_option();
  36. min->key = "min";
  37. min->description = _("Minimum random value");
  38. min->type = TYPE_INTEGER;
  39. min->answer = "0";
  40. max = G_define_option();
  41. max->key = "max";
  42. max->description = _("Maximum random value");
  43. max->type = TYPE_INTEGER;
  44. max->answer = "100";
  45. i_flag = G_define_flag();
  46. i_flag->key = 'i';
  47. i_flag->description = _("Create an integer raster map");
  48. if (G_parser(argc, argv))
  49. exit(EXIT_FAILURE);
  50. randsurf(out->answer, atoi(min->answer), atoi(max->answer),
  51. i_flag->answer);
  52. G_done_msg(_("Raster map <%s> created."), out->answer);
  53. exit(EXIT_SUCCESS);
  54. }