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

Definition at line 490 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.

491 {
492  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
493  GSERIALIZED *result;
494  LWGEOM *lwgeom;
495  LWGEOM *ogeom;
496 
497  POSTGIS_DEBUG(2, "LWGEOM_force_multi called");
498 
499  /*
500  ** This funx is a no-op only if a bbox cache is already present
501  ** in input. If bbox cache is not there we'll need to handle
502  ** automatic bbox addition FOR_COMPLEX_GEOMS.
503  */
504  if ( gserialized_has_bbox(geom) ) {
505  switch (gserialized_get_type(geom))
506  {
507  case MULTIPOINTTYPE:
508  case MULTILINETYPE:
509  case MULTIPOLYGONTYPE:
510  case COLLECTIONTYPE:
511  case MULTICURVETYPE:
512  case MULTISURFACETYPE:
513  case TINTYPE:
514  PG_RETURN_POINTER(geom);
515  default:
516  break;
517  }
518  }
519 
520  /* deserialize into lwgeoms[0] */
521  lwgeom = lwgeom_from_gserialized(geom);
522  ogeom = lwgeom_as_multi(lwgeom);
523 
524  result = geometry_serialize(ogeom);
525 
526  PG_FREE_IF_COPY(geom, 0);
527 
528  PG_RETURN_POINTER(result);
529 }
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:55
#define MULTICURVETYPE
Definition: liblwgeom.h:80
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
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:19
LWGEOM * geom
#define TINTYPE
Definition: liblwgeom.h:84
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define MULTILINETYPE
Definition: liblwgeom.h:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76

Here is the call graph for this function: