PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lwcollection_extract()

static void test_lwcollection_extract ( void  )
static

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

451 {
452 
453  LWGEOM *geom;
454  LWCOLLECTION *col;
455 
456  geom = lwgeom_from_wkt("GEOMETRYCOLLECTION(POINT(0 0))", LW_PARSER_CHECK_NONE);
457 
458  col = lwcollection_extract((LWCOLLECTION*)geom, 1);
459  CU_ASSERT_EQUAL(col->type, MULTIPOINTTYPE);
460  lwcollection_free(col);
461 
462  col = lwcollection_extract((LWCOLLECTION*)geom, 2);
463  CU_ASSERT_EQUAL(col->type, MULTILINETYPE);
464  lwcollection_free(col);
465 
466  col = lwcollection_extract((LWCOLLECTION*)geom, 3);
467  CU_ASSERT_EQUAL(col->type, MULTIPOLYGONTYPE);
468  lwcollection_free(col);
469 
470  lwgeom_free(geom);
471 
472  geom = lwgeom_from_wkt("GEOMETRYCOLLECTION EMPTY", LW_PARSER_CHECK_NONE);
473 
474  col = lwcollection_extract((LWCOLLECTION*)geom, 1);
475  CU_ASSERT_EQUAL(col->type, MULTIPOINTTYPE);
476  lwcollection_free(col);
477 
478  col = lwcollection_extract((LWCOLLECTION*)geom, 2);
479  CU_ASSERT_EQUAL(col->type, MULTILINETYPE);
480  lwcollection_free(col);
481 
482  col = lwcollection_extract((LWCOLLECTION*)geom, 3);
483  CU_ASSERT_EQUAL(col->type, MULTIPOLYGONTYPE);
484  lwcollection_free(col);
485 
486  lwgeom_free(geom);
487 }
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
Definition: lwcollection.c:369
uint8_t type
Definition: liblwgeom.h:503
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:340
#define MULTILINETYPE
Definition: liblwgeom.h:89
Here is the call graph for this function:
Here is the caller graph for this function: