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

◆ test_lwgeom_area_sphere()

static void test_lwgeom_area_sphere ( void  )
static

Definition at line 1561 of file cu_geodetic.c.

1562{
1563 LWGEOM *lwg;
1564 double area;
1565 SPHEROID s;
1566
1567 /* Init to Sphere */
1569 s.a = s.b = s.radius;
1570
1571 /* Simple case */
1572 lwg = lwgeom_from_wkt("POLYGON((1 1, 1 2, 2 2, 2 1, 1 1))", LW_PARSER_CHECK_NONE);
1573 area = lwgeom_area_sphere(lwg, &s);
1574
1575 CU_ASSERT_DOUBLE_EQUAL(area, 12360265021.3561, 1.0);
1576 lwgeom_free(lwg);
1577
1578 /* Robustness tests, from ticket #3393 */
1579 lwg = lwgeom_from_wkt("POLYGON((0 78.703946026663,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026663))", LW_PARSER_CHECK_NONE);
1580 area = lwgeom_area_sphere(lwg, &s);
1581 CU_ASSERT_DOUBLE_EQUAL(area, 127516466960671, 1.0);
1582 lwgeom_free(lwg);
1583
1584 lwg = lwgeom_from_wkt("POLYGON((0 78.703946026662,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026662))", LW_PARSER_CHECK_NONE);
1585 area = lwgeom_area_sphere(lwg, &s);
1586 CU_ASSERT_DOUBLE_EQUAL(area, 127516466960671, 1.0);
1587 lwgeom_free(lwg);
1588
1589 lwg = lwgeom_from_wkt("POLYGON((0 78.703946026664,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026664))", LW_PARSER_CHECK_NONE);
1590 area = lwgeom_area_sphere(lwg, &s);
1591 CU_ASSERT_DOUBLE_EQUAL(area, 127516466960671, 1.0);
1592 lwgeom_free(lwg);
1593 /* end #3393 */
1594}
char * s
Definition cu_in_wkt.c:23
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
#define LW_PARSER_CHECK_NONE
Definition liblwgeom.h:2149
#define WGS84_RADIUS
Definition liblwgeom.h:148
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:940
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.

References LW_PARSER_CHECK_NONE, lwgeom_area_sphere(), lwgeom_free(), lwgeom_from_wkt(), s, spheroid_init(), and WGS84_RADIUS.

Referenced by geodetic_suite_setup().

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