]> granicus.if.org Git - postgis/commitdiff
Stop relying on private projects.h PROJ header (#1541)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 8 Feb 2012 18:51:32 +0000 (18:51 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 8 Feb 2012 18:51:32 +0000 (18:51 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9108 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/liblwgeom.h.in
liblwgeom/liblwgeom_internal.h
libpgcommon/lwgeom_transform.c
postgis/geography.h

index a5dfad1415b2ebb04154173426345193e9a2ff38..05162a3a6299bac00d0154c5cc8ecbe2913c9cfd 100644 (file)
@@ -19,7 +19,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdint.h>
-#include "projects.h"
 #include "proj_api.h"
 
 /**
 #define WKBSRIDFLAG 0x20000000
 #define WKBBBOXFLAG 0x10000000
 
+/**********************************************************************
+** Spherical radius.
+** Moritz, H. (1980). Geodetic Reference System 1980, by resolution of 
+** the XVII General Assembly of the IUGG in Canberra.
+** http://en.wikipedia.org/wiki/Earth_radius
+** http://en.wikipedia.org/wiki/World_Geodetic_System
+*/
+
+#define WGS84_MAJOR_AXIS 6378137.0
+#define WGS84_INVERSE_FLATTENING 298.257223563
+#define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
+#define WGS84_RADIUS ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
+
+
 /**
 * Macros for manipulating the 'flags' byte. A uint8_t used as follows: 
 * ---RGBMZ
index 4816463013374e897fb3694fca82922a16e09813..a7a5579f3f35a9260233e79d3df8833487f22f5a 100644 (file)
@@ -34,7 +34,8 @@
 /**
 * PI
 */
-#define LW_PI 3.1415926535897932384626433832795
+#define PI 3.1415926535897932384626433832795
+
 
 /**
 * Floating point comparitors.
index 706b2f80e7e7d1fd75bbb1188721178724026939..cb7545a29aa2e370b0c117b554f73fe6ff2b84b4 100644 (file)
@@ -714,29 +714,23 @@ spheroid_init_from_srid(FunctionCallInfo fcinfo, int srid, SPHEROID *s)
 {
        projPJ pj1;
        projPJ pj2;
-       PJ *p;
        
        if ( GetProjectionsUsingFCInfo(fcinfo, srid, srid, &pj1, &pj2) == LW_FAILURE)
                return LW_FAILURE;
                
        if ( ! pj_is_latlong(pj1) )
                return LW_FAILURE;
-       
-       /* Get the proj string 
-       char *proj_str;
-       proj_str = pj_get_def(pj1, 0);
-       POSTGIS_DEBUGF(4, "proj_str = %s", proj_str);
-       */
-       
-       /* Get access to the proj internals */  
-       p = (PJ*)pj1;
-       
-       /* Initialize */
-       s->a = p->a;
-       s->e_sq = p->es;
-       s->b = s->a * sqrt(p->one_es);
-       s->f = (s->a - s->b) / s->a;
-       s->radius = (2.0 * s->a + s->b ) / 3.0;
+
+#if POSTGIS_PROJ_VERSION >= 48
+       /* 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);   
+#else
+       /* For old versions of Proj we cannot lookup the spheroid parameters from the API */
+       /* So we use the WGS84 parameters (boo!) */
+       spheroid_init(s, WGS84_MAJOR_AXIS, WGS84_MINOR_AXIS);
+#endif
 
        return LW_SUCCESS;
 }
index cf07dd4fa47ec04069cf6571ad51b6f680c09339..5b777702aa4ad5ed60c372bc821e9249c63e86d7 100644 (file)
  **********************************************************************/
 
 
-/**********************************************************************
-** Spherical radius.
-** Moritz, H. (1980). Geodetic Reference System 1980, by resolution of 
-** the XVII General Assembly of the IUGG in Canberra.
-** http://en.wikipedia.org/wiki/Earth_radius
-** http://en.wikipedia.org/wiki/World_Geodetic_System
-*/
-
-#define WGS84_MAJOR_AXIS 6378137.0
-#define WGS84_INVERSE_FLATTENING 298.257223563
-#define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
-#define WGS84_RADIUS ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
-
 /**********************************************************************
 **  Useful functions for all GSERIALIZED handlers. 
 **  TODO: Move to common.h in pgcommon