17 #include <grass/gis.h> 52 struct Cell_head *wind,
53 const struct Key_Value *proj_info,
54 const struct Key_Value *proj_units)
63 sprintf(path,
"%s/%s",
G_gisdbase(), location_name);
68 sprintf(path,
"%s/%s/%s",
G_gisdbase(), location_name,
"PERMANENT");
82 if (proj_info !=
NULL) {
87 if (proj_units !=
NULL) {
117 const struct Key_Value *proj_units1,
118 const struct Key_Value *proj_info2,
119 const struct Key_Value *proj_units2)
121 const char *proj1, *proj2;
123 if (proj_info1 ==
NULL && proj_info2 ==
NULL)
130 if (proj_info1 ==
NULL || proj_info2 ==
NULL)
136 if (proj1 ==
NULL || proj2 ==
NULL || strcmp(proj1, proj2))
143 if (proj_units1 ==
NULL && proj_units2 ==
NULL)
146 if (proj_units1 ==
NULL || proj_units2 ==
NULL)
150 double a1 = 0, a2 = 0;
157 if (a1 && a2 && (fabs(a2 - a1) > 0.000001))
163 const char *u_1 =
NULL, *u_2 =
NULL;
168 if ((u_1 && !u_2) || (!u_1 && u_2))
185 const char *d_1 =
NULL, *d_2 =
NULL;
190 if ((d_1 && !d_2) || (!d_1 && d_2))
193 if (d_1 && d_2 && strcmp(d_1, d_2)) {
196 G_debug(1,
"Different datum names");
204 const char *e_1 =
NULL, *e_2 =
NULL;
209 if (e_1 && e_2 && strcmp(e_1, e_2))
213 double a1 = 0, a2 = 0;
214 double es1 = 0, es2 = 0;
237 if ((a1 == 0 && a2 != 0) || (a1 != 0 && a2 == 0))
240 if (a1 && a2 && (fabs(a2 - a1) > 0.000001))
243 if ((es1 == 0 && es2 != 0) || (es1 != 0 && es2 == 0))
246 if (es1 && es2 && (fabs(es2 - es1) > 0.000001))
254 if (!strcmp(proj1,
"utm") && !strcmp(proj2,
"utm")
262 if (!strcmp(proj1,
"utm") && !strcmp(proj2,
"utm")
272 const char *x_0_1 =
NULL, *x_0_2 =
NULL;
277 if ((x_0_1 && !x_0_2) || (!x_0_1 && x_0_2))
280 if (x_0_1 && x_0_2 && (fabs(atof(x_0_1) - atof(x_0_2)) > 0.000001))
289 const char *y_0_1 =
NULL, *y_0_2 =
NULL;
294 if ((y_0_1 && !y_0_2) || (!y_0_1 && y_0_2))
297 if (y_0_1 && y_0_2 && (fabs(atof(y_0_1) - atof(y_0_2)) > 0.000001))
306 const char *l_1 =
NULL, *l_2 =
NULL;
311 if ((l_1 && !l_2) || (!l_1 && l_2))
314 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001))
325 if ((l_1 && !l_2) || (!l_1 && l_2))
328 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001))
339 if ((l_1 && !l_2) || (!l_1 && l_2))
342 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
349 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
358 if ((l_1 && !l_2) || (!l_1 && l_2))
361 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
368 if (l_1 && l_2 && (fabs(atof(l_1) - atof(l_2)) > 0.000001)) {
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
const char * G_find_key_value(const char *key, const struct Key_Value *kv)
Find given key (case sensitive)
int G_mkdir(const char *path)
Creates a new 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.
void G_write_key_value_file(const char *file, const struct Key_Value *kv)
Write key/value pairs to file.
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_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)
int G_put_element_window(const struct Cell_head *window, const char *dir, const char *name)
Write the region.
int G_get_ellipsoid_by_name(const char *name, double *a, double *e2)
Get ellipsoid parameters by name.
const char * G_gisdbase(void)
Get name of top level database directory.
int G_legal_filename(const char *s)
Check for legal database file name.
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.