[GRASS-SVN] r71622 - grass/trunk/lib/proj

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Oct 31 13:59:38 PDT 2017


Author: mmetz
Date: 2017-10-31 13:59:38 -0700 (Tue, 31 Oct 2017)
New Revision: 71622

Modified:
   grass/trunk/lib/proj/convert.c
Log:
projlib: improve creating new spatial reference from embedded proj4 definition

Modified: grass/trunk/lib/proj/convert.c
===================================================================
--- grass/trunk/lib/proj/convert.c	2017-10-31 19:46:44 UTC (rev 71621)
+++ grass/trunk/lib/proj/convert.c	2017-10-31 20:59:38 UTC (rev 71622)
@@ -419,16 +419,17 @@
 	    char *proj4ext;
 	    OGRSpatialReferenceH hSRS2;
 
-	    proj4ext = G_store(ograttr);
 	    hSRS2 = OSRNewSpatialReference(NULL);
+	    proj4ext = G_store(ograttr);
+
 	    /* test */
 	    if (OSRImportFromProj4(hSRS2, proj4ext) != OGRERR_NONE) {
 		G_warning(_("Updating spatial reference with embedded proj4 definition failed. "
 		            "Proj4 definition: <%s>"), proj4ext);
+		OSRDestroySpatialReference(hSRS2);
 	    }
 	    else {
-		OSRDestroySpatialReference(hSRS2);
-		/* update OGR spatial reference with proj4 string */
+		/* use new OGR spatial reference defined with embedded proj4 string */
 		/* TODO: replace warning with important_message once confirmed working */
 		G_warning(_("Updating spatial reference with embedded proj4 definition"));
 
@@ -456,10 +457,8 @@
 			G_set_key_value("name", pszProj, *projinfo);
 		}
 
-		hSRS = OSRNewSpatialReference(NULL);
-		if (OSRImportFromProj4(hSRS, proj4ext) != OGRERR_NONE) {
-		    G_fatal_error(_("Can't parse PROJ.4-style parameter string"));
-		}
+		/* the original hSRS1 is left as is, ok? */
+		hSRS = hSRS2;
 	    }
 	    G_free(proj4ext);
 	}



More information about the grass-commit mailing list