17 #define DATUMTABLE "/etc/proj/datum.table" 43 static int compare_table_names(
const void *,
const void *);
51 for (i = 0; i < table.count; i++)
62 if (n < 0 || n >= table.count)
65 return table.datums[n].name;
72 if (n < 0 || n >= table.count)
75 return table.datums[n].descr;
82 if (n < 0 || n >= table.count)
85 return table.datums[n].ellps;
110 char *datumname,
char *params)
124 sprintf(params,
"nadgrids=%s",
135 sprintf(params,
"towgs84=%s,%s,%s",
158 fd = fopen(file,
"r");
160 G_warning(
_(
"unable to open datum table file: %s"), file);
165 for (line = 1;
G_getl2(buf,
sizeof(buf), fd); line++) {
166 char name[100], descr[100], ellps[100];
170 if (*buf ==
'\0' || *buf ==
'#')
173 if (table.count >= table.size) {
175 table.datums =
G_realloc(table.datums, table.size *
sizeof(
struct datum));
178 t = &table.datums[table.count];
180 if (sscanf(buf,
"%s \"%99[^\"]\" %s dx=%lf dy=%lf dz=%lf",
181 name, descr, ellps, &t->dx, &t->dy, &t->dz) != 6) {
182 G_warning(
_(
"error in datum table file, line %d"), line);
193 qsort(table.datums, table.count,
sizeof(
struct datum), compare_table_names);
198 static int compare_table_names(
const void *aa,
const void *bb)
200 const struct datum *a = aa;
201 const struct datum *
b = bb;
int G_getl2(char *, int, FILE *)
Gets a line of text from a file of any pedigree.
int G_get_datumparams_from_projinfo(const struct Key_Value *projinfo, char *datumname, char *params)
void G_read_datum_table(void)
const char * G_datum_description(int n)
void G_strip(char *)
Removes all leading and trailing white space from string.
const char * G_datum_name(int n)
void G_initialize_done(int *)
const char * G_datum_ellipsoid(int n)
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
int G_is_initialized(int *)
const char * G_gisbase(void)
Get full path name of the top level module directory.
void G_warning(const char *,...) __attribute__((format(printf
char * G_store(const char *)
Copy string to allocated memory.
int G_get_datum_by_name(const char *name)
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)