65 sprintf(path,
"%s/%s",
G_gisdbase(), location_name);
70 sprintf(path,
"%s/%s/%s",
G_gisdbase(), location_name,
"PERMANENT");
84 if (proj_info !=
NULL) {
89 if (proj_units !=
NULL) {
142 if (proj_epsg !=
NULL) {
190 const char *proj_srid,
191 const char *proj_wkt)
202 if (proj_srid !=
NULL) {
207 if (proj_wkt !=
NULL) {
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)) {
523 if (location_name && *location_name)
528 fp = fopen(path,
"w");
531 G_fatal_error(
_(
"Unable to open output file <%s>: %s"), path, strerror(errno));
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))
545 G_fatal_error(
_(
"Error closing output file <%s>: %s"), path, strerror(errno));
573 if (location_name && *location_name)
578 fp = fopen(path,
"w");
581 G_fatal_error(
_(
"Unable to open output file <%s>: %s"), path, strerror(errno));
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))
595 G_fatal_error(
_(
"Error closing output file <%s>: %s"), path, strerror(errno));
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_setenv_nogisrc(const char *, const char *)
Set environment name to value (doesn't update .gisrc)
2D/3D raster map header (used also for region)
const char * G_gisdbase(void)
Get name of top level database directory.
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.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
int G_get_ellipsoid_by_name(const char *, double *, double *)
Get ellipsoid parameters by name.
int G_legal_filename(const char *)
Check for legal database file name.
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_write_projsrid(const char *location_name, const char *sridstring)
Write srid (spatial reference id) to file.
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_put_element_window(const struct Cell_head *, const char *, const char *)
Write the region.
void G_write_key_value_file(const char *, const struct Key_Value *)
Write key/value pairs to file.
int G_mkdir(const char *)
Creates a new directory.
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_debug(int, const char *,...) __attribute__((format(printf
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
int G_write_projwkt(const char *location_name, const char *wktstring)
Write WKT definition to file.