Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of the specified type.
WARNING: the output will contain references to geometries in the input, so the result must be carefully released, not freed.
Definition at line 369 of file lwcollection.c.
References LWGEOM::bbox, LWCOLLECTION::bbox, LWCOLLECTION::flags, FLAGS_GET_M, FLAGS_GET_Z, gbox_copy(), LWCOLLECTION::geoms, LINETYPE, lwalloc(), lwcollection_construct(), lwcollection_construct_empty(), lwerror(), lwfree(), lwgeom_calculate_gbox(), lwgeom_clone(), lwgeom_is_empty(), lwrealloc(), lwtype_is_collection(), lwtype_name(), MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, LWCOLLECTION::ngeoms, POINTTYPE, POLYGONTYPE, LWCOLLECTION::srid, and LWGEOM::type.
Referenced by _lwt_AddLineEdge(), lwgeom_to_basic_type(), ST_CollectionExtract(), and test_lwcollection_extract().
374 int geomlistsize = 16;
378 if ( ! col )
return NULL;
392 lwerror(
"Only POLYGON, LINESTRING and POINT are supported by lwcollection_extract. %s requested.",
lwtype_name(
type));
399 for ( i = 0; i < col->
ngeoms; i++ )
408 if ( subtype ==
type )
411 if ( geomlistlen == geomlistsize )
424 for ( j = 0; j < tmpcol->
ngeoms; j++ )
427 if ( geomlistlen == geomlistsize )
432 geomlist[geomlistlen] = tmpcol->
geoms[j];
443 if ( geomlistlen > 0 )
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
void * lwrealloc(void *mem, size_t size)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_M(flags)
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
void lwerror(const char *fmt,...)
Write a notice out to the error handler.