get_projinfo.c 1.6 KB

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