process_row.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. int process_row(int row, int start_col)
  23. {
  24. int r, first_zone, col;
  25. /* go north */
  26. begin_distance(row);
  27. for (r = row; r >= 0 && (first_zone = find_distances(r)) >= 0; r--) {
  28. col = start_col;
  29. while (col <= maxcol) {
  30. process_left(row, r, col, first_zone);
  31. col = process_at(row, r, col, first_zone);
  32. col = process_right(row, r, col, first_zone);
  33. }
  34. }
  35. /* go south */
  36. reset_distances();
  37. for (r = row + 1;
  38. r < window.rows && (first_zone = find_distances(r)) >= 0; r++) {
  39. col = start_col;
  40. while (col <= maxcol) {
  41. process_left(row, r, col, first_zone);
  42. col = process_at(row, r, col, first_zone);
  43. col = process_right(row, r, col, first_zone);
  44. }
  45. }
  46. return 0;
  47. }