PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_lwgeom_area_sphere ( void  )
static

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

1467 {
1468  LWGEOM *lwg;
1469  double area;
1470  SPHEROID s;
1471 
1472  /* Init to WGS84 */
1474 
1475  /* Simple case */
1476  lwg = lwgeom_from_wkt("POLYGON((1 1, 1 2, 2 2, 2 1, 1 1))", LW_PARSER_CHECK_NONE);
1477  area = lwgeom_area_sphere(lwg, &s);
1478 
1479  CU_ASSERT_DOUBLE_EQUAL(area, 12360265021.3561, 1.0);
1480  lwgeom_free(lwg);
1481 
1482  /* Robustness tests, from ticket #3393 */
1483  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026663,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026663))", LW_PARSER_CHECK_NONE);
1484  area = lwgeom_area_sphere(lwg, &s);
1485  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1486  lwgeom_free(lwg);
1487 
1488  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026662,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026662))", LW_PARSER_CHECK_NONE);
1489  area = lwgeom_area_sphere(lwg, &s);
1490  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1491  lwgeom_free(lwg);
1492 
1493  lwg = lwgeom_from_wkt("POLYGON((0 78.703946026664,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026664))", LW_PARSER_CHECK_NONE);
1494  area = lwgeom_area_sphere(lwg, &s);
1495  CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
1496  lwgeom_free(lwg);
1497  /* end #3393 */
1498 }
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:20
Datum area(PG_FUNCTION_ARGS)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
#define WGS84_MINOR_AXIS
Definition: liblwgeom.h:97
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:844
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
char * s
Definition: cu_in_wkt.c:24
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.
Definition: lwgeodetic.c:1924
#define WGS84_MAJOR_AXIS
Definition: liblwgeom.h:95

Here is the call graph for this function:

Here is the caller graph for this function: