wind_format.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 int 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 always returns 0
  28. */
  29. int 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. return 0;
  36. }
  37. /**
  38. * \brief Easting to ASCII.
  39. *
  40. * Converts the double representation of the <b>east</b> coordinate to
  41. * its ASCII representation (into <b>buf</b>).
  42. *
  43. * \param[in] east easting
  44. * \param[in,out] buf buffer to hold formatted string
  45. * \param[in] projection
  46. * \return always returns 0
  47. */
  48. int G_format_easting(double east, char *buf, int projection)
  49. {
  50. if (projection == PROJECTION_LL)
  51. G_lon_format(east, buf);
  52. else
  53. format_double(east, buf);
  54. return 0;
  55. }
  56. /**
  57. * \brief Resolution to ASCII.
  58. *
  59. * Converts the double representation of the <b>resolution</b> to its
  60. * ASCII representation (into <b>buf</b>).
  61. *
  62. * \param[in] resolution
  63. * \param[in,out] buf buffer to hold formatted string
  64. * \param[in] projection
  65. * \return always returns 0
  66. */
  67. int G_format_resolution(double res, char *buf, int projection)
  68. {
  69. if (projection == PROJECTION_LL)
  70. G_llres_format(res, buf);
  71. else
  72. format_double(res, buf);
  73. return 0;
  74. }
  75. static int format_double(double value, char *buf)
  76. {
  77. sprintf(buf, "%.8f", value);
  78. G_trim_decimal(buf);
  79. return 0;
  80. }