16 #include <grass/gis.h>
17 #include <grass/glocale.h>
19 #define PERMANENT "PERMANENT"
34 struct Key_Value *in_units_keys;
38 if (access(
path, 0) != 0) {
40 G_warning(_(
"<%s> file not found for location <%s>"),
63 struct Key_Value *in_proj_keys, *in_epsg_keys;
67 if (access(
path, 0) != 0) {
69 G_warning(_(
"<%s> file not found for location <%s>"),
81 sprintf(buf,
"EPSG:%s", epsgstr);
104 struct Key_Value *in_epsg_keys;
105 char path[GPATH_MAX];
108 if (access(
path, 0) != 0) {
110 G_debug(1,
"<%s> file not found for location <%s>",
129 char *wktstring =
NULL;
130 char path[GPATH_MAX];
136 if (access(
path, 0) != 0) {
138 G_debug(1,
"<%s> file not found for location <%s>",
144 fp = fopen(
path,
"r");
148 wktstring = G_malloc(1024 *
sizeof(
char));
174 wktstring = G_realloc(wktstring, nalloc + 1024);
185 wktstring = G_realloc(wktstring, nalloc + 1);
198 if (wktstring && *wktstring)
200 if (wktstring && *wktstring ==
'\0') {
235 char *sridstring =
NULL;
236 char path[GPATH_MAX];
242 if (access(
path, 0) != 0) {
244 struct Key_Value *projepsg;
245 const char *epsg_num;
247 G_debug(1,
"<%s> file not found for location <%s>",
254 G_debug(1,
"Using <%s> file instead for location <%s>",
266 fp = fopen(
path,
"r");
270 sridstring = G_malloc(1024 *
sizeof(
char));
296 sridstring = G_realloc(sridstring, nalloc + 1024);
307 sridstring = G_realloc(sridstring, nalloc + 1);
310 sridstring[n] =
'\0';
320 if (sridstring && *sridstring)
322 if (sridstring && *sridstring ==
'\0') {
void G_free(void *buf)
Free allocated memory.
int G_asprintf(char **out, const char *fmt,...)
int G_debug(int level, const char *msg,...)
Print debugging message.
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
struct Key_Value * G_get_projinfo(void)
Gets projection information for location.
struct Key_Value * G_get_projunits(void)
Gets units information for location.
char * G_get_projsrid(void)
Get srid (spatial reference id) for the current location.
char * G_get_projwkt(void)
Get WKT information for the current location.
struct Key_Value * G_get_projepsg(void)
Gets EPSG information for the current location.
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
void G_warning(const char *msg,...)
Print a warning message to stderr.
void G_free_key_value(struct Key_Value *kv)
Free allocated Key_Value structure.
void G_set_key_value(const char *key, const char *value, struct Key_Value *kv)
Set value for given key.
const char * G_find_key_value(const char *key, const struct Key_Value *kv)
Find given key (case sensitive)
struct Key_Value * G_read_key_value_file(const char *file)
Read key/values pairs from file.
const char * G_location(void)
Get current location name.
int G_projection(void)
Query cartographic projection.
char * G_chop(char *line)
Chop leading and trailing white spaces.