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

Definition at line 441 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().

442 {
443 
444  LWGEOM *geom;
445  LWCOLLECTION *col;
446 
447  geom = lwgeom_from_wkt("GEOMETRYCOLLECTION(POINT(0 0))", LW_PARSER_CHECK_NONE);
448 
449  col = lwcollection_extract((LWCOLLECTION*)geom, 1);
450  CU_ASSERT_EQUAL(col->type, MULTIPOINTTYPE);
451  lwcollection_free(col);
452 
453  col = lwcollection_extract((LWCOLLECTION*)geom, 2);
454  CU_ASSERT_EQUAL(col->type, MULTILINETYPE);
455  lwcollection_free(col);
456 
457  col = lwcollection_extract((LWCOLLECTION*)geom, 3);
458  CU_ASSERT_EQUAL(col->type, MULTIPOLYGONTYPE);
459  lwcollection_free(col);
460 
461  lwgeom_free(geom);
462 
463  geom = lwgeom_from_wkt("GEOMETRYCOLLECTION EMPTY", LW_PARSER_CHECK_NONE);
464 
465  col = lwcollection_extract((LWCOLLECTION*)geom, 1);
466  CU_ASSERT_EQUAL(col->type, MULTIPOINTTYPE);
467  lwcollection_free(col);
468 
469  col = lwcollection_extract((LWCOLLECTION*)geom, 2);
470  CU_ASSERT_EQUAL(col->type, MULTILINETYPE);
471  lwcollection_free(col);
472 
473  col = lwcollection_extract((LWCOLLECTION*)geom, 3);
474  CU_ASSERT_EQUAL(col->type, MULTIPOLYGONTYPE);
475  lwcollection_free(col);
476 
477  lwgeom_free(geom);
478 }
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
Definition: lwcollection.c:343
uint8_t type
Definition: liblwgeom.h:459
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:844
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:316
#define MULTILINETYPE
Definition: liblwgeom.h:64

Here is the call graph for this function:

Here is the caller graph for this function: