17 #include <grass/gis.h>
25 #include <grass/glocale.h>
54 struct Cell_head *wind,
55 const struct Key_Value *proj_info,
56 const struct Key_Value *proj_units)
70 sprintf(
path,
"%s/%s/%s",
G_gisdbase(), location_name,
"PERMANENT");
84 if (proj_info !=
NULL) {
89 if (proj_units !=
NULL) {
128 struct Cell_head *wind,
129 const struct Key_Value *proj_info,
130 const struct Key_Value *proj_units,
131 const struct Key_Value *proj_epsg)
134 char path[GPATH_MAX];
142 if (proj_epsg !=
NULL) {
187 struct Cell_head *wind,
188 const struct Key_Value *proj_info,
189 const struct Key_Value *proj_units,
190 const char *proj_srid,
191 const char *proj_wkt)
194 char path[GPATH_MAX];
202 if (proj_srid !=
NULL) {
207 if (proj_wkt !=
NULL) {
236 const struct Key_Value *proj_units1,
237 const struct Key_Value *proj_info2,
238 const struct Key_Value *proj_units2)
240 const char *proj1, *proj2;
242 if (proj_info1 ==
NULL && proj_info2 ==
NULL)
249 if (proj_info1 ==
NULL || proj_info2 ==
NULL)
255 if (proj1 ==
NULL || proj2 ==
NULL || strcmp(proj1, proj2))
262 if (proj_units1 ==
NULL && proj_units2 ==
NULL)
265 if (proj_units1 ==
NULL || proj_units2 ==
NULL)
269 double a1 = 0, a2 = 0;
276 if (a1 && a2 && (fabs(a2 - a1) > 0.000001))
282 const char *u_1 =
NULL, *u_2 =
NULL;
287 if ((u_1 && !u_2) || (!u_1 && u_2))
304 const char *d_1 =
NULL, *d_2 =
NULL;
309 if ((d_1 && !d_2) || (!d_1 && d_2))
312 if (d_1 && d_2 && strcmp(d_1, d_2)) {
315 G_debug(1,
"Different datum names");
323 const char *e_1 =
NULL, *e_2 =
NULL;
328 if (e_1 && e_2 && strcmp(e_1, e_2))
332 double a1 = 0, a2 = 0;
333 double es1 = 0, es2 = 0;
356 if ((a1 == 0 && a2 != 0) || (a1 != 0 && a2 == 0))
359 if (a1 && a2 && (fabs(a2 - a1) > 0.000001))
362 if ((es1 == 0 && es2 != 0) || (es1 != 0 && es2 == 0))
365 if (es1 && es2 && (fabs(es2 - es1) > 0.000001))
373 if (!strcmp(proj1,
"utm") && !strcmp(proj2,
"utm")
381 if (!strcmp(proj1,
"utm") && !strcmp(proj2,
"utm")
391 const char *x_0_1 =
NULL, *x_0_2 =
NULL;
396 if ((x_0_1 && !x_0_2) || (!x_0_1 && x_0_2))
399 if (x_0_1 && x_0_2 && (fabs(atof(x_0_1) - atof(x_0_2)) > 0.000001))
408 const char *y_0_1 =
NULL, *y_0_2 =
NULL;
413 if ((y_0_1 && !y_0_2) || (!y_0_1 && y_0_2))
416 if (y_0_1 && y_0_2 && (fabs(atof(y_0_1) - atof(y_0_2)) > 0.000001))
425 const char *l_1 =
NULL, *l_2 =
NULL;
430 if ((l_1 && !l_2) || (!l_1 && l_2))
433 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001))
444 if ((l_1 && !l_2) || (!l_1 && l_2))
447 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001))
458 if ((l_1 && !l_2) || (!l_1 && l_2))
461 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
468 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
477 if ((l_1 && !l_2) || (!l_1 && l_2))
480 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
487 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
517 char path[GPATH_MAX];
523 if (location_name && *location_name)
524 sprintf(
path,
"%s/%s/%s/%s",
G_gisdbase(), location_name,
"PERMANENT", WKT_FILE);
528 fp = fopen(
path,
"w");
534 n = strlen(wktstring);
535 if (wktstring[n - 1] !=
'\n') {
536 if (n != fprintf(fp,
"%s\n", wktstring))
540 if (n != fprintf(fp,
"%s", wktstring))
567 char path[GPATH_MAX];
573 if (location_name && *location_name)
574 sprintf(
path,
"%s/%s/%s/%s",
G_gisdbase(), location_name,
"PERMANENT", SRID_FILE);
578 fp = fopen(
path,
"w");
584 n = strlen(sridstring);
585 if (sridstring[n - 1] !=
'\n') {
586 if (n != fprintf(fp,
"%s\n", sridstring))
590 if (n != fprintf(fp,
"%s", sridstring))
int G_debug(int level, const char *msg,...)
Print debugging message.
void G_setenv_nogisrc(const char *name, const char *value)
Set environment name to value (doesn't update .gisrc)
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
int G_get_ellipsoid_by_name(const char *name, double *a, double *e2)
Get ellipsoid parameters by name.
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
const char * G_gisdbase(void)
Get name of top level database directory.
const char * G_find_key_value(const char *key, const struct Key_Value *kv)
Find given key (case sensitive)
void G_write_key_value_file(const char *file, const struct Key_Value *kv)
Write key/value pairs to file.
int G_legal_filename(const char *s)
Check for legal database file name.
int G_make_location_crs(const char *location_name, struct Cell_head *wind, const struct Key_Value *proj_info, const struct Key_Value *proj_units, const char *proj_srid, const char *proj_wkt)
Create a new location.
int G_write_projsrid(const char *location_name, const char *sridstring)
Write srid (spatial reference id) to file.
int G_write_projwkt(const char *location_name, const char *wktstring)
Write WKT definition to file.
int G_compare_projections(const struct Key_Value *proj_info1, const struct Key_Value *proj_units1, const struct Key_Value *proj_info2, const struct Key_Value *proj_units2)
Compare projections including units.
int G_make_location(const char *location_name, struct Cell_head *wind, const struct Key_Value *proj_info, const struct Key_Value *proj_units)
Create a new location.
int G_make_location_epsg(const char *location_name, struct Cell_head *wind, const struct Key_Value *proj_info, const struct Key_Value *proj_units, const struct Key_Value *proj_epsg)
Create a new location.
int G_mkdir(const char *path)
Creates a new directory.
int G_put_element_window(const struct Cell_head *window, const char *dir, const char *name)
Write the region.
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)