get_projinfo.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*!
  2. * \file get_projinfo.c
  3. *
  4. * \brief GIS Library - Get projection info
  5. *
  6. * (C) 1999-2008 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public
  9. * License (>=v2). Read the file COPYING that comes with GRASS
  10. * for details.
  11. *
  12. */
  13. #include <unistd.h>
  14. #include <grass/gis.h>
  15. #include <grass/glocale.h>
  16. #define PERMANENT "PERMANENT"
  17. /*!
  18. * \brief Gets unit information for location
  19. *
  20. * \return pointer to Key_Value structure with key/value pairs
  21. */
  22. struct Key_Value *G_get_projunits(void)
  23. {
  24. int stat;
  25. struct Key_Value *in_units_keys;
  26. char path[GPATH_MAX];
  27. G__file_name(path, "", UNIT_FILE, PERMANENT);
  28. if (access(path, 0) != 0) {
  29. G_warning(_("<%s> file not found for location <%s>"),
  30. UNIT_FILE, G_location());
  31. return NULL;
  32. }
  33. in_units_keys = G_read_key_value_file(path, &stat);
  34. if (stat != 0) {
  35. G_warning(_("ERROR in reading <%s> file for location <%s>"),
  36. UNIT_FILE, G_location());
  37. return NULL;
  38. }
  39. return in_units_keys;
  40. }
  41. /*!
  42. * \brief Gets projection information for location
  43. *
  44. * \return pointer to Key_Value structure with key/value pairs
  45. */
  46. struct Key_Value *G_get_projinfo(void)
  47. {
  48. int stat;
  49. struct Key_Value *in_proj_keys;
  50. char path[GPATH_MAX];
  51. G__file_name(path, "", PROJECTION_FILE, PERMANENT);
  52. if (access(path, 0) != 0) {
  53. G_warning(_("<%s> file not found for location <%s>"),
  54. PROJECTION_FILE, G_location());
  55. return NULL;
  56. }
  57. in_proj_keys = G_read_key_value_file(path, &stat);
  58. if (stat != 0) {
  59. G_warning(_("ERROR in reading <%s> file for location <%s>"),
  60. PROJECTION_FILE, G_location());
  61. return NULL;
  62. }
  63. return in_proj_keys;
  64. }