21 static const char *lookup_proj(
const char *);
22 static const char *lookup_units(
const char *);
23 static const char *lookup_epsg();
24 static int equal(
const char *,
const char *);
25 static int lower(
char);
27 static int initialized;
28 static struct Key_Value *proj_info, *proj_units, *proj_epsg;
30 static void init(
void)
73 name = lookup_units(
"unit");
77 if (strcasecmp(name,
"meter") == 0 || strcasecmp(name,
"metre") == 0
78 || strcasecmp(name,
"meters") == 0 || strcasecmp(name,
"metres") == 0)
80 else if (strcasecmp(name,
"kilometer") == 0 || strcasecmp(name,
"kilometre") == 0
81 || strcasecmp(name,
"kilometers") == 0 || strcasecmp(name,
"kilometres") == 0)
83 else if (strcasecmp(name,
"acre") == 0 || strcasecmp(name,
"acres") == 0)
85 else if (strcasecmp(name,
"hectare") == 0 || strcasecmp(name,
"hectares") == 0)
87 else if (strcasecmp(name,
"mile") == 0 || strcasecmp(name,
"miles") == 0)
89 else if (strcasecmp(name,
"foot") == 0 || strcasecmp(name,
"feet") == 0)
91 else if (strcasecmp(name,
"foot_us") == 0 || strcasecmp(name,
"foot_uss") == 0)
93 else if (strcasecmp(name,
"degree") == 0 || strcasecmp(name,
"degrees") == 0)
122 name = lookup_proj(
"name");
124 return _(
"Unknown projection");
154 {
"foot_us", 1200/3937.},
160 buf = lookup_units(
"meters");
162 sscanf(buf,
"%lf", &factor);
165 for (n = 0; table[n].unit; n++)
166 if (equal(unit, table[n].unit)) {
167 factor = table[n].factor;
187 char buf[256], params[256];
190 name = lookup_proj(
"datum");
198 if (datumstatus == 2)
214 name = lookup_proj(
"ellps");
220 sprintf(buf,
"a=%.16g es=%.16g", a, es);
236 return lookup_epsg();
239 const char *lookup_proj(
const char *
key)
245 const char *lookup_units(
const char *key)
251 const char *lookup_epsg()
257 int equal(
const char *a,
const char *
b)
262 if (lower(*a++) != lower(*b++))
271 if (c >=
'A' && c <=
'Z')
const char * G_database_datum_name(void)
Get datum name for the current location.
struct Key_Value * G_get_projinfo(void)
Gets projection information for location.
const char * G_database_ellipse_name(void)
Get ellipsoid name for the current location.
int G_projection(void)
Query cartographic projection.
int G_get_datumparams_from_projinfo(const struct Key_Value *, char *, char *)
const char * G_database_epsg_code(void)
Get EPGS code for the current location.
#define PROJECTION_XY
Projection code - XY coordinate system (unreferenced data)
void G_initialize_done(int *)
struct Key_Value * G_get_projunits(void)
Gets units information for location.
int G_database_unit()
Get units id for the current location.
#define PROJECTION_UTM
Projection code - UTM.
const char * G_get_units_name(int, int, int)
Get localized units name.
const char * G_projection_name(int)
Get projection name.
#define U_UNDEFINED
List of units.
#define PROJECTION_LL
Projection code - Latitude-Longitude.
const char * G_database_projection_name(void)
Query cartographic projection for the current location.
int G_get_ellipsoid_parameters(double *, double *)
get ellipsoid parameters
int G_is_initialized(int *)
int G_projection_units(int)
Get projection units code (for internal use only)
char * G_store(const char *)
Copy string to allocated memory.
double G_database_units_to_meters_factor(void)
Conversion to meters.
struct Key_Value * G_get_projepsg(void)
Gets EPSG information for the current location.
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
const char * G_database_unit_name(int plural)
Get units (localized) name for the current location.