222 FuncCallContext *funcctx;
226 AttInMetadata *attinmeta;
227 MemoryContext oldcontext, newcontext;
232 if (SRF_IS_FIRSTCALL())
234 funcctx = SRF_FIRSTCALL_INIT();
235 newcontext = funcctx->multi_call_memory_ctx;
237 oldcontext = MemoryContextSwitchTo(newcontext);
239 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
242 elog(ERROR,
"Input is not a polygon");
250 assert (state->
poly);
253 funcctx->user_fctx = state;
259 get_call_result_type(fcinfo, 0, &tupdesc);
260 BlessTupleDesc(tupdesc);
266 attinmeta = TupleDescGetAttInMetadata(tupdesc);
267 funcctx->attinmeta = attinmeta;
269 MemoryContextSwitchTo(oldcontext);
273 funcctx = SRF_PERCALL_SETUP();
274 newcontext = funcctx->multi_call_memory_ctx;
277 state = funcctx->user_fctx;
288 oldcontext = MemoryContextSwitchTo(newcontext);
301 sprintf(address,
"{%d}", state->
ringnum);
306 MemoryContextSwitchTo(oldcontext);
308 tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
309 result = HeapTupleGetDatum(tuple);
311 SRF_RETURN_NEXT(funcctx, result);
314 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 *g)
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)
void * lwalloc(size_t size)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)