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) {
141 if (proj_epsg !=
NULL) {
190 const char *proj_srid,
191 const char *proj_wkt)
201 if (proj_srid !=
NULL) {
206 if (proj_wkt !=
NULL) {
239 const char *proj1, *proj2;
241 if (proj_info1 ==
NULL && proj_info2 ==
NULL)
248 if (proj_info1 ==
NULL || proj_info2 ==
NULL)
254 if (proj1 ==
NULL || proj2 ==
NULL || strcmp(proj1, proj2))
261 if (proj_units1 ==
NULL && proj_units2 ==
NULL)
264 if (proj_units1 ==
NULL || proj_units2 ==
NULL)
268 double a1 = 0, a2 = 0;
275 if (a1 && a2 && (fabs(a2 - a1) > 0.000001))
281 const char *u_1 =
NULL, *u_2 =
NULL;
286 if ((u_1 && !u_2) || (!u_1 && u_2))
303 const char *d_1 =
NULL, *d_2 =
NULL;
308 if ((d_1 && !d_2) || (!d_1 && d_2))
311 if (d_1 && d_2 && strcmp(d_1, d_2)) {
314 G_debug(1,
"Different datum names");
322 const char *e_1 =
NULL, *e_2 =
NULL;
327 if (e_1 && e_2 && strcmp(e_1, e_2))
331 double a1 = 0, a2 = 0;
332 double es1 = 0, es2 = 0;
355 if ((a1 == 0 && a2 != 0) || (a1 != 0 && a2 == 0))
358 if (a1 && a2 && (fabs(a2 - a1) > 0.000001))
361 if ((es1 == 0 && es2 != 0) || (es1 != 0 && es2 == 0))
364 if (es1 && es2 && (fabs(es2 - es1) > 0.000001))
372 if (!strcmp(proj1,
"utm") && !strcmp(proj2,
"utm")
380 if (!strcmp(proj1,
"utm") && !strcmp(proj2,
"utm")
390 const char *x_0_1 =
NULL, *x_0_2 =
NULL;
395 if ((x_0_1 && !x_0_2) || (!x_0_1 && x_0_2))
398 if (x_0_1 && x_0_2 && (fabs(atof(x_0_1) - atof(x_0_2)) > 0.000001))
407 const char *y_0_1 =
NULL, *y_0_2 =
NULL;
412 if ((y_0_1 && !y_0_2) || (!y_0_1 && y_0_2))
415 if (y_0_1 && y_0_2 && (fabs(atof(y_0_1) - atof(y_0_2)) > 0.000001))
424 const char *l_1 =
NULL, *l_2 =
NULL;
429 if ((l_1 && !l_2) || (!l_1 && l_2))
432 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001))
442 if ((l_1 && !l_2) || (!l_1 && l_2))
445 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001))
455 if ((l_1 && !l_2) || (!l_1 && l_2))
458 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
465 if (fabs(atof(l_1) - atof(l_2)) > 0.000001) {
473 if ((l_1 && !l_2) || (!l_1 && l_2))
476 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
483 if (fabs(atof(l_1) - atof(l_2)) > 0.000001) {
519 if (location_name && *location_name)
524 fp = fopen(path,
"w");
527 G_fatal_error(
_(
"Unable to open output file <%s>: %s"), path, strerror(errno));
530 n = strlen(wktstring);
531 if (wktstring[n - 1] !=
'\n') {
532 if (n != fprintf(fp,
"%s\n", wktstring))
536 if (n != fprintf(fp,
"%s", wktstring))
541 G_fatal_error(
_(
"Error closing output file <%s>: %s"), path, strerror(errno));
569 if (location_name && *location_name)
574 fp = fopen(path,
"w");
577 G_fatal_error(
_(
"Unable to open output file <%s>: %s"), path, strerror(errno));
580 n = strlen(sridstring);
581 if (sridstring[n - 1] !=
'\n') {
582 if (n != fprintf(fp,
"%s\n", sridstring))
586 if (n != fprintf(fp,
"%s", sridstring))
591 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.