223 FuncCallContext *funcctx;
227 AttInMetadata *attinmeta;
228 MemoryContext oldcontext, newcontext;
233 if (SRF_IS_FIRSTCALL())
235 funcctx = SRF_FIRSTCALL_INIT();
236 newcontext = funcctx->multi_call_memory_ctx;
238 oldcontext = MemoryContextSwitchTo(newcontext);
240 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
243 elog(ERROR,
"Input is not a polygon");
251 assert (state->
poly);
254 funcctx->user_fctx = state;
260 get_call_result_type(fcinfo, 0, &tupdesc);
261 BlessTupleDesc(tupdesc);
267 attinmeta = TupleDescGetAttInMetadata(tupdesc);
268 funcctx->attinmeta = attinmeta;
270 MemoryContextSwitchTo(oldcontext);
274 funcctx = SRF_PERCALL_SETUP();
275 newcontext = funcctx->multi_call_memory_ctx;
278 state = funcctx->user_fctx;
289 oldcontext = MemoryContextSwitchTo(newcontext);
302 sprintf(address,
"{%d}", state->
ringnum);
307 MemoryContextSwitchTo(oldcontext);
309 tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
310 result = HeapTupleGetDatum(tuple);
312 SRF_RETURN_NEXT(funcctx, result);
315 SRF_RETURN_DONE(funcctx);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
void * lwalloc(size_t size)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)