get_projinfo.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. struct Key_Value *in_units_keys;
  25. char path[GPATH_MAX];
  26. G__file_name(path, "", UNIT_FILE, PERMANENT);
  27. if (access(path, 0) != 0) {
  28. if (G_projection() != PROJECTION_XY) {
  29. G_warning(_("<%s> file not found for location <%s>"),
  30. UNIT_FILE, G_location());
  31. }
  32. return NULL;
  33. }
  34. in_units_keys = G_read_key_value_file(path);
  35. return in_units_keys;
  36. }
  37. /*!
  38. * \brief Gets projection information for location
  39. *
  40. * \return pointer to Key_Value structure with key/value pairs
  41. */
  42. struct Key_Value *G_get_projinfo(void)
  43. {
  44. struct Key_Value *in_proj_keys;
  45. char path[GPATH_MAX];
  46. G__file_name(path, "", PROJECTION_FILE, PERMANENT);
  47. if (access(path, 0) != 0) {
  48. if (G_projection() != PROJECTION_XY) {
  49. G_warning(_("<%s> file not found for location <%s>"),
  50. PROJECTION_FILE, G_location());
  51. }
  52. return NULL;
  53. }
  54. in_proj_keys = G_read_key_value_file(path);
  55. return in_proj_keys;
  56. }