[GRASS-SVN] r66968 - grass/branches/releasebranch_7_0/general/g.proj

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 28 08:37:56 PST 2015


Author: martinl
Date: 2015-11-28 08:37:56 -0800 (Sat, 28 Nov 2015)
New Revision: 66968

Modified:
   grass/branches/releasebranch_7_0/general/g.proj/local_proto.h
   grass/branches/releasebranch_7_0/general/g.proj/main.c
   grass/branches/releasebranch_7_0/general/g.proj/output.c
Log:
g.proj: don't ignore epsg as parameter when printing info (-p/g)
        (merge r66967 from trunk)


Modified: grass/branches/releasebranch_7_0/general/g.proj/local_proto.h
===================================================================
--- grass/branches/releasebranch_7_0/general/g.proj/local_proto.h	2015-11-28 16:12:56 UTC (rev 66967)
+++ grass/branches/releasebranch_7_0/general/g.proj/local_proto.h	2015-11-28 16:37:56 UTC (rev 66968)
@@ -13,7 +13,7 @@
 #endif
 
 /* output.c */
-void print_projinfo(int);
+void print_projinfo(int, const char *);
 void print_datuminfo(void);
 void print_proj4(int);
 #ifdef HAVE_OGR

Modified: grass/branches/releasebranch_7_0/general/g.proj/main.c
===================================================================
--- grass/branches/releasebranch_7_0/general/g.proj/main.c	2015-11-28 16:12:56 UTC (rev 66967)
+++ grass/branches/releasebranch_7_0/general/g.proj/main.c	2015-11-28 16:37:56 UTC (rev 66968)
@@ -292,7 +292,7 @@
 		      create->key);
 
     if (printinfo->answer || shellinfo->answer)
-	print_projinfo(shellinfo->answer);
+        print_projinfo(shellinfo->answer, epsg);
     else if (datuminfo->answer)
 	print_datuminfo();
     else if (printproj4->answer)

Modified: grass/branches/releasebranch_7_0/general/g.proj/output.c
===================================================================
--- grass/branches/releasebranch_7_0/general/g.proj/output.c	2015-11-28 16:12:56 UTC (rev 66967)
+++ grass/branches/releasebranch_7_0/general/g.proj/output.c	2015-11-28 16:37:56 UTC (rev 66968)
@@ -28,7 +28,7 @@
 
 static int check_xy(int shell);
 
-void print_projinfo(int shell)
+void print_projinfo(int shell, const char *force_epsg)
 {
     int i;
     char path[GPATH_MAX];
@@ -50,20 +50,28 @@
 	the contents of this file are not used by pj_*() routines at all */
     G_file_name(path, "", "PROJ_EPSG", "PERMANENT");
     if (access(path, F_OK) == 0) {
-	struct Key_Value *in_epsg_key;
-	in_epsg_key = G_read_key_value_file(path);
+        const char *epsg_value, *epsg_key;
+        struct Key_Value *in_epsg_key;
+        
+        if (force_epsg) {
+            epsg_key = "epgs";
+            epsg_value = force_epsg;
+        }
+        else {
+            in_epsg_key = G_read_key_value_file(path);
+            epsg_key = in_epsg_key->key[0];
+            epsg_value = in_epsg_key->value[0];
+        }
 	if (!shell) {
 	    fprintf(stdout,
 		"-PROJ_EPSG-------------------------------------------------\n");
-	    fprintf(stdout, "%-11s: %s\n", in_epsg_key->key[0],
-		    in_epsg_key->value[0]);
+	    fprintf(stdout, "%-11s: %s\n", epsg_key, epsg_value);
 	}
 	else
-	    fprintf(stdout, "%s=%s\n", in_epsg_key->key[0],
-		    in_epsg_key->value[0]);
+	    fprintf(stdout, "%s=%s\n", epsg_key, epsg_value);
 
-	if (in_epsg_key != NULL)
-	    G_free_key_value(in_epsg_key);
+        if (!force_epsg)
+            G_free_key_value(in_epsg_key);
     }
  
     if (!shell)



More information about the grass-commit mailing list