main.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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>,
  11. * Hamish Bowman <hamish_b yahoo.com>,
  12. * Jan-Oliver Wagner <jan intevation.de>,
  13. * Huidae Cho <grass4u gmail.com>
  14. * PURPOSE: Cell-file line thinning
  15. * COPYRIGHT: (C) 1999-2015 by the GRASS Development Team
  16. *
  17. * This program is free software under the GNU General Public
  18. * License (>=v2). Read the file COPYING that comes with GRASS
  19. * for details.
  20. *
  21. *****************************************************************************/
  22. /* Cell-file line thinning */
  23. /* Mike Baba */
  24. /* DBA Systems */
  25. /* Fairfax, Va */
  26. /* Jan 1990 */
  27. /* Jean Ezell */
  28. /* US Army Corps of Engineers */
  29. /* Construction Engineering Research Lab */
  30. /* Modelling and Simulation Team */
  31. /* Champaign, IL 61820 */
  32. /* January - February 1988 */
  33. #include <stdlib.h>
  34. #include <stdio.h>
  35. #include <unistd.h>
  36. #include <grass/gis.h>
  37. #include <grass/raster.h>
  38. #include "local_proto.h"
  39. #include <grass/glocale.h>
  40. int main(int argc, char *argv[])
  41. {
  42. char *input, *output;
  43. struct GModule *module;
  44. struct Option *opt1, *opt2, *opt3;
  45. struct History history;
  46. int iterations;
  47. G_gisinit(argv[0]);
  48. module = G_define_module();
  49. G_add_keyword(_("raster"));
  50. G_add_keyword(_("geometry"));
  51. module->description =
  52. _("Thins non-null cells that denote linear "
  53. "features in a raster map layer.");
  54. opt1 = G_define_standard_option(G_OPT_R_INPUT);
  55. opt2 = G_define_standard_option(G_OPT_R_OUTPUT);
  56. opt3 = G_define_option();
  57. opt3->key = "iterations";
  58. opt3->type = TYPE_INTEGER;
  59. opt3->required = NO;
  60. opt3->answer = "200";
  61. opt3->description = _("Maximal number of iterations");
  62. if (G_parser(argc, argv))
  63. exit(EXIT_FAILURE);
  64. input = opt1->answer;
  65. output = opt2->answer;
  66. iterations = atoi(opt3->answer);
  67. open_file(input);
  68. thin_lines(iterations);
  69. close_file(output);
  70. Rast_put_cell_title(output, "Thinned linear features");
  71. Rast_short_history(output, "raster", &history);
  72. Rast_command_history(&history);
  73. Rast_write_history(output, &history);
  74. exit(EXIT_SUCCESS);
  75. }