PostGIS  2.2.7dev-r@@SVN_REVISION@@
static void test_lwcollection_extract ( void  )
static

Definition at line 449 of file cu_libgeom.c.

References LW_PARSER_CHECK_NONE, lwcollection_extract(), lwcollection_free(), lwgeom_free(), lwgeom_from_wkt(), MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, and LWCOLLECTION::type.

Referenced by libgeom_suite_setup().

450 {
451 
452  LWGEOM *geom;
453  LWCOLLECTION *col;
454 
455  geom = lwgeom_from_wkt("GEOMETRYCOLLECTION(POINT(0 0))", LW_PARSER_CHECK_NONE);
456 
457  col = lwcollection_extract((LWCOLLECTION*)geom, 1);
458  CU_ASSERT_EQUAL(col->type, MULTIPOINTTYPE);
459  lwcollection_free(col);
460 
461  col = lwcollection_extract((LWCOLLECTION*)geom, 2);
462  CU_ASSERT_EQUAL(col->type, MULTILINETYPE);
463  lwcollection_free(col);
464 
465  col = lwcollection_extract((LWCOLLECTION*)geom, 3);
466  CU_ASSERT_EQUAL(col->type, MULTIPOLYGONTYPE);
467  lwcollection_free(col);
468 
469  lwgeom_free(geom);
470 
471  geom = lwgeom_from_wkt("GEOMETRYCOLLECTION EMPTY", LW_PARSER_CHECK_NONE);
472 
473  col = lwcollection_extract((LWCOLLECTION*)geom, 1);
474  CU_ASSERT_EQUAL(col->type, MULTIPOINTTYPE);
475  lwcollection_free(col);
476 
477  col = lwcollection_extract((LWCOLLECTION*)geom, 2);
478  CU_ASSERT_EQUAL(col->type, MULTILINETYPE);
479  lwcollection_free(col);
480 
481  col = lwcollection_extract((LWCOLLECTION*)geom, 3);
482  CU_ASSERT_EQUAL(col->type, MULTIPOLYGONTYPE);
483  lwcollection_free(col);
484 
485  lwgeom_free(geom);
486 }
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
Definition: lwcollection.c:353
uint8_t type
Definition: liblwgeom.h:487
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:890
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1869
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:326
#define MULTILINETYPE
Definition: liblwgeom.h:74

Here is the call graph for this function:

Here is the caller graph for this function: