execute.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /****************************************************************************
  2. *
  3. * MODULE: r.buffer
  4. *
  5. * AUTHOR(S): Michael Shapiro - CERL
  6. *
  7. * PURPOSE: This program creates distance zones from non-zero
  8. * cells in a grid layer. Distances are specified in
  9. * meters (on the command-line). Window does not have to
  10. * have square cells. Works both for planimetric
  11. * (UTM, State Plane) and lat-long.
  12. *
  13. * COPYRIGHT: (C) 2005 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. #include "distance.h"
  21. #include "local_proto.h"
  22. #include <grass/glocale.h>
  23. int execute_distance(void)
  24. {
  25. int row, col, nrows;
  26. MAPTYPE *ptr;
  27. /* find the first 1 in each row, and process that row */
  28. G_message(_("Finding buffer zones..."));
  29. nrows = 0;
  30. for (row = minrow; row <= maxrow; row++) {
  31. ptr = map + MAPINDEX(row, mincol);
  32. for (col = mincol; col <= maxcol; col++) {
  33. if (*ptr++ == 1) {
  34. G_percent(nrows++, count_rows_with_data, 2);
  35. process_row(row, col);
  36. break;
  37. }
  38. }
  39. }
  40. G_percent(nrows, count_rows_with_data, 2);
  41. return 0;
  42. }