PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ test_spheroid_distance()

static void test_spheroid_distance ( void  )
static

Definition at line 1293 of file cu_geodetic.c.

1294{
1295 GEOGRAPHIC_POINT g1, g2;
1296 double d;
1297#ifndef PROJ_GEODESIC
1298 double epsilon; /* irregular */
1299#else
1300 const double epsilon = 1e-8; /* at least 10 nm precision */
1301#endif
1302 SPHEROID s;
1303
1304 /* Init to WGS84 */
1305 spheroid_init(&s, 6378137.0, 6356752.314245179498);
1306
1307 /* One vertical degree
1308 $ GeodSolve -E -i -p 16 --input-string "0 0 1 0" */
1309 point_set(0.0, 0.0, &g1);
1310 point_set(0.0, 1.0, &g2);
1311 d = spheroid_distance(&g1, &g2, &s);
1312#ifndef PROJ_GEODESIC
1313 epsilon = 1e-6;
1314#endif
1315 CU_ASSERT_DOUBLE_EQUAL(d, 110574.3885577987957342, epsilon);
1316
1317 /* Ten horizontal degrees
1318 $ GeodSolve -E -i -p 16 --input-string "0 -10 0 0" */
1319 point_set(-10.0, 0.0, &g1);
1320 point_set(0.0, 0.0, &g2);
1321 d = spheroid_distance(&g1, &g2, &s);
1322#ifndef PROJ_GEODESIC
1323 epsilon = 1e-3;
1324#endif
1325 CU_ASSERT_DOUBLE_EQUAL(d, 1113194.9079327357264771, epsilon);
1326
1327 /* One horizontal degree
1328 $ GeodSolve -E -i -p 16 --input-string "0 -1 0 0" */
1329 point_set(-1.0, 0.0, &g1);
1330 point_set(0.0, 0.0, &g2);
1331 d = spheroid_distance(&g1, &g2, &s);
1332#ifndef PROJ_GEODESIC
1333 epsilon = 1e-4;
1334#endif
1335 CU_ASSERT_DOUBLE_EQUAL(d, 111319.4907932735726477, epsilon);
1336
1337 /* Around world w/ slight bend
1338 $ GeodSolve -E -i -p 16 --input-string "0 -180 1 0" */
1339 point_set(-180.0, 0.0, &g1);
1340 point_set(0.0, 1.0, &g2);
1341 d = spheroid_distance(&g1, &g2, &s);
1342#ifndef PROJ_GEODESIC
1343 epsilon = 1e-5;
1344#endif
1345 CU_ASSERT_DOUBLE_EQUAL(d, 19893357.0700676468277450, epsilon);
1346
1347 /* Up to pole
1348 $ GeodSolve -E -i -p 16 --input-string "0 -180 90 0" */
1349 point_set(-180.0, 0.0, &g1);
1350 point_set(0.0, 90.0, &g2);
1351 d = spheroid_distance(&g1, &g2, &s);
1352#ifndef PROJ_GEODESIC
1353 epsilon = 1e-6;
1354#endif
1355 CU_ASSERT_DOUBLE_EQUAL(d, 10001965.7293127228117396, epsilon);
1356
1357}
static void point_set(double lon, double lat, GEOGRAPHIC_POINT *p)
char * s
Definition cu_in_wkt.c:23
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition lwspheroid.c:39
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:79
Point in spherical coordinates on the world.
Definition lwgeodetic.h:54

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

Referenced by geodetic_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: