wr_cellhd.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*!
  2. * \file lib/gis/wr_cellhd.c
  3. *
  4. * \brief GIS Library - Write Cell Header functions.
  5. *
  6. * (C) 2001-2014 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public License
  9. * (>=v2). Read the file COPYING that comes with GRASS for details.
  10. *
  11. * \author GRASS GIS Development Team
  12. *
  13. * \date 1999-2014
  14. */
  15. #include <stdio.h>
  16. #include <grass/gis.h>
  17. /**
  18. * \brief Write cell header or window.
  19. *
  20. * \param[in,out] fd header file
  21. * \param[in] cellhd pointed to cell header structure
  22. * \param[in] is_cellhd 1 cell header; 0 window
  23. * \return
  24. */
  25. void G__write_Cell_head(FILE * fd,
  26. const struct Cell_head *cellhd, int is_cellhd)
  27. {
  28. char buf[1024];
  29. int fmt;
  30. fmt = cellhd->proj;
  31. fprintf(fd, "proj: %d\n", cellhd->proj);
  32. fprintf(fd, "zone: %d\n", cellhd->zone);
  33. G_format_northing(cellhd->north, buf, fmt);
  34. fprintf(fd, "north: %s\n", buf);
  35. G_format_northing(cellhd->south, buf, fmt);
  36. fprintf(fd, "south: %s\n", buf);
  37. G_format_easting(cellhd->east, buf, fmt);
  38. fprintf(fd, "east: %s\n", buf);
  39. G_format_easting(cellhd->west, buf, fmt);
  40. fprintf(fd, "west: %s\n", buf);
  41. fprintf(fd, "cols: %d\n", cellhd->cols);
  42. fprintf(fd, "rows: %d\n", cellhd->rows);
  43. G_format_resolution(cellhd->ew_res, buf, fmt);
  44. fprintf(fd, "e-w resol: %s\n", buf);
  45. G_format_resolution(cellhd->ns_res, buf, fmt);
  46. fprintf(fd, "n-s resol: %s\n", buf);
  47. if (is_cellhd) {
  48. fprintf(fd, "format: %d\n", cellhd->format);
  49. fprintf(fd, "compressed: %d\n", cellhd->compressed);
  50. }
  51. }
  52. /**
  53. * \brief Write 3D cell header or window.
  54. *
  55. * \param[in,out] fd header file
  56. * \param[in] cellhd pointer to cell header structure
  57. * \param[in] is_cellhd 1 cell header; 0 window
  58. * \return
  59. */
  60. void G__write_Cell_head3(FILE * fd,
  61. const struct Cell_head *cellhd, int is_cellhd)
  62. {
  63. char buf[1024];
  64. int fmt;
  65. fmt = cellhd->proj;
  66. G__write_Cell_head(fd, cellhd, is_cellhd);
  67. fprintf(fd, "top: %.15f\n", cellhd->top);
  68. fprintf(fd, "bottom: %.15f\n", cellhd->bottom);
  69. fprintf(fd, "cols3: %d\n", cellhd->cols3);
  70. fprintf(fd, "rows3: %d\n", cellhd->rows3);
  71. fprintf(fd, "depths: %d\n", cellhd->depths);
  72. G_format_resolution(cellhd->ew_res3, buf, fmt);
  73. fprintf(fd, "e-w resol3: %s\n", buf);
  74. G_format_resolution(cellhd->ns_res3, buf, fmt);
  75. fprintf(fd, "n-s resol3: %s\n", buf);
  76. G_format_resolution(cellhd->tb_res, buf, -1);
  77. fprintf(fd, "t-b resol: %s\n", buf);
  78. }