339 FuncCallContext *funcctx;
340 collection_fctx *fctx;
341 MemoryContext oldcontext;
344 if (SRF_IS_FIRSTCALL())
349 int maxvertices = 256;
352 funcctx = SRF_FIRSTCALL_INIT();
357 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
362 gser = PG_GETARG_GSERIALIZED_P(0);
368 if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
369 maxvertices = PG_GETARG_INT32(1);
377 SRF_RETURN_DONE(funcctx);
380 fctx = (collection_fctx *) palloc(
sizeof(collection_fctx));
384 fctx->numgeoms = col->
ngeoms;
388 funcctx->user_fctx = fctx;
389 MemoryContextSwitchTo(oldcontext);
393 funcctx = SRF_PERCALL_SETUP();
394 fctx = funcctx->user_fctx;
396 if (fctx->nextgeom < fctx->numgeoms)
400 SRF_RETURN_NEXT(funcctx, PointerGetDatum(gpart));
405 SRF_RETURN_DONE(funcctx);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWCOLLECTION * lwgeom_subdivide(const LWGEOM *geom, uint32_t maxvertices)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)