PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum LWGEOM_force_multi ( PG_FUNCTION_ARGS  )

Definition at line 506 of file lwgeom_functions_basic.c.

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

507 {
508  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
509  GSERIALIZED *result;
510  LWGEOM *lwgeom;
511  LWGEOM *ogeom;
512 
513  POSTGIS_DEBUG(2, "LWGEOM_force_multi called");
514 
515  /*
516  ** This funx is a no-op only if a bbox cache is already present
517  ** in input. If bbox cache is not there we'll need to handle
518  ** automatic bbox addition FOR_COMPLEX_GEOMS.
519  */
520  if ( gserialized_has_bbox(geom) ) {
521  switch (gserialized_get_type(geom))
522  {
523  case MULTIPOINTTYPE:
524  case MULTILINETYPE:
525  case MULTIPOLYGONTYPE:
526  case COLLECTIONTYPE:
527  case MULTICURVETYPE:
528  case MULTISURFACETYPE:
529  case TINTYPE:
530  PG_RETURN_POINTER(geom);
531  default:
532  break;
533  }
534  }
535 
536  /* deserialize into lwgeoms[0] */
537  lwgeom = lwgeom_from_gserialized(geom);
538  ogeom = lwgeom_as_multi(lwgeom);
539 
540  result = geometry_serialize(ogeom);
541 
542  PG_FREE_IF_COPY(geom, 0);
543 
544  PG_RETURN_POINTER(result);
545 }
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:94
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
Definition: lwgeom.c:364
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:98
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define MULTILINETYPE
Definition: liblwgeom.h:88
#define COLLECTIONTYPE
Definition: liblwgeom.h:90

Here is the call graph for this function: