PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_gbox_utils()

static void test_gbox_utils ( void  )
static

Definition at line 1422 of file cu_geodetic.c.

1423 {
1424  LWGEOM *lwg;
1425  GBOX gbox;
1426  double a1, a2;
1427  SPHEROID s;
1428  POINT2D pt;
1429 
1430  /* Init to WGS84 */
1432 
1433  gbox.flags = gflags(0, 0, 1);
1434 
1435  /* One-degree square by equator */
1436  lwg = lwgeom_from_wkt("POLYGON((1 20,1 21,2 21,2 20,1 20))", LW_PARSER_CHECK_NONE);
1437  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1438  a1 = gbox_angular_width(&gbox);
1439  a2 = gbox_angular_height(&gbox);
1440  CU_ASSERT_DOUBLE_EQUAL(a1, 0.0177951, 0.0000001);
1441  CU_ASSERT_DOUBLE_EQUAL(a2, 0.017764, 0.0000001);
1442  lwgeom_free(lwg);
1443 
1444  /* One-degree square *across* antimeridian */
1445  lwg = lwgeom_from_wkt("POLYGON((179.5 2,179.5 1,-179.5 1,-179.5 2,179.5 2))", LW_PARSER_CHECK_NONE);
1446  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1447  a1 = gbox_angular_width(&gbox);
1448  a2 = gbox_angular_height(&gbox);
1449  //printf("a1=%g a2=%g\n", a1, a2);
1450  CU_ASSERT_DOUBLE_EQUAL(a1, 0.0174613, 0.0000001);
1451  CU_ASSERT_DOUBLE_EQUAL(a2, 0.0174553, 0.0000001);
1452  lwgeom_free(lwg);
1453 
1454  /* One-degree square *across* antimeridian */
1455  lwg = lwgeom_from_wkt("POLYGON((178.5 2,178.5 1,-179.5 1,-179.5 2,178.5 2))", LW_PARSER_CHECK_NONE);
1456  lwgeom_calculate_gbox_geodetic(lwg, &gbox);
1457  gbox_centroid(&gbox, &pt);
1458  //printf("POINT(%g %g)\n", pt.x, pt.y);
1459  CU_ASSERT_DOUBLE_EQUAL(pt.x, 179.5, 0.0001);
1460  CU_ASSERT_DOUBLE_EQUAL(pt.y, 1.50024, 0.0001);
1461  lwgeom_free(lwg);
1462 
1463 }
char * s
Definition: cu_in_wkt.c:23
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
Definition: g_util.c:145
#define WGS84_MAJOR_AXIS
Definition: liblwgeom.h:128
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
#define WGS84_MINOR_AXIS
Definition: liblwgeom.h:130
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:904
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
uint8_t flags
Definition: liblwgeom.h:294
double y
Definition: liblwgeom.h:331
double x
Definition: liblwgeom.h:331

References GBOX::flags, gbox_angular_height(), gbox_angular_width(), gbox_centroid(), gflags(), LW_PARSER_CHECK_NONE, 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: