402{
406 int32 idx = PG_GETARG_INT32(1);
408
410 {
412 PG_FREE_IF_COPY(geom, 0);
413 elog(ERROR, "ST_PatchN only supports TIN and PolyhedralSurface geometries");
414 }
415
416
418
419 if (!subgeom)
420 PG_RETURN_NULL();
421
422
423 if (subgeom == lwgeom)
424 PG_RETURN_POINTER(geom);
425
427
429
430 result = geometry_serialize(subgeom);
432 PG_FREE_IF_COPY(geom, 0);
433 PG_RETURN_POINTER(
result);
434}
char result[OUT_DOUBLE_BUFFER_SIZE]
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
int lwgeom_has_patches(const LWGEOM *geom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
static LWGEOM * lwgeom_extract_geometry_n(LWGEOM *lwgeom, int32 idx, bool patches_as_geometries)