find_pour.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "Gwater.h"
  2. int find_pourpts(void)
  3. {
  4. int value, row, col;
  5. double easting, northing, stream_length;
  6. CELL old_elev, basin_num;
  7. ocs_alloced = 2 * bas_thres;
  8. ocs = (OC_STACK *)G_malloc(ocs_alloced * sizeof(OC_STACK));
  9. basin_num = 0;
  10. stream_length = old_elev = 0;
  11. for (row = 0; row < nrows; row++) {
  12. G_percent(row, nrows, 1);
  13. northing = window.north - (row + .5) * window.ns_res;
  14. for (col = 0; col < ncols; col++) {
  15. value = FLAG_GET(swale, row, col);
  16. if (value && asp[SEG_INDEX(asp_seg, row, col)] <= 0) {
  17. basin_num += 2;
  18. if (arm_flag) {
  19. easting = window.west + (col + .5) * window.ew_res;
  20. fprintf(fp, "%5d drains into %5d at %3d %3d %.3f %.3f",
  21. (int)basin_num, 0, row, col, easting, northing);
  22. if (col == 0 || col == ncols - 1) {
  23. stream_length = .5 * window.ew_res;
  24. }
  25. else if (row == 0 || row == nrows - 1) {
  26. stream_length = .5 * window.ns_res;
  27. }
  28. else {
  29. stream_length = 0.0;
  30. }
  31. old_elev = alt[SEG_INDEX(alt_seg, row, col)];
  32. }
  33. basin_num =
  34. def_basin(row, col, basin_num, stream_length, old_elev);
  35. }
  36. }
  37. }
  38. G_percent(nrows, nrows, 1); /* finish it */
  39. n_basins = basin_num;
  40. G_free(ocs);
  41. return 0;
  42. }