21 static const char *lookup_proj(
const char *);
22 static const char *lookup_units(
const char *);
23 static const char *lookup_epsg(
void);
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)
74 name = lookup_units(
"unit");
78 if (strcasecmp(
name,
"meter") == 0 || strcasecmp(
name,
"metre") == 0 ||
79 strcasecmp(
name,
"meters") == 0 || strcasecmp(
name,
"metres") == 0)
81 else if (strcasecmp(
name,
"kilometer") == 0 ||
82 strcasecmp(
name,
"kilometre") == 0 ||
83 strcasecmp(
name,
"kilometers") == 0 ||
84 strcasecmp(
name,
"kilometres") == 0)
86 else if (strcasecmp(
name,
"acre") == 0 ||
87 strcasecmp(
name,
"acres") == 0)
89 else if (strcasecmp(
name,
"hectare") == 0 ||
90 strcasecmp(
name,
"hectares") == 0)
92 else if (strcasecmp(
name,
"mile") == 0 ||
93 strcasecmp(
name,
"miles") == 0)
95 else if (strcasecmp(
name,
"foot") == 0 || strcasecmp(
name,
"feet") == 0)
97 else if (strcasecmp(
name,
"foot_us") == 0 ||
98 strcasecmp(
name,
"foot_uss") == 0)
100 else if (strcasecmp(
name,
"degree") == 0 ||
101 strcasecmp(
name,
"degrees") == 0)
130 name = lookup_proj(
"name");
132 return _(
"Unknown projection");
154 static const struct {
157 } table[] = {{
"unit", 1.0}, {
"meter", 1.0},
158 {
"foot", .3048}, {
"foot_us", 1200 / 3937.},
159 {
"inch", .0254}, {
NULL, 0.0}};
162 buf = lookup_units(
"meters");
164 sscanf(buf,
"%lf", &factor);
167 for (n = 0; table[n].unit; n++)
168 if (equal(unit, table[n].unit)) {
169 factor = table[n].factor;
189 char buf[256], params[256];
192 name = lookup_proj(
"datum");
200 if (datumstatus == 2)
216 name = lookup_proj(
"ellps");
222 sprintf(buf,
"a=%.16g es=%.16g", a, es);
238 return lookup_epsg();
241 const char *lookup_proj(
const char *key)
247 const char *lookup_units(
const char *key)
253 const char *lookup_epsg(
void)
259 int equal(
const char *a,
const char *
b)
264 if (lower(*a++) != lower(*
b++))
273 if (c >=
'A' && c <=
'Z')
struct Key_Value * G_get_projinfo(void)
Gets projection information for location.
struct Key_Value * G_get_projunits(void)
Gets units information for location.
int G_get_ellipsoid_parameters(double *, double *)
get ellipsoid parameters
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
const char * G_get_units_name(int, int, int)
Get localized units name.
int G_projection_units(int)
Get projection units code (for internal use only)
int G_get_datumparams_from_projinfo(const struct Key_Value *, char *, char *)
const char * G_projection_name(int)
Get projection name.
int G_is_initialized(int *)
void G_initialize_done(int *)
struct Key_Value * G_get_projepsg(void)
Gets EPSG information for the current location.
char * G_store(const char *)
Copy string to allocated memory.
int G_projection(void)
Query cartographic projection.
#define PROJECTION_XY
Projection code - XY coordinate system (unreferenced data)
#define U_UNDEFINED
List of units.
#define PROJECTION_UTM
Projection code - UTM.
#define PROJECTION_LL
Projection code - Latitude-Longitude.
const char * G_database_epsg_code(void)
Get EPGS code for the current location.
const char * G_database_projection_name(void)
Query cartographic projection for the current location.
double G_database_units_to_meters_factor(void)
Conversion to meters.
const char * G_database_unit_name(int plural)
Get units (localized) name for the current location.
int G_database_unit(void)
Get units id for the current location.
const char * G_database_ellipse_name(void)
Get ellipsoid name for the current location.
const char * G_database_datum_name(void)
Get datum name for the current location.