PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ test_lwgeom_area_sphere()

static void test_lwgeom_area_sphere ( void  )
static

Definition at line 1538 of file cu_geodetic.c.

References area(), LW_PARSER_CHECK_NONE, lwgeom_area_sphere(), lwgeom_free(), lwgeom_from_wkt(), s, spheroid_init(), WGS84_MAJOR_AXIS, and WGS84_MINOR_AXIS.

Referenced by geodetic_suite_setup().

1539 {
1540  LWGEOM *lwg;
1541  double area;
1542  SPHEROID s;
1543 
1544  /* Init to WGS84 */
1546 
1547  /* Simple case */
1548  lwg = lwgeom_from_wkt("POLYGON((1 1, 1 2, 2 2, 2 1, 1 1))", LW_PARSER_CHECK_NONE);
1549  area = lwgeom_area_sphere(lwg, &s);
1550 
1551  CU_ASSERT_DOUBLE_EQUAL(area, 12360265021.3561, 1.0);
1552  lwgeom_free(lwg);
1553 
1554  /* Robustness tests, from ticket #3393 */
1555  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026663,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026663))", LW_PARSER_CHECK_NONE);
1556  area = lwgeom_area_sphere(lwg, &s);
1557  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1558  lwgeom_free(lwg);
1559 
1560  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026662,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026662))", LW_PARSER_CHECK_NONE);
1561  area = lwgeom_area_sphere(lwg, &s);
1562  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1563  lwgeom_free(lwg);
1564 
1565  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026664,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026664))", LW_PARSER_CHECK_NONE);
1566  area = lwgeom_area_sphere(lwg, &s);
1567  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1568  lwgeom_free(lwg);
1569  /* end #3393 */
1570 }
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:25
Datum area(PG_FUNCTION_ARGS)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
#define WGS84_MINOR_AXIS
Definition: liblwgeom.h:115
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:890
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1869
char * s
Definition: cu_in_wkt.c:23
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.
Definition: lwgeodetic.c:1927
#define WGS84_MAJOR_AXIS
Definition: liblwgeom.h:113
Here is the call graph for this function:
Here is the caller graph for this function: