225 FuncCallContext *funcctx;
229 AttInMetadata *attinmeta;
230 MemoryContext oldcontext, newcontext;
235 if (SRF_IS_FIRSTCALL())
237 funcctx = SRF_FIRSTCALL_INIT();
238 newcontext = funcctx->multi_call_memory_ctx;
240 oldcontext = MemoryContextSwitchTo(newcontext);
242 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
245 elog(ERROR,
"Input is not a polygon");
253 assert (state->
poly);
256 funcctx->user_fctx = state;
262 get_call_result_type(fcinfo, 0, &tupdesc);
263 BlessTupleDesc(tupdesc);
269 attinmeta = TupleDescGetAttInMetadata(tupdesc);
270 funcctx->attinmeta = attinmeta;
272 MemoryContextSwitchTo(oldcontext);
276 funcctx = SRF_PERCALL_SETUP();
277 newcontext = funcctx->multi_call_memory_ctx;
280 state = funcctx->user_fctx;
291 oldcontext = MemoryContextSwitchTo(newcontext);
304 sprintf(address,
"{%d}", state->
ringnum);
309 MemoryContextSwitchTo(oldcontext);
311 tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
312 result = HeapTupleGetDatum(tuple);
314 SRF_RETURN_NEXT(funcctx,
result);
317 SRF_RETURN_DONE(funcctx);
char result[OUT_DOUBLE_BUFFER_SIZE]
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_buffer(const LWGEOM *geom, uint8_t variant)
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)