GRASS GIS 7 Programmer's Manual  7.0.5(2016)-r00000
get_projinfo.c
Go to the documentation of this file.
1 
12 #include <unistd.h>
13 #include <grass/gis.h>
14 #include <grass/glocale.h>
15 
16 #define PERMANENT "PERMANENT"
17 
29 struct Key_Value *G_get_projunits(void)
30 {
31  struct Key_Value *in_units_keys;
32  char path[GPATH_MAX];
33 
34  G_file_name(path, "", UNIT_FILE, PERMANENT);
35  if (access(path, 0) != 0) {
36  if (G_projection() != PROJECTION_XY) {
37  G_warning(_("<%s> file not found for location <%s>"),
38  UNIT_FILE, G_location());
39  }
40  return NULL;
41  }
42  in_units_keys = G_read_key_value_file(path);
43 
44  return in_units_keys;
45 }
46 
58 struct Key_Value *G_get_projinfo(void)
59 {
60  struct Key_Value *in_proj_keys;
61  char path[GPATH_MAX];
62 
63  G_file_name(path, "", PROJECTION_FILE, PERMANENT);
64  if (access(path, 0) != 0) {
65  if (G_projection() != PROJECTION_XY) {
66  G_warning(_("<%s> file not found for location <%s>"),
67  PROJECTION_FILE, G_location());
68  }
69  return NULL;
70  }
71  in_proj_keys = G_read_key_value_file(path);
72 
73  return in_proj_keys;
74 }
75 
85 struct Key_Value *G_get_projepsg(void)
86 {
87  struct Key_Value *in_epsg_keys;
88  char path[GPATH_MAX];
89 
90  G_file_name(path, "", EPSG_FILE, PERMANENT);
91  if (access(path, 0) != 0) {
92  if (G_projection() != PROJECTION_XY) {
93  G_debug(1, "<%s> file not found for location <%s>",
94  EPSG_FILE, G_location());
95  }
96  return NULL;
97  }
98  in_epsg_keys = G_read_key_value_file(path);
99 
100  return in_epsg_keys;
101 }
const char * G_location(void)
Get current location name.
Definition: location.c:32
#define PERMANENT
Definition: get_projinfo.c:16
struct Key_Value * G_get_projunits(void)
Gets units information for location.
Definition: get_projinfo.c:29
#define NULL
Definition: ccmath.h:32
struct Key_Value * G_read_key_value_file(const char *file)
Read key/values pairs from file.
Definition: key_value3.c:53
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
Definition: file_name.c:33
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
struct Key_Value * G_get_projinfo(void)
Gets projection information for location.
Definition: get_projinfo.c:58
struct Key_Value * G_get_projepsg(void)
Gets EPSG information for the current location.
Definition: get_projinfo.c:85
Definition: path.h:16
int G_projection(void)
Query cartographic projection.
Definition: proj1.c:32
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition: gis/error.c:203