Ver código fonte

g.proj: don't ignore epsg as parameter when printing info (-p/g)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66967 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 anos atrás
pai
commit
a159f76e8e
3 arquivos alterados com 19 adições e 11 exclusões
  1. 1 1
      general/g.proj/local_proto.h
  2. 1 1
      general/g.proj/main.c
  3. 17 9
      general/g.proj/output.c

+ 1 - 1
general/g.proj/local_proto.h

@@ -13,7 +13,7 @@ int input_georef(char *);
 #endif
 
 /* output.c */
-void print_projinfo(int);
+void print_projinfo(int, const char *);
 void print_datuminfo(void);
 void print_proj4(int);
 #ifdef HAVE_OGR

+ 1 - 1
general/g.proj/main.c

@@ -292,7 +292,7 @@ int main(int argc, char *argv[])
 		      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)

+ 17 - 9
general/g.proj/output.c

@@ -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 @@ void print_projinfo(int shell)
 	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)