main.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /****************************************************************************
  2. *
  3. * MODULE: r.thin
  4. * AUTHOR(S): Olga Waupotitsch, CERL (original contributor)
  5. * The code for finding the bounding box as well as
  6. * input/output code was written by Mike Baba (DBA
  7. * Systems, 1990) and Jean Ezell (USACERL, 1988).
  8. *
  9. * Roberto Flor <flor itc.it>, Markus Neteler <neteler itc.it>
  10. * Glynn Clements <glynn gclements.plus.com>, Hamish Bowman <hamish_b yahoo.com>,
  11. * Jan-Oliver Wagner <jan intevation.de>
  12. * PURPOSE: Cell-file line thinning
  13. * COPYRIGHT: (C) 1999-2006 by the GRASS Development Team
  14. *
  15. * This program is free software under the GNU General Public
  16. * License (>=v2). Read the file COPYING that comes with GRASS
  17. * for details.
  18. *
  19. *****************************************************************************/
  20. /* Cell-file line thinning */
  21. /* Mike Baba */
  22. /* DBA Systems */
  23. /* Fairfax, Va */
  24. /* Jan 1990 */
  25. /* Jean Ezell */
  26. /* US Army Corps of Engineers */
  27. /* Construction Engineering Research Lab */
  28. /* Modelling and Simulation Team */
  29. /* Champaign, IL 61820 */
  30. /* January - February 1988 */
  31. #include <stdlib.h>
  32. #include <stdio.h>
  33. #include <unistd.h>
  34. #include <grass/gis.h>
  35. #include <grass/raster.h>
  36. #include "local_proto.h"
  37. #include <grass/glocale.h>
  38. char *error_prefix;
  39. int main(int argc, char *argv[])
  40. {
  41. char *input, *output;
  42. struct GModule *module;
  43. struct Option *opt1, *opt2, *opt3;
  44. struct History history;
  45. int iterations;
  46. G_gisinit(argv[0]);
  47. module = G_define_module();
  48. G_add_keyword(_("raster"));
  49. G_add_keyword(_("geometry"));
  50. module->description =
  51. _("Thins non-zero cells that denote linear "
  52. "features in a raster map layer.");
  53. opt1 = G_define_standard_option(G_OPT_R_INPUT);
  54. opt2 = G_define_standard_option(G_OPT_R_OUTPUT);
  55. opt3 = G_define_option();
  56. opt3->key = "iterations";
  57. opt3->type = TYPE_INTEGER;
  58. opt3->required = NO;
  59. opt3->answer = "200";
  60. opt3->description = _("Maximal number of iterations");
  61. if (G_parser(argc, argv))
  62. exit(EXIT_FAILURE);
  63. input = opt1->answer;
  64. output = opt2->answer;
  65. iterations = atoi(opt3->answer);
  66. open_file(input);
  67. thin_lines(iterations);
  68. close_file(output);
  69. Rast_put_cell_title(output, "Thinned linear features");
  70. Rast_short_history(output, "raster", &history);
  71. Rast_command_history(&history);
  72. Rast_write_history(output, &history);
  73. exit(EXIT_SUCCESS);
  74. }