220{
223 FuncCallContext *funcctx;
225 TupleDesc tupdesc;
226 HeapTuple tuple;
227 MemoryContext oldcontext, newcontext;
229 char address[256];
230 char *values[2];
231
232 if (SRF_IS_FIRSTCALL())
233 {
234 funcctx = SRF_FIRSTCALL_INIT();
235 newcontext = funcctx->multi_call_memory_ctx;
236
237 oldcontext = MemoryContextSwitchTo(newcontext);
238
239 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
241 {
242 elog(ERROR, "Input is not a polygon");
243 }
244
246
247
250 assert (state->
poly);
252
253 funcctx->user_fctx = state;
254
255
256
257
258
259 get_call_result_type(fcinfo, 0, &tupdesc);
260 BlessTupleDesc(tupdesc);
261
262
263
264
265
266 funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);;
267
268 MemoryContextSwitchTo(oldcontext);
269 }
270
271
272 funcctx = SRF_PERCALL_SETUP();
273 newcontext = funcctx->multi_call_memory_ctx;
274
275
276 state = funcctx->user_fctx;
277
278
280 {
284
285
286
287 oldcontext = MemoryContextSwitchTo(newcontext);
288
289
291
292
295 NULL,
296 1,
297 &ring);
298
299
300 sprintf(address,
"{%d}", state->
ringnum);
301
302 values[0] = address;
304
305 MemoryContextSwitchTo(oldcontext);
306
307 tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
308 result = HeapTupleGetDatum(tuple);
310 SRF_RETURN_NEXT(funcctx,
result);
311 }
312
313 SRF_RETURN_DONE(funcctx);
314
315}
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,...
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)
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)