PostGIS  2.3.7dev-r@@SVN_REVISION@@
static void test_lwpoly_construct_circle ( void  )
static

Definition at line 1105 of file cu_algorithm.c.

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().

1106 {
1107  LWPOLY* p;
1108  GBOX* g;
1109  const int srid = 4326;
1110  const int segments_per_quad = 17;
1111  const int x = 10;
1112  const int y = 20;
1113  const int r = 5;
1114 
1115  /* With normal arguments you should get something circle-y */
1116  p = lwpoly_construct_circle(srid, x, y, r, segments_per_quad, LW_TRUE);
1117 
1118  ASSERT_INT_EQUAL(lwgeom_count_vertices(p), segments_per_quad * 4 + 1);
1120 
1122  CU_ASSERT_DOUBLE_EQUAL(g->xmin, x-r, 0.1);
1123  CU_ASSERT_DOUBLE_EQUAL(g->xmax, x+r, 0.1);
1124  CU_ASSERT_DOUBLE_EQUAL(g->ymin, y-r, 0.1);
1125  CU_ASSERT_DOUBLE_EQUAL(g->ymax, y+r, 0.1);
1126 
1127  CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(p), M_PI*5*5, 0.1);
1128 
1129  lwpoly_free(p);
1130 
1131  /* No segments? No circle. */
1132  p = lwpoly_construct_circle(srid, x, y, r, 0, LW_TRUE);
1133  CU_ASSERT_TRUE(p == NULL);
1134 
1135  /* Negative radius? No circle. */
1136  p = lwpoly_construct_circle(srid, x, y, -1e-3, segments_per_quad, LW_TRUE);
1137  CU_ASSERT_TRUE(p == NULL);
1138 
1139  /* Zero radius? Invalid circle */
1140  p = lwpoly_construct_circle(srid, x, y, 0, segments_per_quad, LW_TRUE);
1141  CU_ASSERT_TRUE(p != NULL);
1142  lwpoly_free(p);
1143 }
char * r
Definition: cu_in_wkt.c:24
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:835
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:252
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:150
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
#define ASSERT_INT_EQUAL(o, e)
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:653
tuple x
Definition: pixval.py:53
double lwgeom_area(const LWGEOM *geom)
Definition: lwgeom.c:1592
LWPOLY * lwpoly_construct_circle(int srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
Definition: lwpoly.c:98
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1153
tuple y
Definition: pixval.py:54

Here is the call graph for this function:

Here is the caller graph for this function: