13 #include "CUnit/Basic.h"
23 #define check_geom_equal(gobt, gexp) do { \
25 LWGEOM *ngobt, *ngexp; \
26 ngobt = lwgeom_normalize(gobt); \
27 ngexp = lwgeom_normalize(gexp); \
28 if ( ! lwgeom_same((ngobt), (ngexp)) ) { \
29 obt = lwgeom_to_wkt((ngobt), WKT_ISO, 8, NULL); \
30 exp = lwgeom_to_wkt((ngexp), WKT_ISO, 8, NULL); \
31 printf(" Failure at %s:%d\n", __FILE__, __LINE__); \
32 printf(" Exp: %s\n", exp); \
33 printf(" Obt: %s\n", obt); \
34 free(obt); free(exp); \
35 lwgeom_free(ngobt); lwgeom_free(ngexp); \
38 lwgeom_free(ngobt); lwgeom_free(ngexp); \
57 "MULTILINESTRING((0 0, 10 0, 10 10, 0 10, 0 0),(10 10, 20 10, 20 20, 10 20, 10 10))",
59 CU_ASSERT( gin != NULL );
62 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((10 10,10 20,20 20,20 10,10 10)))",
64 CU_ASSERT( gexp != NULL );
67 CU_ASSERT(gout != NULL);
89 "MULTILINESTRING((0 0, 10 0, 10 10, 0 10, 0 0),(10 10, 20 10, 20 0, 10 0, 10 10))",
91 CU_ASSERT(gin != NULL);
94 "POLYGON((0 0,0 10,10 10,20 10,20 0,10 0,0 0))",
96 CU_ASSERT(gexp != NULL);
99 CU_ASSERT(gout != NULL);
118 LWGEOM *gin, *gout, *gexp;
123 "MULTILINESTRING((0 0, 20 0, 20 20, 0 20, 0 0),(2 2, 18 2, 18 18, 2 18, 2 2))",
125 CU_ASSERT(gin != NULL);
128 "POLYGON((0 0,0 20,20 20,20 0,0 0),(2 2,18 2,18 18,2 18,2 2))",
130 CU_ASSERT(gexp != NULL);
133 CU_ASSERT(gout != NULL);
154 LWGEOM *gin, *gout, *gexp;
159 "MULTILINESTRING((0 0, 20 0, 20 20, 0 20, 0 0),(2 2, 18 2, 18 18, 2 18, 2 2),(8 8, 8 12, 12 12, 12 8, 8 8))",
161 CU_ASSERT(gin != NULL);
164 "MULTIPOLYGON(((0 0,0 20,20 20,20 0,0 0),(2 2,18 2,18 18,2 18,2 2)),((8 8,8 12,12 12,12 8,8 8)))",
166 CU_ASSERT(gexp != NULL);
169 CU_ASSERT(gout != NULL);
190 LWGEOM *gin, *gout, *gexp;
195 "MULTILINESTRING((0 0, 20 0, 20 20, 0 20, 0 0),(2 2, 18 2, 18 18, 2 18, 2 2), (8 8, 8 9, 8 10, 8 11, 8 12, 9 12, 10 12, 11 12, 12 12, 12 11, 12 10, 12 9, 12 8, 11 8, 10 8, 9 8, 8 8))",
197 CU_ASSERT(gin != NULL);
200 "MULTIPOLYGON(((0 0,0 20,20 20,20 0,0 0),(2 2,18 2,18 18,2 18,2 2)),((8 8,8 9,8 10,8 11,8 12,9 12,10 12,11 12,12 12,12 11,12 10,12 9,12 8,11 8,10 8,9 8,8 8)))",
202 CU_ASSERT(gexp != NULL);
205 CU_ASSERT(gout != NULL);
226 LWGEOM *gin, *gout, *gexp;
231 "MULTILINESTRING((0 0, 20 0, 20 20, 0 20, 0 0),(2 2, 18 2, 18 18, 2 18, 2 2),(8 8, 8 12, 12 12, 12 8, 8 8),(10 8, 10 12))",
233 CU_ASSERT(gin != NULL);
236 "MULTIPOLYGON(((0 0,0 20,20 20,20 0,0 0),(2 2,18 2,18 18,2 18,2 2)),((8 8,8 12,12 12,12 8,8 8)))",
238 CU_ASSERT(gexp != NULL);
241 CU_ASSERT(gout != NULL);
262 LWGEOM *gin, *gout, *gexp;
267 "MULTILINESTRING((0 0, 20 0, 20 20, 0 20, 0 0),(2 2, 18 2, 18 18, 2 18, 2 2),(10 2, 10 18))",
269 CU_ASSERT(gin != NULL);
272 "POLYGON((0 0,0 20,20 20,20 0,0 0),(2 2,18 2,18 18,2 18,2 2))",
274 CU_ASSERT(gexp != NULL);
277 CU_ASSERT(gout != NULL);
300 LWGEOM *gin, *gout, *gexp;
305 "MULTILINESTRING( (0 0, 70 0, 70 70, 0 70, 0 0), (10 10, 10 60, 40 60, 40 10, 10 10), (20 20, 20 30, 30 30, 30 20, 20 20), (20 30, 30 30, 30 50, 20 50, 20 30), (50 20, 60 20, 60 40, 50 40, 50 20), (50 40, 60 40, 60 60, 50 60, 50 40), (80 0, 110 0, 110 70, 80 70, 80 0), (90 60, 100 60, 100 50, 90 50, 90 60))",
307 CU_ASSERT(gin != NULL);
310 "MULTIPOLYGON(((80 0,80 70,110 70,110 0,80 0),(90 60,90 50,100 50,100 60,90 60)),((20 20,20 30,20 50,30 50,30 30,30 20,20 20)),((0 0,0 70,70 70,70 0,0 0),(10 10,40 10,40 60,10 60,10 10),(50 20,60 20,60 40,60 60,50 60,50 40,50 20)))",
312 CU_ASSERT(gexp != NULL);
315 CU_ASSERT(gout != NULL);
329 CU_pSuite suite = CU_add_suite(
"buildarea", NULL, NULL);
static void buildarea4b(void)
static void buildarea2(void)
static void buildarea7(void)
#define check_geom_equal(gobt, gexp)
static void buildarea4(void)
static void buildarea1(void)
static void buildarea6(void)
static void buildarea5(void)
static void buildarea3(void)
void buildarea_suite_setup(void)
void cu_error_msg_reset()
#define PG_ADD_TEST(suite, testfunc)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
LWGEOM * lwgeom_buildarea(const LWGEOM *geom)
Take a geometry and return an areal geometry (Polygon or MultiPolygon).
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
This library is the generic geometry handling section of PostGIS.