PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_gbox_utils()

static void test_gbox_utils ( void  )
static

Definition at line 1439 of file cu_geodetic.c.

1440 {
1441  LWGEOM *lwg;
1442  GBOX gbox;
1443  double a1, a2;
1444  SPHEROID s;
1445  POINT2D pt;
1446 
1447  /* Init to WGS84 */
1449 
1450  gbox.flags = lwflags(0, 0, 1);
1451 
1452  /* One-degree square by equator */
1453  lwg = lwgeom_from_wkt("POLYGON((1 20,1 21,2 21,2 20,1 20))", LW_PARSER_CHECK_NONE);
1454  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1455  a1 = gbox_angular_width(&gbox);
1456  a2 = gbox_angular_height(&gbox);
1457  CU_ASSERT_DOUBLE_EQUAL(a1, 0.0177951, 0.0000001);
1458  CU_ASSERT_DOUBLE_EQUAL(a2, 0.017764, 0.0000001);
1459  lwgeom_free(lwg);
1460 
1461  /* One-degree square *across* antimeridian */
1462  lwg = lwgeom_from_wkt("POLYGON((179.5 2,179.5 1,-179.5 1,-179.5 2,179.5 2))", LW_PARSER_CHECK_NONE);
1463  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1464  a1 = gbox_angular_width(&gbox);
1465  a2 = gbox_angular_height(&gbox);
1466  //printf("a1=%g a2=%g\n", a1, a2);
1467  CU_ASSERT_DOUBLE_EQUAL(a1, 0.0174613, 0.0000001);
1468  CU_ASSERT_DOUBLE_EQUAL(a2, 0.0174553, 0.0000001);
1469  lwgeom_free(lwg);
1470 
1471  /* One-degree square *across* antimeridian */
1472  lwg = lwgeom_from_wkt("POLYGON((178.5 2,178.5 1,-179.5 1,-179.5 2,178.5 2))", LW_PARSER_CHECK_NONE);
1473  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1474  gbox_centroid(&gbox, &pt);
1475  //printf("POINT(%g %g)\n", pt.x, pt.y);
1476  CU_ASSERT_DOUBLE_EQUAL(pt.x, 179.5, 0.0001);
1477  CU_ASSERT_DOUBLE_EQUAL(pt.y, 1.50024, 0.0001);
1478  lwgeom_free(lwg);
1479 
1480 }
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
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 gbox_angular_height(const GBOX *gbox)
GBOX utility functions to figure out coverage/location on the globe.
Definition: lwgeodetic.c:188
double gbox_angular_width(const GBOX *gbox)
Returns the angular width (longitudinal span) of the box in radians.
Definition: lwgeodetic.c:215
int gbox_centroid(const GBOX *gbox, POINT2D *out)
Computes the average(ish) center of the box and returns success.
Definition: lwgeodetic.c:267
lwflags_t flags
Definition: liblwgeom.h:339
double y
Definition: liblwgeom.h:376
double x
Definition: liblwgeom.h:376

References GBOX::flags, gbox_angular_height(), gbox_angular_width(), gbox_centroid(), LW_PARSER_CHECK_NONE, lwflags(), lwgeom_calculate_gbox_geodetic(), lwgeom_free(), lwgeom_from_wkt(), s, spheroid_init(), WGS84_MAJOR_AXIS, WGS84_MINOR_AXIS, POINT2D::x, and POINT2D::y.

Referenced by geodetic_suite_setup().

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