PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_spheroid_area()

static void test_spheroid_area ( void  )
static

Definition at line 1359 of file cu_geodetic.c.

1360 {
1361  LWGEOM *lwg;
1362  GBOX gbox;
1363  double a1, a2;
1364  SPHEROID s;
1365 
1366  /* Init to WGS84 */
1368 
1369  gbox.flags = lwflags(0, 0, 1);
1370 
1371  /* Medford lot test polygon */
1372  lwg = lwgeom_from_wkt("POLYGON((-122.848227067007 42.5007249610493,-122.848309475585 42.5007179884263,-122.848327688675 42.500835880696,-122.848245279942 42.5008428533324,-122.848227067007 42.5007249610493))", LW_PARSER_CHECK_NONE);
1373  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1374  /* sphere: Planimeter -E -p 20 -e $WGS84_SPHERE -r --input-string \
1375  "42.5007249610493 -122.848227067007;42.5007179884263 -122.848309475585;"\
1376  "42.500835880696 -122.848327688675;42.5008428533324 -122.848245279942" */
1377  a1 = lwgeom_area_sphere(lwg, &s);
1378  CU_ASSERT_DOUBLE_EQUAL(a1, 89.721147136698008, 0.1);
1379  /* spheroid: Planimeter -E -p 20 -r --input-string \
1380  "42.5007249610493 -122.848227067007;42.5007179884263 -122.848309475585;"\
1381  "42.500835880696 -122.848327688675;42.5008428533324 -122.848245279942" */
1382  a2 = lwgeom_area_spheroid(lwg, &s);
1383  CU_ASSERT_DOUBLE_EQUAL(a2, 89.868413479309585, 0.1);
1384  lwgeom_free(lwg);
1385 
1386  /* Big-ass polygon */
1387  lwg = lwgeom_from_wkt("POLYGON((-2 3, -2 4, -1 4, -1 3, -2 3))", LW_PARSER_CHECK_NONE);
1388  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1389  /* sphere: Planimeter -E -p 20 -e $WGS84_SPHERE -r --input-string "3 -2;4 -2;4 -1;3 -1" */
1390  a1 = lwgeom_area_sphere(lwg, &s);
1391  CU_ASSERT_DOUBLE_EQUAL(a1, 12341436880.106982993974659, 0.1);
1392  /* spheroid: Planimeter -E -p 20 -r --input-string "3 -2;4 -2;4 -1;3 -1" */
1393 #ifdef PROJ_GEODESIC
1394  a2 = lwgeom_area_spheroid(lwg, &s);
1395  CU_ASSERT_DOUBLE_EQUAL(a2, 12286884908.946891319597874, 0.1);
1396 #endif
1397  lwgeom_free(lwg);
1398 
1399  /* One-degree square */
1400  lwg = lwgeom_from_wkt("POLYGON((8.5 2,8.5 1,9.5 1,9.5 2,8.5 2))", LW_PARSER_CHECK_NONE);
1401  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1402  /* sphere: Planimeter -E -p 20 -e $WGS84_SPHERE --input-string "2 8.5;1 8.5;1 9.5;2 9.5" */
1403  a1 = lwgeom_area_sphere(lwg, &s);
1404  CU_ASSERT_DOUBLE_EQUAL(a1, 12360265021.368023059138681, 0.1);
1405  /* spheroid: Planimeter -E -p 20 --input-string "2 8.5;1 8.5;1 9.5;2 9.5" */
1406 #ifdef PROJ_GEODESIC
1407  a2 = lwgeom_area_spheroid(lwg, &s);
1408  CU_ASSERT_DOUBLE_EQUAL(a2, 12305128751.042900673161556, 0.1);
1409 #endif
1410  lwgeom_free(lwg);
1411 
1412  /* One-degree square *near* the antimeridian */
1413  lwg = lwgeom_from_wkt("POLYGON((179.5 2,179.5 1,178.5 1,178.5 2,179.5 2))", LW_PARSER_CHECK_NONE);
1414  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1415  /* sphere: Planimeter -E -p 20 -e $WGS84_SPHERE -r --input-string "2 179.5;1 179.5;1 178.5;2 178.5" */
1416  a1 = lwgeom_area_sphere(lwg, &s);
1417  CU_ASSERT_DOUBLE_EQUAL(a1, 12360265021.368023059138681, 0.1);
1418  /* spheroid: Planimeter -E -p 20 -r --input-string "2 179.5;1 179.5;1 178.5;2 178.5" */
1419 #ifdef PROJ_GEODESIC
1420  a2 = lwgeom_area_spheroid(lwg, &s);
1421  CU_ASSERT_DOUBLE_EQUAL(a2, 12305128751.042900673161556, 0.1);
1422 #endif
1423  lwgeom_free(lwg);
1424 
1425  /* One-degree square *across* the antimeridian */
1426  lwg = lwgeom_from_wkt("POLYGON((179.5 2,179.5 1,-179.5 1,-179.5 2,179.5 2))", LW_PARSER_CHECK_NONE);
1427  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1428  /* sphere: Planimeter -E -p 20 -e $WGS84_SPHERE --input-string "2 179.5;1 179.5;1 -179.5;2 -179.5" */
1429  a1 = lwgeom_area_sphere(lwg, &s);
1430  CU_ASSERT_DOUBLE_EQUAL(a1, 12360265021.368023059138681, 0.1);
1431  /* spheroid: Planimeter -E -p 20 --input-string "2 179.5;1 179.5;1 -179.5;2 -179.5" */
1432 #ifdef PROJ_GEODESIC
1433  a2 = lwgeom_area_spheroid(lwg, &s);
1434  CU_ASSERT_DOUBLE_EQUAL(a2, 12305128751.042900673161556, 0.1);
1435 #endif
1436  lwgeom_free(lwg);
1437 }
char * s
Definition: cu_in_wkt.c:23
#define WGS84_MAJOR_AXIS
Definition: liblwgeom.h:159
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2060
#define WGS84_MINOR_AXIS
Definition: liblwgeom.h:161
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
Definition: lwgeodetic.c:3028
double lwgeom_area_spheroid(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the spheroid.
Definition: lwspheroid.c:647
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:39
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:905
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition: lwutil.c:471
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.
Definition: lwgeodetic.c:2031
lwflags_t flags
Definition: liblwgeom.h:339

References GBOX::flags, LW_PARSER_CHECK_NONE, lwflags(), lwgeom_area_sphere(), lwgeom_area_spheroid(), lwgeom_calculate_gbox_geodetic(), lwgeom_free(), lwgeom_from_wkt(), s, spheroid_init(), WGS84_MAJOR_AXIS, and WGS84_MINOR_AXIS.

Referenced by geodetic_suite_setup().

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