wind_format.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * \file wind_format.c
  3. *
  4. * \brief GIS Library - Window formatting functions.
  5. *
  6. * (C) 2001-2008 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-2008
  14. */
  15. #include <stdio.h>
  16. #include <grass/gis.h>
  17. static void format_double(double, char *);
  18. /**
  19. * \brief Northing to ASCII.
  20. *
  21. * Converts the double representation of the <b>north</b> coordinate to
  22. * its ASCII representation (into <b>buf</b>).
  23. *
  24. * \param[in] north northing
  25. * \param[in,out] buf buffer to hold formatted string
  26. * \param[in] projection
  27. * \return
  28. */
  29. void G_format_northing(double north, char *buf, int projection)
  30. {
  31. if (projection == PROJECTION_LL)
  32. G_lat_format(north, buf);
  33. else
  34. format_double(north, buf);
  35. }
  36. /**
  37. * \brief Easting to ASCII.
  38. *
  39. * Converts the double representation of the <b>east</b> coordinate to
  40. * its ASCII representation (into <b>buf</b>).
  41. *
  42. * \param[in] east easting
  43. * \param[in,out] buf buffer to hold formatted string
  44. * \param[in] projection
  45. * \return
  46. */
  47. void G_format_easting(double east, char *buf, int projection)
  48. {
  49. if (projection == PROJECTION_LL)
  50. G_lon_format(east, buf);
  51. else
  52. format_double(east, buf);
  53. }
  54. /**
  55. * \brief Resolution to ASCII.
  56. *
  57. * Converts the double representation of the <b>resolution</b> to its
  58. * ASCII representation (into <b>buf</b>).
  59. *
  60. * \param[in] resolution
  61. * \param[in,out] buf buffer to hold formatted string
  62. * \param[in] projection
  63. * \return
  64. */
  65. void G_format_resolution(double res, char *buf, int projection)
  66. {
  67. if (projection == PROJECTION_LL)
  68. G_llres_format(res, buf);
  69. else
  70. format_double(res, buf);
  71. }
  72. static void format_double(double value, char *buf)
  73. {
  74. sprintf(buf, "%.8f", value);
  75. G_trim_decimal(buf);
  76. }