[GRASS-SVN] r74192 - in grass/trunk: general/g.proj lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 8 11:31:28 PST 2019


Author: mmetz
Date: 2019-03-08 11:31:28 -0800 (Fri, 08 Mar 2019)
New Revision: 74192

Modified:
   grass/trunk/general/g.proj/output.c
   grass/trunk/lib/gis/get_projinfo.c
Log:
libgis: get srid for proj_create_crs_to_crs()

Modified: grass/trunk/general/g.proj/output.c
===================================================================
--- grass/trunk/general/g.proj/output.c	2019-03-08 19:29:27 UTC (rev 74191)
+++ grass/trunk/general/g.proj/output.c	2019-03-08 19:31:28 UTC (rev 74192)
@@ -39,6 +39,8 @@
 	fprintf(stdout,
 		"-PROJ_INFO-------------------------------------------------\n");
     for (i = 0; i < projinfo->nitems; i++) {
+	if (strcmp(projinfo->key[i], "init") == 0)
+	    continue;
 	if (shell)
 	    fprintf(stdout, "%s=%s\n", projinfo->key[i], projinfo->value[i]);
 	else

Modified: grass/trunk/lib/gis/get_projinfo.c
===================================================================
--- grass/trunk/lib/gis/get_projinfo.c	2019-03-08 19:29:27 UTC (rev 74191)
+++ grass/trunk/lib/gis/get_projinfo.c	2019-03-08 19:31:28 UTC (rev 74192)
@@ -10,6 +10,7 @@
 */
 
 #include <unistd.h>
+#include <stdio.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
@@ -57,7 +58,7 @@
 */
 struct Key_Value *G_get_projinfo(void)
 {
-    struct Key_Value *in_proj_keys;
+    struct Key_Value *in_proj_keys, *in_epsg_keys;
     char path[GPATH_MAX];
 
     G_file_name(path, "", PROJECTION_FILE, PERMANENT);
@@ -69,6 +70,16 @@
 	return NULL;
     }
     in_proj_keys = G_read_key_value_file(path);
+    
+    /* TODO: do not restrict to EPSG as the only authority */
+    if ((in_epsg_keys = G_get_projepsg()) != NULL) {
+	const char *epsgstr = G_find_key_value("epsg", in_epsg_keys);
+	char buf[4096];
+	
+	sprintf(buf, "EPSG:%s", epsgstr);
+	G_set_key_value("init", buf, in_proj_keys);
+	G_free_key_value(in_epsg_keys);
+    }
 
     return in_proj_keys;
 }
@@ -80,7 +91,7 @@
   G_free_key_value().
   
   \return pointer to Key_Value structure with key/value pairs
-  \return NULL when EPSG code is defined for location
+  \return NULL when EPSG code is not defined for location
 */
 struct Key_Value *G_get_projepsg(void)
 {



More information about the grass-commit mailing list