PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ 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 }
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:309
#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:370
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#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:695
static int lwcollection_extract_recursive(const LWCOLLECTION *col, uint32_t type, LWCOLLECTION *col_out)
Definition: lwcollection.c:408
static uint32_t lwcollection_largest_dimension(const LWCOLLECTION *col)
Examines contents of collection and finds the largest coordinate dimension of all components.
Definition: lwcollection.c:384
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
Definition: lwcollection.c:92
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
type
Definition: ovdump.py:42
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, LWCOLLECTION::srid, and ovdump::type.

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: