process_at.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. int process_at(int from_row, int to_row, int start_col, int first_zone)
  22. {
  23. register MAPTYPE *to_ptr, *from_ptr;
  24. register int col, cur_zone;
  25. /* find all adjacent 1 cells
  26. * stop at last 1 in the from_row
  27. * return position of last 1
  28. */
  29. col = start_col;
  30. from_ptr = map + MAPINDEX(from_row, col);
  31. to_ptr = map + MAPINDEX(to_row, col);
  32. while (col <= maxcol && *from_ptr == 1) {
  33. if ((cur_zone = *to_ptr))
  34. cur_zone -= ZONE_INCR;
  35. else
  36. cur_zone = ndist;
  37. if (first_zone < cur_zone)
  38. *to_ptr = first_zone + ZONE_INCR;
  39. to_ptr++;
  40. col++;
  41. from_ptr++;
  42. }
  43. return col - 1;
  44. }