17 #define DATUMTABLE "/etc/proj/datum.table"
41 static int compare_table_names(
const void *,
const void *);
49 for (i = 0; i < table.count; i++)
60 if (n < 0 || n >= table.count)
63 return table.datums[n].name;
70 if (n < 0 || n >= table.count)
73 return table.datums[n].descr;
80 if (n < 0 || n >= table.count)
83 return table.datums[n].ellps;
108 char *datumname,
char *params)
153 fd = fopen(
file,
"r");
160 for (line = 1;
G_getl2(buf,
sizeof(buf), fd); line++) {
161 char name[100], descr[100], ellps[100];
165 if (*buf ==
'\0' || *buf ==
'#')
168 if (table.count >= table.size) {
171 G_realloc(table.datums, table.size *
sizeof(
struct datum));
174 t = &table.datums[table.count];
176 if (sscanf(buf,
"%s \"%99[^\"]\" %s dx=%lf dy=%lf dz=%lf",
name, descr,
177 ellps, &
t->dx, &
t->dy, &
t->dz) != 6) {
178 G_warning(
_(
"error in datum table file, line %d"), line);
189 qsort(table.datums, table.count,
sizeof(
struct datum), compare_table_names);
194 static int compare_table_names(
const void *aa,
const void *bb)
196 const struct datum *a = aa;
197 const struct datum *
b = bb;
int G_getl2(char *, int, FILE *)
Gets a line of text from a file of any pedigree.
void G_warning(const char *,...) __attribute__((format(printf
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
void G_strip(char *)
Removes all leading and trailing white space from string.
int G_is_initialized(int *)
void G_initialize_done(int *)
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
const char * G_gisbase(void)
Get full path name of the top level module directory.
char * G_store(const char *)
Copy string to allocated memory.
const char * G_datum_name(int n)
int G_get_datumparams_from_projinfo(const struct Key_Value *projinfo, char *datumname, char *params)
const char * G_datum_description(int n)
const char * G_datum_ellipsoid(int n)
int G_get_datum_by_name(const char *name)
void G_read_datum_table(void)