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>"), UNIT_FILE,
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>", EPSG_FILE,
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>", WKT_FILE,
144 fp = fopen(
path,
"r");
149 wktstring = G_malloc(1024 *
sizeof(
char));
176 wktstring = G_realloc(wktstring, nalloc + 1024);
187 wktstring = G_realloc(wktstring, nalloc + 1);
201 if (wktstring && *wktstring)
203 if (wktstring && *wktstring ==
'\0') {
239 char *sridstring =
NULL;
240 char path[GPATH_MAX];
246 if (access(
path, 0) != 0) {
248 struct Key_Value *projepsg;
249 const char *epsg_num;
251 G_debug(1,
"<%s> file not found for location <%s>", SRID_FILE,
258 G_debug(1,
"Using <%s> file instead for location <%s>",
270 fp = fopen(
path,
"r");
275 sridstring = G_malloc(1024 *
sizeof(
char));
302 sridstring = G_realloc(sridstring, nalloc + 1024);
313 sridstring = G_realloc(sridstring, nalloc + 1);
316 sridstring[n] =
'\0';
327 if (sridstring && *sridstring)
329 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_projepsg(void)
Gets EPSG information for the current location.
char * G_get_projwkt(void)
Get WKT information for the current location.
char * G_get_projsrid(void)
Get srid (spatial reference id) for the current location.
struct Key_Value * G_get_projunits(void)
Gets units information for 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.