PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_spheroid_distance()

static void test_spheroid_distance ( void  )
static

Definition at line 1275 of file cu_geodetic.c.

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

Referenced by geodetic_suite_setup().

1276 {
1277  GEOGRAPHIC_POINT g1, g2;
1278  double d;
1279 #if ! PROJ_GEODESIC
1280  double epsilon; /* irregular */
1281 #else
1282  const double epsilon = 1e-8; /* at least 10 nm precision */
1283 #endif
1284  SPHEROID s;
1285 
1286  /* Init to WGS84 */
1287  spheroid_init(&s, 6378137.0, 6356752.314245179498);
1288 
1289  /* One vertical degree
1290  $ GeodSolve -E -i -p 16 --input-string "0 0 1 0" */
1291  point_set(0.0, 0.0, &g1);
1292  point_set(0.0, 1.0, &g2);
1293  d = spheroid_distance(&g1, &g2, &s);
1294 #if ! PROJ_GEODESIC
1295  epsilon = 1e-6;
1296 #endif
1297  CU_ASSERT_DOUBLE_EQUAL(d, 110574.3885577987957342, epsilon);
1298 
1299  /* Ten horizontal degrees
1300  $ GeodSolve -E -i -p 16 --input-string "0 -10 0 0" */
1301  point_set(-10.0, 0.0, &g1);
1302  point_set(0.0, 0.0, &g2);
1303  d = spheroid_distance(&g1, &g2, &s);
1304 #if ! PROJ_GEODESIC
1305  epsilon = 1e-3;
1306 #endif
1307  CU_ASSERT_DOUBLE_EQUAL(d, 1113194.9079327357264771, epsilon);
1308 
1309  /* One horizonal degree
1310  $ GeodSolve -E -i -p 16 --input-string "0 -1 0 0" */
1311  point_set(-1.0, 0.0, &g1);
1312  point_set(0.0, 0.0, &g2);
1313  d = spheroid_distance(&g1, &g2, &s);
1314 #if ! PROJ_GEODESIC
1315  epsilon = 1e-4;
1316 #endif
1317  CU_ASSERT_DOUBLE_EQUAL(d, 111319.4907932735726477, epsilon);
1318 
1319  /* Around world w/ slight bend
1320  $ GeodSolve -E -i -p 16 --input-string "0 -180 1 0" */
1321  point_set(-180.0, 0.0, &g1);
1322  point_set(0.0, 1.0, &g2);
1323  d = spheroid_distance(&g1, &g2, &s);
1324 #if ! PROJ_GEODESIC
1325  epsilon = 1e-5;
1326 #endif
1327  CU_ASSERT_DOUBLE_EQUAL(d, 19893357.0700676468277450, epsilon);
1328 
1329  /* Up to pole
1330  $ GeodSolve -E -i -p 16 --input-string "0 -180 90 0" */
1331  point_set(-180.0, 0.0, &g1);
1332  point_set(0.0, 90.0, &g2);
1333  d = spheroid_distance(&g1, &g2, &s);
1334 #if ! PROJ_GEODESIC
1335  epsilon = 1e-6;
1336 #endif
1337  CU_ASSERT_DOUBLE_EQUAL(d, 10001965.7293127228117396, epsilon);
1338 
1339 }
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:52
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: