PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ test_spheroid_distance()

static void test_spheroid_distance ( void  )
static

Definition at line 1269 of file cu_geodetic.c.

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

Referenced by geodetic_suite_setup().

1270 {
1271  GEOGRAPHIC_POINT g1, g2;
1272  double d;
1273 #if ! PROJ_GEODESIC
1274  double epsilon; /* irregular */
1275 #else
1276  const double epsilon = 1e-8; /* at least 10 nm precision */
1277 #endif
1278  SPHEROID s;
1279 
1280  /* Init to WGS84 */
1281  spheroid_init(&s, 6378137.0, 6356752.314245179498);
1282 
1283  /* One vertical degree
1284  $ GeodSolve -E -i -p 16 --input-string "0 0 1 0" */
1285  point_set(0.0, 0.0, &g1);
1286  point_set(0.0, 1.0, &g2);
1287  d = spheroid_distance(&g1, &g2, &s);
1288 #if ! PROJ_GEODESIC
1289  epsilon = 1e-6;
1290 #endif
1291  CU_ASSERT_DOUBLE_EQUAL(d, 110574.3885577987957342, epsilon);
1292 
1293  /* Ten horizontal degrees
1294  $ GeodSolve -E -i -p 16 --input-string "0 -10 0 0" */
1295  point_set(-10.0, 0.0, &g1);
1296  point_set(0.0, 0.0, &g2);
1297  d = spheroid_distance(&g1, &g2, &s);
1298 #if ! PROJ_GEODESIC
1299  epsilon = 1e-3;
1300 #endif
1301  CU_ASSERT_DOUBLE_EQUAL(d, 1113194.9079327357264771, epsilon);
1302 
1303  /* One horizonal degree
1304  $ GeodSolve -E -i -p 16 --input-string "0 -1 0 0" */
1305  point_set(-1.0, 0.0, &g1);
1306  point_set(0.0, 0.0, &g2);
1307  d = spheroid_distance(&g1, &g2, &s);
1308 #if ! PROJ_GEODESIC
1309  epsilon = 1e-4;
1310 #endif
1311  CU_ASSERT_DOUBLE_EQUAL(d, 111319.4907932735726477, epsilon);
1312 
1313  /* Around world w/ slight bend
1314  $ GeodSolve -E -i -p 16 --input-string "0 -180 1 0" */
1315  point_set(-180.0, 0.0, &g1);
1316  point_set(0.0, 1.0, &g2);
1317  d = spheroid_distance(&g1, &g2, &s);
1318 #if ! PROJ_GEODESIC
1319  epsilon = 1e-5;
1320 #endif
1321  CU_ASSERT_DOUBLE_EQUAL(d, 19893357.0700676468277450, epsilon);
1322 
1323  /* Up to pole
1324  $ GeodSolve -E -i -p 16 --input-string "0 -180 90 0" */
1325  point_set(-180.0, 0.0, &g1);
1326  point_set(0.0, 90.0, &g2);
1327  d = spheroid_distance(&g1, &g2, &s);
1328 #if ! PROJ_GEODESIC
1329  epsilon = 1e-6;
1330 #endif
1331  CU_ASSERT_DOUBLE_EQUAL(d, 10001965.7293127228117396, epsilon);
1332 
1333 }
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:39
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:47
char * s
Definition: cu_in_wkt.c:23
static void point_set(double lon, double lat, GEOGRAPHIC_POINT *p)
Definition: cu_geodetic.c:356
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:186
Here is the call graph for this function:
Here is the caller graph for this function: