]> granicus.if.org Git - postgis/commitdiff
Prepare for Proj4.8 with spheroid info handling
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 16 Feb 2012 00:25:48 +0000 (00:25 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 16 Feb 2012 00:25:48 +0000 (00:25 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9214 b70326c6-7e19-0410-871a-916f4a2858ee

libpgcommon/lwgeom_transform.c

index 9cd7778015752282d7e9ec98b7273a2d7c511006..91fdf7e51b6ba8c3f04e252be61e2b5df38c07a2 100644 (file)
@@ -710,8 +710,8 @@ GetProjectionsUsingFCInfo(FunctionCallInfo fcinfo, int srid1, int srid2, projPJ
 int 
 spheroid_init_from_srid(FunctionCallInfo fcinfo, int srid, SPHEROID *s)
 {
-       projPJ pj1;
-       projPJ pj2;
+       projPJ pj1, pj2;
+       double major_axis, minor_axis, eccentricity_squared;
        
        if ( GetProjectionsUsingFCInfo(fcinfo, srid, srid, &pj1, &pj2) == LW_FAILURE)
                return LW_FAILURE;
@@ -723,7 +723,9 @@ spheroid_init_from_srid(FunctionCallInfo fcinfo, int srid, SPHEROID *s)
        /* For newer versions of Proj we can pull the spheroid paramaeters and initialize */
        /* using them */
        /* TODO actually implement this using the API function when it exists */
-       spheroid_init(s, WGS84_MAJOR_AXIS, WGS84_MINOR_AXIS);   
+       pj_get_spheroid_defn(pj1, &major_axis, &eccentricity_squared);
+       minor_axis = major_axis * sqrt(1-eccentricity_squared);
+       spheroid_init(s, major_axis, minor_axis);       
 #else
        /* For old versions of Proj we cannot lookup the spheroid parameters from the API */
        /* So we use the WGS84 parameters (boo!) */