[GRASS-SVN] r68137 - grass/branches/releasebranch_7_0/lib/proj

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 24 12:15:36 PDT 2016


Author: mmetz
Date: 2016-03-24 12:15:36 -0700 (Thu, 24 Mar 2016)
New Revision: 68137

Modified:
   grass/branches/releasebranch_7_0/lib/proj/convert.c
Log:
libproj: fix mixing of projection name and coordinate system name (trunk r68131)

Modified: grass/branches/releasebranch_7_0/lib/proj/convert.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/proj/convert.c	2016-03-24 17:31:02 UTC (rev 68136)
+++ grass/branches/releasebranch_7_0/lib/proj/convert.c	2016-03-24 19:15:36 UTC (rev 68137)
@@ -141,6 +141,9 @@
 	return NULL;
     }
     G_free(proj4mod);
+    sysname = G_find_key_value("name", proj_info);
+    if (sysname)
+	OSRSetProjCS(hSRS, sysname);
 
     if ((errcode = OSRExportToWkt(hSRS, &wkt)) != OGRERR_NONE) {
 	G_warning(_("OGR can't get WKT-style parameter string "
@@ -152,7 +155,7 @@
     GPJ__get_ellipsoid_params(proj_info, &a, &es, &rf);
     haveparams = GPJ__get_datum_params(proj_info, &datum, &params);
 
-    if(ellpskv != NULL)
+    if (ellpskv != NULL)
 	ellps = G_store(ellpskv);
     else
 	ellps = NULL;
@@ -278,6 +281,7 @@
     struct Key_Value *temp_projinfo;
     char *pszProj4 = NULL, *pszRemaining;
     char *pszProj = NULL;
+    const char *pszProjCS = NULL;
     char *datum = NULL;
     struct gpj_datum dstruct;
 
@@ -357,14 +361,13 @@
 	else
 	    pszValue = "defined";
 
-
+	/* projection name */
 	if (G_strcasecmp(pszToken, "proj") == 0) {
 	    /* The ll projection is known as longlat in PROJ.4 */
 	    if (G_strcasecmp(pszValue, "longlat") == 0)
 		pszValue = "ll";
 
 	    pszProj = pszValue;
-	    continue;
 	}
 
 	/* Ellipsoid and datum handled separately below */
@@ -383,15 +386,26 @@
 
 	G_set_key_value(pszToken, pszValue, temp_projinfo);
     }
+    if (!pszProj)
+	G_warning(_("No projection name! Projection parameters likely to be meaningless."));
 
     *projinfo = G_create_key_value();
 
     /* -------------------------------------------------------------------- */
-    /*      Derive the user name for the projection.                        */
+    /*      Derive the user name for the coordinate system.                 */
     /* -------------------------------------------------------------------- */
-    if (pszProj) {
+    pszProjCS = OSRGetAttrValue(hSRS, "PROJCS", 0);
+    if (!pszProjCS)
+	pszProjCS = OSRGetAttrValue(hSRS, "GEOGCS", 0);
+
+    if (pszProjCS) {
+	G_set_key_value("name", pszProjCS, *projinfo);
+    }
+    else if (pszProj) {
 	char path[4095];
 	char name[80];
+	
+	/* use name of the projection as name for the coordinate system */
 
 	sprintf(path, "%s/etc/proj/projections", G_gisbase());
 	if (G_lookup_key_value_from_file(path, pszProj, name, sizeof(name)) >
@@ -399,11 +413,7 @@
 	    G_set_key_value("name", name, *projinfo);
 	else
 	    G_set_key_value("name", pszProj, *projinfo);
-
-	G_set_key_value("proj", pszProj, *projinfo);
     }
-    else
-	G_warning(_("No projection name! Projection parameters likely to be meaningless."));
 
 
     /* -------------------------------------------------------------------- */



More information about the grass-commit mailing list