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

Definition at line 481 of file lwgeom_functions_basic.c.

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

482 {
483  GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
485  LWGEOM *lwgeom;
486  LWGEOM *ogeom;
487 
488  POSTGIS_DEBUG(2, "LWGEOM_force_multi called");
489 
490  /*
491  ** This funx is a no-op only if a bbox cache is already present
492  ** in input. If bbox cache is not there we'll need to handle
493  ** automatic bbox addition FOR_COMPLEX_GEOMS.
494  */
495  if ( gserialized_has_bbox(geom) ) {
496  switch (gserialized_get_type(geom))
497  {
498  case MULTIPOINTTYPE:
499  case MULTILINETYPE:
500  case MULTIPOLYGONTYPE:
501  case COLLECTIONTYPE:
502  case MULTICURVETYPE:
503  case MULTISURFACETYPE:
504  case TINTYPE:
505  PG_RETURN_POINTER(geom);
506  default:
507  break;
508  }
509  }
510 
511  /* deserialize into lwgeoms[0] */
512  lwgeom = lwgeom_from_gserialized(geom);
513  ogeom = lwgeom_as_multi(lwgeom);
514 
515  result = geometry_serialize(ogeom);
516 
517  PG_FREE_IF_COPY(geom, 0);
518 
519  PG_RETURN_POINTER(result);
520 }
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:56
#define MULTICURVETYPE
Definition: liblwgeom.h:70
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
Definition: lwgeom.c:284
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: g_serialized.c:20
char ** result
Definition: liblwgeom.h:218
LWGEOM * geom
#define TINTYPE
Definition: liblwgeom.h:74
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define MULTILINETYPE
Definition: liblwgeom.h:64
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function: