Commit e0d2f255 authored by Paul Ramsey's avatar Paul Ramsey

Only use new geodesics when Proj 4.9 is installed


git-svn-id: http://svn.osgeo.org/postgis/[email protected] b70326c6-7e19-0410-871a-916f4a2858ee
parent 27453e9c
......@@ -92,7 +92,6 @@ SA_OBJS = \
varint.o
NM_OBJS = \
geodesic.o \
lwspheroid.o
ifeq (@[email protected],sfcgal)
......
......@@ -1277,7 +1277,7 @@ static void test_spheroid_distance(void)
{
GEOGRAPHIC_POINT g1, g2;
double d;
#ifdef USE_PRE22GEODESIC
#if ! PROJ_GEODESIC
double epsilon; /* irregular */
#else
const double epsilon = 1e-8; /* at least 10 nm precision */
......@@ -1292,7 +1292,7 @@ static void test_spheroid_distance(void)
point_set(0.0, 0.0, &g1);
point_set(0.0, 1.0, &g2);
d = spheroid_distance(&g1, &g2, &s);
#ifdef USE_PRE22GEODESIC
#if ! PROJ_GEODESIC
epsilon = 1e-6;
#endif
CU_ASSERT_DOUBLE_EQUAL(d, 110574.3885577987957342, epsilon);
......@@ -1302,7 +1302,7 @@ static void test_spheroid_distance(void)
point_set(-10.0, 0.0, &g1);
point_set(0.0, 0.0, &g2);
d = spheroid_distance(&g1, &g2, &s);
#ifdef USE_PRE22GEODESIC
#if ! PROJ_GEODESIC
epsilon = 1e-3;
#endif
CU_ASSERT_DOUBLE_EQUAL(d, 1113194.9079327357264771, epsilon);
......@@ -1312,7 +1312,7 @@ static void test_spheroid_distance(void)
point_set(-1.0, 0.0, &g1);
point_set(0.0, 0.0, &g2);
d = spheroid_distance(&g1, &g2, &s);
#ifdef USE_PRE22GEODESIC
#if ! PROJ_GEODESIC
epsilon = 1e-4;
#endif
CU_ASSERT_DOUBLE_EQUAL(d, 111319.4907932735726477, epsilon);
......@@ -1322,7 +1322,7 @@ static void test_spheroid_distance(void)
point_set(-180.0, 0.0, &g1);
point_set(0.0, 1.0, &g2);
d = spheroid_distance(&g1, &g2, &s);
#ifdef USE_PRE22GEODESIC
#if ! PROJ_GEODESIC
epsilon = 1e-5;
#endif
CU_ASSERT_DOUBLE_EQUAL(d, 19893357.0700676468277450, epsilon);
......@@ -1332,7 +1332,7 @@ static void test_spheroid_distance(void)
point_set(-180.0, 0.0, &g1);
point_set(0.0, 90.0, &g2);
d = spheroid_distance(&g1, &g2, &s);
#ifdef USE_PRE22GEODESIC
#if ! PROJ_GEODESIC
epsilon = 1e-6;
#endif
CU_ASSERT_DOUBLE_EQUAL(d, 10001965.7293127228117396, epsilon);
......@@ -1373,7 +1373,8 @@ static void test_spheroid_area(void)
a1 = lwgeom_area_sphere(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(a1, 12341436880.106982993974659, 0.1);
/* spheroid: Planimeter -E -p 20 -r --input-string "3 -2;4 -2;4 -1;3 -1" */
#ifndef USE_PRE22GEODESIC
#if PROJ_GEODESIC
// printf("XXXXX %d\n", PJ_VERSION);
a2 = lwgeom_area_spheroid(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(a2, 12286884908.946891319597874, 0.1);
#endif
......@@ -1386,7 +1387,7 @@ static void test_spheroid_area(void)
a1 = lwgeom_area_sphere(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(a1, 12360265021.368023059138681, 0.1);
/* spheroid: Planimeter -E -p 20 --input-string "2 8.5;1 8.5;1 9.5;2 9.5" */
#ifndef USE_PRE22GEODESIC
#if PROJ_GEODESIC
a2 = lwgeom_area_spheroid(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(a2, 12305128751.042900673161556, 0.1);
#endif
......@@ -1399,7 +1400,7 @@ static void test_spheroid_area(void)
a1 = lwgeom_area_sphere(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(a1, 12360265021.368023059138681, 0.1);
/* spheroid: Planimeter -E -p 20 -r --input-string "2 179.5;1 179.5;1 178.5;2 178.5" */
#ifndef USE_PRE22GEODESIC
#if PROJ_GEODESIC
a2 = lwgeom_area_spheroid(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(a2, 12305128751.042900673161556, 0.1);
#endif
......@@ -1412,7 +1413,7 @@ static void test_spheroid_area(void)
a1 = lwgeom_area_sphere(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(a1, 12360265021.368023059138681, 0.1);
/* spheroid: Planimeter -E -p 20 --input-string "2 179.5;1 179.5;1 -179.5;2 -179.5" */
#ifndef USE_PRE22GEODESIC
#if PROJ_GEODESIC
a2 = lwgeom_area_spheroid(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(a2, 12305128751.042900673161556, 0.1);
#endif
......
This diff is collapsed.
This diff is collapsed.
......@@ -34,9 +34,15 @@
/* Define to enable pre-version 2.2 geodesic functions for geography types
(e.g. Vincenty for ST_Distance); otherwise use GeographicLib */
#define USE_PRE22GEODESIC
/* #define USE_PRE22GEODESIC */
/* #undef USE_PRE22GEODESIC */
#if defined(PJ_VERSION) && PJ_VERSION >= 490
#define PROJ_GEODESIC 1
#else
#define PROJ_GEODESIC 0
#endif
/**
* Floating point comparators.
*/
......
......@@ -15,7 +15,9 @@
#include "lwgeom_log.h"
/* GeographicLib */
#include "geodesic.h"
#if PROJ_GEODESIC
#include <geodesic.h>
#endif
/**
* Initialize spheroid object based on major and minor axis
......@@ -29,7 +31,7 @@ void spheroid_init(SPHEROID *s, double a, double b)
s->radius = (2.0 * a + b ) / 3.0;
}
#ifdef USE_PRE22GEODESIC
#if ! PROJ_GEODESIC
static double spheroid_mu2(double alpha, const SPHEROID *s)
{
double b2 = POW2(s->b);
......@@ -45,10 +47,10 @@ static double spheroid_big_b(double u2)
{
return (u2 / 1024.0) * (256.0 + u2 * (-128.0 + u2 * (74.0 - 47.0 * u2)));
}
#endif /* def USE_PRE22GEODESIC */
#endif /* ! PROJ_GEODESIC */
#ifndef USE_PRE22GEODESIC
#if PROJ_GEODESIC
/**
* Computes the shortest distance along the surface of the spheroid
......@@ -150,7 +152,7 @@ static double ptarray_area_spheroid(const POINTARRAY *pa, const SPHEROID *sphero
}
/* Above use GeographicLib */
#else /* ndef USE_PRE22GEODESIC */
#else /* ! PROJ_GEODESIC */
/* Below use pre-version 2.2 geodesic functions */
/**
......@@ -614,7 +616,7 @@ static double ptarray_area_spheroid(const POINTARRAY *pa, const SPHEROID *sphero
}
return fabs(area);
}
#endif /* else USE_PRE22GEODESIC */
#endif /* else ! PROJ_GEODESIC */
/**
* Calculate the area of an LWGEOM. Anything except POLYGON, MULTIPOLYGON
......
......@@ -21,6 +21,7 @@ LIBLWGEOM_CFLAGS=-I../../../liblwgeom
LIBGDAL_CFLAGS=@[email protected]
LIBGDAL_LDFLAGS=@[email protected]
PROJ_CFLAGS=@[email protected]
PROJ_LDFLAGS=@[email protected] -lproj
GEOS_CFLAGS=@[email protected]
GEOS_LDFLAGS=@[email protected] -lgeos_c
......@@ -41,6 +42,7 @@ LDFLAGS = \
$(LIBLWGEOM_LDFLAGS) \
$(LIBGDAL_LDFLAGS) \
$(GEOS_LDFLAGS) \
$(PROJ_LDFLAGS) \
-lm \
CUNIT_LDFLAGS=@[email protected]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment