PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ LWGEOM_geometryn_collection()

Datum LWGEOM_geometryn_collection ( PG_FUNCTION_ARGS  )

Definition at line 373 of file lwgeom_ogc.c.

374 {
375  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
376  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
377  GSERIALIZED *result = NULL;
378  int32 idx = PG_GETARG_INT32(1);
379  LWGEOM *subgeom = NULL;
380 
381  /* TIN and PolyhedralSurface are treated as unitary geometries */
382  subgeom = lwgeom_extract_geometry_n(lwgeom, idx, false);
383 
384  if (!subgeom)
385  PG_RETURN_NULL();
386 
387  /* If returning the original geometry */
388  if (subgeom == lwgeom)
389  {
390  lwgeom_free(lwgeom);
391  PG_FREE_IF_COPY(geom, 0);
392  PG_RETURN_POINTER(geom);
393  }
394 
395  subgeom->srid = lwgeom->srid;
396  /* COMPUTE_BBOX==TAINTING */
397  if (lwgeom->bbox) lwgeom_add_bbox(subgeom);
398 
399  result = geometry_serialize(subgeom);
400  lwgeom_free(lwgeom);
401  PG_FREE_IF_COPY(geom, 0);
402  PG_RETURN_POINTER(result);
403 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1218
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:695
static LWGEOM * lwgeom_extract_geometry_n(LWGEOM *lwgeom, int32 idx, bool patches_as_geometries)
Definition: lwgeom_ogc.c:320
unsigned int int32
Definition: shpopen.c:54
GBOX * bbox
Definition: liblwgeom.h:458
int32_t srid
Definition: liblwgeom.h:460

References LWGEOM::bbox, lwgeom_add_bbox(), lwgeom_extract_geometry_n(), lwgeom_free(), lwgeom_from_gserialized(), result, and LWGEOM::srid.

Here is the call graph for this function: