main.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /****************************************************************************
  2. *
  3. * MODULE: r.topidx
  4. *
  5. * AUTHOR(S): Keith Beven <k.beven lancaster.ac.uk>,
  6. * Huidae Cho <grass4u gmail.com>, Hydro Laboratory,
  7. * Kyungpook National University
  8. *
  9. * PURPOSE: Creates topographic index map from elevation map.
  10. * Based on GRIDATB.FOR.
  11. *
  12. * COPYRIGHT: (C) 2000-2013 by the GRASS Development Team
  13. *
  14. * This program is free software under the GNU General Public
  15. * License (>=v2). Read the file COPYING that comes with GRASS
  16. * for details.
  17. *
  18. *****************************************************************************/
  19. #define _MAIN_C_
  20. #include <stdlib.h>
  21. #include <grass/gis.h>
  22. #include <grass/glocale.h>
  23. #include "global.h"
  24. int main(int argc, char **argv)
  25. {
  26. struct GModule *module;
  27. struct
  28. {
  29. struct Option *input;
  30. struct Option *output;
  31. } params;
  32. G_gisinit(argv[0]);
  33. module = G_define_module();
  34. G_add_keyword(_("raster"));
  35. G_add_keyword(_("hydrology"));
  36. module->description =
  37. _("Creates topographic index map from elevation raster map.");
  38. params.input = G_define_standard_option(G_OPT_R_ELEV);
  39. params.input->key = "input";
  40. params.output = G_define_standard_option(G_OPT_R_OUTPUT);
  41. params.output->description = _("Name for output topographic index map");
  42. if (G_parser(argc, argv))
  43. exit(EXIT_FAILURE);
  44. /* Make sure that the current projection is not lat/long */
  45. if ((G_projection() == PROJECTION_LL))
  46. G_fatal_error(_("Lat/Long location is not supported by %s. Please reproject map first."),
  47. G_program_name());
  48. input = params.input->answer;
  49. output = params.output->answer;
  50. G_get_window(&window);
  51. read_cells();
  52. initialize();
  53. calculate_atanb();
  54. write_cells();
  55. exit(EXIT_SUCCESS);
  56. }