PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lwgeom_area_sphere()

static void test_lwgeom_area_sphere ( void  )
static

Definition at line 1544 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().

1545 {
1546  LWGEOM *lwg;
1547  double area;
1548  SPHEROID s;
1549 
1550  /* Init to WGS84 */
1552 
1553  /* Simple case */
1554  lwg = lwgeom_from_wkt("POLYGON((1 1, 1 2, 2 2, 2 1, 1 1))", LW_PARSER_CHECK_NONE);
1555  area = lwgeom_area_sphere(lwg, &s);
1556 
1557  CU_ASSERT_DOUBLE_EQUAL(area, 12360265021.3561, 1.0);
1558  lwgeom_free(lwg);
1559 
1560  /* Robustness tests, from ticket #3393 */
1561  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026663,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026663))", LW_PARSER_CHECK_NONE);
1562  area = lwgeom_area_sphere(lwg, &s);
1563  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1564  lwgeom_free(lwg);
1565 
1566  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026662,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026662))", LW_PARSER_CHECK_NONE);
1567  area = lwgeom_area_sphere(lwg, &s);
1568  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1569  lwgeom_free(lwg);
1570 
1571  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026664,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026664))", LW_PARSER_CHECK_NONE);
1572  area = lwgeom_area_sphere(lwg, &s);
1573  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1574  lwgeom_free(lwg);
1575  /* end #3393 */
1576 }
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:39
Datum area(PG_FUNCTION_ARGS)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
#define WGS84_MINOR_AXIS
Definition: liblwgeom.h:130
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
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:2027
#define WGS84_MAJOR_AXIS
Definition: liblwgeom.h:128
Here is the call graph for this function:
Here is the caller graph for this function: