PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_force_multi()

Datum LWGEOM_force_multi ( PG_FUNCTION_ARGS  )

Definition at line 509 of file lwgeom_functions_basic.c.

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 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: g_serialized.c:40
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 COLLECTIONTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:89
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
Definition: lwgeom.c:371
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTICURVETYPE
Definition: liblwgeom.h:95
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

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

Here is the call graph for this function: