PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ test_lwpoly_construct_circle()

static void test_lwpoly_construct_circle ( void  )
static

Definition at line 1681 of file cu_algorithm.c.

1682 {
1683  LWPOLY* p;
1684  const GBOX* g;
1685  const int32_t srid = 4326;
1686  const uint32_t segments_per_quad = 17;
1687  const int x = 10;
1688  const int y = 20;
1689  const int r = 5;
1690 
1691  /* With normal arguments you should get something circle-y */
1692  p = lwpoly_construct_circle(srid, x, y, r, segments_per_quad, LW_TRUE);
1693 
1694  ASSERT_INT_EQUAL(lwgeom_count_vertices(lwpoly_as_lwgeom(p)), segments_per_quad * 4 + 1);
1696 
1698  CU_ASSERT_DOUBLE_EQUAL(g->xmin, x-r, 0.1);
1699  CU_ASSERT_DOUBLE_EQUAL(g->xmax, x+r, 0.1);
1700  CU_ASSERT_DOUBLE_EQUAL(g->ymin, y-r, 0.1);
1701  CU_ASSERT_DOUBLE_EQUAL(g->ymax, y+r, 0.1);
1702 
1703  CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(lwpoly_as_lwgeom(p)), M_PI*5*5, 0.1);
1704 
1705  lwpoly_free(p);
1706 
1707  /* No segments? No circle. */
1708  p = lwpoly_construct_circle(srid, x, y, r, 0, LW_TRUE);
1709  CU_ASSERT_TRUE(p == NULL);
1710 
1711  /* Negative radius? No circle. */
1712  p = lwpoly_construct_circle(srid, x, y, -1e-3, segments_per_quad, LW_TRUE);
1713  CU_ASSERT_TRUE(p == NULL);
1714 
1715  /* Zero radius? Invalid circle */
1716  p = lwpoly_construct_circle(srid, x, y, 0, segments_per_quad, LW_TRUE);
1717  CU_ASSERT_TRUE(p != NULL);
1718  lwpoly_free(p);
1719 }
char * r
Definition: cu_in_wkt.c:24
#define ASSERT_INT_EQUAL(o, e)
LWPOLY * lwpoly_construct_circle(int32_t srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
Definition: lwpoly.c:120
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:927
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:329
double lwgeom_area(const LWGEOM *geom)
Definition: lwgeom.c:1908
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1246
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
Definition: lwgeom.c:743
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:175
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:108
double ymax
Definition: liblwgeom.h:372
double xmax
Definition: liblwgeom.h:370
double ymin
Definition: liblwgeom.h:371
double xmin
Definition: liblwgeom.h:369

References ASSERT_INT_EQUAL, LW_TRUE, lwgeom_area(), lwgeom_count_vertices(), lwgeom_get_bbox(), lwgeom_get_srid(), lwpoly_as_lwgeom(), lwpoly_construct_circle(), lwpoly_free(), r, pixval::x, GBOX::xmax, GBOX::xmin, pixval::y, GBOX::ymax, and GBOX::ymin.

Referenced by algorithms_suite_setup().

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