PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwcollection_extract()

LWCOLLECTION * lwcollection_extract ( const LWCOLLECTION col,
uint32_t  type 
)

Definition at line 432 of file lwcollection.c.

433{
434 LWCOLLECTION* outcol;
435
436 if (!col) return NULL;
437
438 /* Self-discover output type when it is not specified */
439 if (!type)
441
442 /*
443 * If self-discovery failed, there were no primitive points
444 * lines or polygons in the collection, so send back an
445 * empty collection.
446 */
447 if (!type)
448 {
450 col->srid,
451 FLAGS_GET_Z(col->flags),
452 FLAGS_GET_M(col->flags));
453 }
454
455 if (!(type == POINTTYPE || type == LINETYPE || type == POLYGONTYPE))
456 {
457 lwerror(
458 "Only POLYGON, LINESTRING and POINT are supported by "
459 "lwcollection_extract. %s requested.",
460 lwtype_name(type));
461 return NULL;
462 }
463
465 col->srid,
466 FLAGS_GET_Z(col->flags),
467 FLAGS_GET_M(col->flags));
468
469 lwcollection_extract_recursive(col, type, outcol);
471 return outcol;
472}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define COLLECTIONTYPE
Definition liblwgeom.h:108
#define LINETYPE
Definition liblwgeom.h:103
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
#define POLYGONTYPE
Definition liblwgeom.h:104
uint8_t lwtype_multitype(uint8_t type)
Definition lwgeom.c:398
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:166
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition lwgeom.c:723
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition lwgeom.c:337
static int lwcollection_extract_recursive(const LWCOLLECTION *col, uint32_t type, LWCOLLECTION *col_out)
static uint32_t lwcollection_largest_dimension(const LWCOLLECTION *col)
Examines contents of collection and finds the largest coordinate dimension of all components.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
lwflags_t flags
Definition liblwgeom.h:577
int32_t srid
Definition liblwgeom.h:576

References COLLECTIONTYPE, LWCOLLECTION::flags, FLAGS_GET_M, FLAGS_GET_Z, LINETYPE, lwcollection_as_lwgeom(), lwcollection_construct_empty(), lwcollection_extract_recursive(), lwcollection_largest_dimension(), lwerror(), lwgeom_add_bbox(), lwtype_multitype(), lwtype_name(), POINTTYPE, POLYGONTYPE, and LWCOLLECTION::srid.

Referenced by _lwt_AddLineEdge(), lwgeom_to_basic_type(), ST_CollectionExtract(), and test_lwcollection_extract().

Here is the call graph for this function:
Here is the caller graph for this function: