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 386 of file lwcollection.c.
391 int geomlistsize = 16;
395 if (!col)
return NULL;
410 "Only POLYGON, LINESTRING and POINT are supported by "
411 "lwcollection_extract. %s requested.",
419 for (i = 0; i < col->
ngeoms; i++)
429 if (geomlistlen == geomlistsize)
433 geomlist,
sizeof(
LWGEOM*) * geomlistsize);
444 for (j = 0; j < tmpcol->
ngeoms; j++)
448 if (geomlistlen == geomlistsize)
455 geomlist[geomlistlen] = tmpcol->
geoms[j];
468 outtype, col->
srid, NULL, geomlistlen, geomlist);
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
void * lwrealloc(void *mem, size_t size)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
#define FLAGS_GET_M(flags)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
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...
void * lwalloc(size_t size)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
References LWGEOM::bbox, LWCOLLECTION::bbox, LWCOLLECTION::flags, FLAGS_GET_M, FLAGS_GET_Z, gbox_copy(), LWCOLLECTION::geoms, LINETYPE, lwalloc(), lwcollection_construct(), lwcollection_construct_empty(), lwcollection_extract(), 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, LWGEOM::type, and ovdump::type.
Referenced by _lwt_AddLineEdge(), lwcollection_extract(), lwgeom_to_basic_type(), ST_CollectionExtract(), and test_lwcollection_extract().