338         FuncCallContext *funcctx;
 
  339         collection_fctx *fctx;
 
  340         MemoryContext oldcontext;
 
  343         if (SRF_IS_FIRSTCALL())
 
  349                 int maxvertices = 128;
 
  350                 double gridSize = -1;
 
  353                 funcctx = SRF_FIRSTCALL_INIT();
 
  358                 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
  363                 gser = PG_GETARG_GSERIALIZED_P(0);
 
  369                 if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
 
  370                         maxvertices = PG_GETARG_INT32(1);
 
  375                 if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
 
  376                         gridSize = PG_GETARG_FLOAT8(2);
 
  384                         SRF_RETURN_DONE(funcctx);
 
  387                 fctx = (collection_fctx *) palloc(
sizeof(collection_fctx));
 
  391                 fctx->numgeoms = col->
ngeoms;
 
  395                 funcctx->user_fctx = fctx;
 
  396                 MemoryContextSwitchTo(oldcontext);
 
  400         funcctx = SRF_PERCALL_SETUP();
 
  401         fctx = funcctx->user_fctx;
 
  403         if (fctx->nextgeom < fctx->numgeoms)
 
  405                 GSERIALIZED *gpart = geometry_serialize(fctx->col->geoms[fctx->nextgeom]);
 
  407                 SRF_RETURN_NEXT(funcctx, PointerGetDatum(gpart));
 
  412                 SRF_RETURN_DONE(funcctx);
 
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWCOLLECTION * lwgeom_subdivide_prec(const LWGEOM *geom, uint32_t maxvertices, double gridSize)