main.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /****************************************************************************
  2. *
  3. * MODULE: r.random.cells
  4. * AUTHOR(S): Charles Ehlschlaeger; National Center for Geographic Information
  5. * and Analysis, University of California, Santa Barbara (original contributor)
  6. * Markus Neteler <neteler itc.it>
  7. * Roberto Flor <flor itc.it>,
  8. * Brad Douglas <rez touchofmadness.com>, Glynn Clements <glynn gclements.plus.com>
  9. * PURPOSE: generates a random sets of cells that are at least
  10. * some distance apart
  11. * COPYRIGHT: (C) 1999-2008 by the GRASS Development Team
  12. *
  13. * This program is free software under the GNU General Public
  14. * License (>=v2). Read the file COPYING that comes with GRASS
  15. * for details.
  16. *
  17. *****************************************************************************/
  18. #include <stdlib.h>
  19. #include <grass/gis.h>
  20. #include <grass/glocale.h>
  21. #include "ransurf.h"
  22. #include "local_proto.h"
  23. double NS, EW;
  24. int CellCount, Rs, Cs;
  25. double MaxDist, MaxDistSq;
  26. FLAG *Cells;
  27. CELLSORTER *DoNext;
  28. CELL **Out, *CellBuffer;
  29. int Seed, OutFD;
  30. struct Flag *Verbose;
  31. struct Option *Distance;
  32. struct Option *Output;
  33. struct Option *SeedStuff;
  34. int main(int argc, char *argv[])
  35. {
  36. struct GModule *module;
  37. G_gisinit(argv[0]);
  38. /* Set description */
  39. module = G_define_module();
  40. G_add_keyword(_("raster"));
  41. G_add_keyword(_("sampling"));
  42. G_add_keyword(_("random"));
  43. module->description =
  44. _("Generates random cell values with spatial dependence.");
  45. Output = G_define_standard_option(G_OPT_R_OUTPUT);
  46. Distance = G_define_option();
  47. Distance->key = "distance";
  48. Distance->type = TYPE_DOUBLE;
  49. Distance->required = YES;
  50. Distance->multiple = NO;
  51. Distance->description =
  52. _("Maximum distance of spatial correlation (value(s) >= 0.0)");
  53. SeedStuff = G_define_option();
  54. SeedStuff->key = "seed";
  55. SeedStuff->type = TYPE_INTEGER;
  56. SeedStuff->required = NO;
  57. SeedStuff->description =
  58. _("Random seed (SEED_MIN >= value >= SEED_MAX) (default [random])");
  59. if (G_parser(argc, argv))
  60. exit(EXIT_FAILURE);
  61. Init();
  62. Indep();
  63. G_done_msg(" ");
  64. exit(EXIT_SUCCESS);
  65. }