|
@@ -27,26 +27,37 @@
|
|
|
|
|
|
#include "local_proto.h"
|
|
|
|
|
|
-static int check_xy(void);
|
|
|
+static int check_xy(int shell);
|
|
|
|
|
|
-void print_projinfo(void)
|
|
|
+void print_projinfo(int shell)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
|
- if (check_xy())
|
|
|
+ if (check_xy(shell))
|
|
|
return;
|
|
|
|
|
|
- fprintf(stdout,
|
|
|
- "-PROJ_INFO-------------------------------------------------\n");
|
|
|
- for (i = 0; i < projinfo->nitems; i++)
|
|
|
- fprintf(stdout, "%-11s: %s\n", projinfo->key[i], projinfo->value[i]);
|
|
|
-
|
|
|
- fprintf(stdout,
|
|
|
- "-PROJ_UNITS------------------------------------------------\n");
|
|
|
- for (i = 0; i < projunits->nitems; i++)
|
|
|
- fprintf(stdout, "%-11s: %s\n",
|
|
|
- projunits->key[i], projunits->value[i]);
|
|
|
-
|
|
|
+ if (!shell)
|
|
|
+ fprintf(stdout,
|
|
|
+ "-PROJ_INFO-------------------------------------------------\n");
|
|
|
+ for (i = 0; i < projinfo->nitems; i++) {
|
|
|
+ if (shell)
|
|
|
+ fprintf(stdout, "%s=%s\n", projinfo->key[i], projinfo->value[i]);
|
|
|
+ else
|
|
|
+ fprintf(stdout, "%-11s: %s\n", projinfo->key[i], projinfo->value[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!shell)
|
|
|
+ fprintf(stdout,
|
|
|
+ "-PROJ_UNITS------------------------------------------------\n");
|
|
|
+ for (i = 0; i < projunits->nitems; i++) {
|
|
|
+ if (shell)
|
|
|
+ fprintf(stdout, "%s=%s\n",
|
|
|
+ projunits->key[i], projunits->value[i]);
|
|
|
+ else
|
|
|
+ fprintf(stdout, "%-11s: %s\n",
|
|
|
+ projunits->key[i], projunits->value[i]);
|
|
|
+ }
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -56,7 +67,7 @@ void print_datuminfo(void)
|
|
|
struct gpj_datum dstruct;
|
|
|
int validdatum = 0;
|
|
|
|
|
|
- if (check_xy())
|
|
|
+ if (check_xy(FALSE))
|
|
|
return;
|
|
|
|
|
|
GPJ__get_datum_params(projinfo, &datum, ¶ms);
|
|
@@ -100,7 +111,7 @@ void print_proj4(int dontprettify)
|
|
|
char *proj4, *proj4mod, *i;
|
|
|
const char *unfact;
|
|
|
|
|
|
- if (check_xy())
|
|
|
+ if (check_xy(FALSE))
|
|
|
return;
|
|
|
|
|
|
pj_get_kv(&pjinfo, projinfo, projunits);
|
|
@@ -137,7 +148,7 @@ void print_wkt(int esristyle, int dontprettify)
|
|
|
{
|
|
|
char *outwkt;
|
|
|
|
|
|
- if (check_xy())
|
|
|
+ if (check_xy(FALSE))
|
|
|
return;
|
|
|
|
|
|
outwkt = GPJ_grass_to_wkt(projinfo, projunits, esristyle,
|
|
@@ -160,12 +171,12 @@ void create_location(char *location)
|
|
|
if (location) {
|
|
|
ret = G__make_location(location, &cellhd, projinfo, projunits, NULL);
|
|
|
if (ret == 0)
|
|
|
- G_message(_("Location %s created!"), location);
|
|
|
+ G_message(_("Location <%s> created"), location);
|
|
|
else if (ret == -1)
|
|
|
- G_fatal_error(_("Unable to create location: %s"),
|
|
|
- strerror(errno));
|
|
|
+ G_fatal_error(_("Unable to create location <%s>: %s"),
|
|
|
+ location, strerror(errno));
|
|
|
else if (ret == -2)
|
|
|
- G_fatal_error(_("Unable to create projection files: %s"),
|
|
|
+ G_fatal_error(_("Unable to create projection files: %s"),
|
|
|
strerror(errno));
|
|
|
else
|
|
|
/* Shouldn't happen */
|
|
@@ -176,7 +187,6 @@ void create_location(char *location)
|
|
|
* projection files for current location */
|
|
|
|
|
|
const char *mapset = G_mapset();
|
|
|
- struct Key_Value *old_projinfo = NULL, *old_projunits = NULL;
|
|
|
struct Cell_head old_cellhd;
|
|
|
|
|
|
if (strcmp(mapset, "PERMANENT") != 0)
|
|
@@ -186,46 +196,41 @@ void create_location(char *location)
|
|
|
|
|
|
/* Read projection information from current location first */
|
|
|
G_get_default_window(&old_cellhd);
|
|
|
-
|
|
|
- if (old_cellhd.proj != PROJECTION_XY) {
|
|
|
- old_projinfo = G_get_projinfo();
|
|
|
- old_projunits = G_get_projunits();
|
|
|
+
|
|
|
+ char path[GPATH_MAX];
|
|
|
+
|
|
|
+ /* Write out the PROJ_INFO, and PROJ_UNITS if available. */
|
|
|
+ if (projinfo != NULL) {
|
|
|
+ G_file_name(path, "", "PROJ_INFO", "PERMANENT");
|
|
|
+ G_write_key_value_file(path, projinfo);
|
|
|
}
|
|
|
-
|
|
|
- {
|
|
|
- char path[GPATH_MAX];
|
|
|
-
|
|
|
- /* Write out the PROJ_INFO, and PROJ_UNITS if available. */
|
|
|
- if (projinfo != NULL) {
|
|
|
- G_file_name(path, "", "PROJ_INFO", "PERMANENT");
|
|
|
- G_write_key_value_file(path, projinfo);
|
|
|
- }
|
|
|
-
|
|
|
- if (projunits != NULL) {
|
|
|
- G_file_name(path, "", "PROJ_UNITS", "PERMANENT");
|
|
|
- G_write_key_value_file(path, projunits);
|
|
|
- }
|
|
|
-
|
|
|
- if ((old_cellhd.zone != cellhd.zone) ||
|
|
|
- (old_cellhd.proj != cellhd.proj)) {
|
|
|
- /* Recreate the default, and current window files if projection
|
|
|
- * number or zone have changed */
|
|
|
- G__put_window(&cellhd, "", "DEFAULT_WIND");
|
|
|
+
|
|
|
+ if (projunits != NULL) {
|
|
|
+ G_file_name(path, "", "PROJ_UNITS", "PERMANENT");
|
|
|
+ G_write_key_value_file(path, projunits);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((old_cellhd.zone != cellhd.zone) ||
|
|
|
+ (old_cellhd.proj != cellhd.proj)) {
|
|
|
+ /* Recreate the default, and current window files if projection
|
|
|
+ * number or zone have changed */
|
|
|
+ G__put_window(&cellhd, "", "DEFAULT_WIND");
|
|
|
G__put_window(&cellhd, "", "WIND");
|
|
|
G_message(_("N.B. The default region was updated to the new projection, but if you have "
|
|
|
- "multiple mapsets g.region -d should be run in each to update the region from "
|
|
|
- "the default."));
|
|
|
- }
|
|
|
- G_message(_("Projection information updated!"));
|
|
|
+ "multiple mapsets g.region -d should be run in each to update the region from "
|
|
|
+ "the default."));
|
|
|
}
|
|
|
+ G_message(_("Projection information updated!"));
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-static int check_xy(void)
|
|
|
+static int check_xy(int shell)
|
|
|
{
|
|
|
if (cellhd.proj == PROJECTION_XY) {
|
|
|
+ if (shell)
|
|
|
+ fprintf(stdout, "name=");
|
|
|
fprintf(stdout, "XY location (unprojected)\n");
|
|
|
return 1;
|
|
|
}
|