close_down.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*****************************************************************************/
  2. /*** ***/
  3. /*** close_down() ***/
  4. /*** Closes all input and output raster maps and frees memory. ***/
  5. /*** Jo Wood, Project ASSIST, 7th February 1993 ***/
  6. /*** ***/
  7. /*****************************************************************************/
  8. #include <string.h>
  9. #include <grass/raster.h>
  10. #include "param.h"
  11. void close_down(void)
  12. {
  13. struct History history;
  14. char map_title[80], map_type[32];
  15. /* Close connection with existing input raster. */
  16. Rast_unopen(fd_in);
  17. /* Write output raster map and close connection. */
  18. Rast_close(fd_out);
  19. /* write out map metadata */
  20. Rast_short_history(rast_out_name, "raster", &history);
  21. Rast_set_history(&history, HIST_DATSRC_1, rast_in_name);
  22. switch (mparam) {
  23. case ELEV:
  24. strcpy(map_type, "Generalised elevation value");
  25. break;
  26. case SLOPE:
  27. strcpy(map_type, "Magnitude of maximum gradient");
  28. Rast_write_units(rast_out_name, "degrees");
  29. Rast_append_history(
  30. &history,
  31. "Slope is given for steepest slope angle and measured in degrees.");
  32. break;
  33. case ASPECT:
  34. strcpy(map_type, "Direction of maximum gradient");
  35. Rast_write_units(rast_out_name, "degrees");
  36. Rast_append_history(
  37. &history,
  38. "Flow direction (aspect): W=0, E=180, N=+90, S=-90 degrees");
  39. break;
  40. case PROFC:
  41. strcpy(map_type, "Profile curvature");
  42. Rast_append_history(
  43. &history,
  44. "Curvature intersecting with the plane defined by the Z axis and");
  45. Rast_append_history(
  46. &history,
  47. "maximum gradient direction. Positive values describe convex profile");
  48. Rast_append_history(
  49. &history,
  50. "curvature, negative values concave profile.");
  51. break;
  52. case PLANC:
  53. strcpy(map_type, "Plan curvature");
  54. Rast_append_history(
  55. &history,
  56. "Plan curvature is the horizontal curvature, intersecting with");
  57. Rast_append_history(
  58. &history,
  59. "the XY plane.");
  60. break;
  61. case LONGC:
  62. strcpy(map_type, "Longitudinal curvature");
  63. Rast_append_history(
  64. &history,
  65. "Longitudinal curvature is the profile curvature intersecting with the");
  66. Rast_append_history(
  67. &history,
  68. "plane defined by the surfacenormal and maximum gradient direction.");
  69. break;
  70. case CROSC:
  71. strcpy(map_type, "Cross-sectional curvature");
  72. Rast_append_history(
  73. &history,
  74. "Cross-sectional curvature is the tangential curvature intersecting");
  75. Rast_append_history(
  76. &history,
  77. "with the plane defined by the surface normal and a tangent to the");
  78. Rast_append_history(
  79. &history,
  80. "contour - perpendicular to maximum gradient direction.");
  81. break;
  82. case MINIC:
  83. strcpy(map_type, "Minimum curvature");
  84. Rast_append_history(
  85. &history,
  86. "Measured in direction perpendicular to the direction of of maximum curvature.");
  87. break;
  88. case MAXIC:
  89. strcpy(map_type, "Maximum curvature");
  90. Rast_append_history(
  91. &history,
  92. "The maximum curvature is measured in any direction");
  93. break;
  94. case FEATURE:
  95. strcpy(map_type, "Morphometric features");
  96. Rast_append_history(
  97. &history,
  98. "Morphometric features: peaks, ridges, passes, channels, pits and planes");
  99. break;
  100. default:
  101. strcpy(map_type, "?");
  102. break;
  103. }
  104. Rast_command_history(&history);
  105. Rast_write_history(rast_out_name, &history);
  106. sprintf(map_title, "DEM terrain parameter: %s", map_type);
  107. Rast_put_cell_title(rast_out_name, map_title);
  108. return;
  109. }