PostGIS  2.3.7dev-r@@SVN_REVISION@@
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_from_gserialized(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, and TINTYPE.

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:69
#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:297
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: g_serialized.c:33
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: