PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ LWGEOM_force_multi()

Datum LWGEOM_force_multi ( PG_FUNCTION_ARGS  )

Definition at line 509 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().

510 {
511  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
512  GSERIALIZED *result;
513  LWGEOM *lwgeom;
514  LWGEOM *ogeom;
515 
516  POSTGIS_DEBUG(2, "LWGEOM_force_multi called");
517 
518  /*
519  ** This funx is a no-op only if a bbox cache is already present
520  ** in input. If bbox cache is not there we'll need to handle
521  ** automatic bbox addition FOR_COMPLEX_GEOMS.
522  */
523  if ( gserialized_has_bbox(geom) ) {
524  switch (gserialized_get_type(geom))
525  {
526  case MULTIPOINTTYPE:
527  case MULTILINETYPE:
528  case MULTIPOLYGONTYPE:
529  case COLLECTIONTYPE:
530  case MULTICURVETYPE:
531  case MULTISURFACETYPE:
532  case TINTYPE:
533  PG_RETURN_POINTER(geom);
534  default:
535  break;
536  }
537  }
538 
539  /* deserialize into lwgeoms[0] */
540  lwgeom = lwgeom_from_gserialized(geom);
541  ogeom = lwgeom_as_multi(lwgeom);
542 
543  result = geometry_serialize(ogeom);
544 
545  PG_FREE_IF_COPY(geom, 0);
546 
547  PG_RETURN_POINTER(result);
548 }
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:371
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:
Here is the caller graph for this function: