PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_force_multi()

Datum LWGEOM_force_multi ( PG_FUNCTION_ARGS  )

Definition at line 505 of file lwgeom_functions_basic.c.

References COLLECTIONTYPE, dumpnode::geom, geometry_serialize(), gserialized_get_type(), gserialized_has_bbox(), lwgeom_as_multi(), LWGEOM_force_curve(), lwgeom_from_gserialized(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, PG_FUNCTION_INFO_V1(), and TINTYPE.

Referenced by LWGEOM_force_collection().

506 {
507  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
508  GSERIALIZED *result;
509  LWGEOM *lwgeom;
510  LWGEOM *ogeom;
511 
512  POSTGIS_DEBUG(2, "LWGEOM_force_multi called");
513 
514  /*
515  ** This funx is a no-op only if a bbox cache is already present
516  ** in input. If bbox cache is not there we'll need to handle
517  ** automatic bbox addition FOR_COMPLEX_GEOMS.
518  */
519  if ( gserialized_has_bbox(geom) ) {
520  switch (gserialized_get_type(geom))
521  {
522  case MULTIPOINTTYPE:
523  case MULTILINETYPE:
524  case MULTIPOLYGONTYPE:
525  case COLLECTIONTYPE:
526  case MULTICURVETYPE:
527  case MULTISURFACETYPE:
528  case TINTYPE:
529  PG_RETURN_POINTER(geom);
530  default:
531  break;
532  }
533  }
534 
535  /* deserialize into lwgeoms[0] */
536  lwgeom = lwgeom_from_gserialized(geom);
537  ogeom = lwgeom_as_multi(lwgeom);
538 
539  result = geometry_serialize(ogeom);
540 
541  PG_FREE_IF_COPY(geom, 0);
542 
543  PG_RETURN_POINTER(result);
544 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:86
#define MULTICURVETYPE
Definition: liblwgeom.h:95
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
Definition: lwgeom.c:333
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: g_serialized.c:40
LWGEOM * geom
#define TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: