PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_spheroid_distance ( void  )
static

Definition at line 1240 of file cu_geodetic.c.

References point_set(), s, spheroid_distance(), and spheroid_init().

Referenced by geodetic_suite_setup().

1241 {
1242  GEOGRAPHIC_POINT g1, g2;
1243  double d;
1244  SPHEROID s;
1245 
1246  /* Init to WGS84 */
1247  spheroid_init(&s, 6378137.0, 6356752.314245179498);
1248 
1249  /* One vertical degree */
1250  point_set(0.0, 0.0, &g1);
1251  point_set(0.0, 1.0, &g2);
1252  d = spheroid_distance(&g1, &g2, &s);
1253  CU_ASSERT_DOUBLE_EQUAL(d, 110574.388615329, 0.001);
1254 
1255  /* Ten horizontal degrees */
1256  point_set(-10.0, 0.0, &g1);
1257  point_set(0.0, 0.0, &g2);
1258  d = spheroid_distance(&g1, &g2, &s);
1259  CU_ASSERT_DOUBLE_EQUAL(d, 1113194.90793274, 0.001);
1260 
1261  /* One horizonal degree */
1262  point_set(-1.0, 0.0, &g1);
1263  point_set(0.0, 0.0, &g2);
1264  d = spheroid_distance(&g1, &g2, &s);
1265  CU_ASSERT_DOUBLE_EQUAL(d, 111319.490779, 0.001);
1266 
1267  /* Around world w/ slight bend */
1268  point_set(-180.0, 0.0, &g1);
1269  point_set(0.0, 1.0, &g2);
1270  d = spheroid_distance(&g1, &g2, &s);
1271  CU_ASSERT_DOUBLE_EQUAL(d, 19893357.0704483, 0.001);
1272 
1273  /* Up to pole */
1274  point_set(-180.0, 0.0, &g1);
1275  point_set(0.0, 90.0, &g2);
1276  d = spheroid_distance(&g1, &g2, &s);
1277  CU_ASSERT_DOUBLE_EQUAL(d, 10001965.7295318, 0.001);
1278 
1279 }
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:20
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:33
char * s
Definition: cu_in_wkt.c:24
static void point_set(double lon, double lat, GEOGRAPHIC_POINT *p)
Definition: cu_geodetic.c:336
double spheroid_distance(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const SPHEROID *spheroid)
Computes the shortest distance along the surface of the spheroid between two points.
Definition: lwspheroid.c:59

Here is the call graph for this function:

Here is the caller graph for this function: