303 FuncCallContext *funcctx;
304 MemoryContext oldcontext, newcontext;
314 bool isnull[2] = {0, 0};
317 if (SRF_IS_FIRSTCALL())
319 funcctx = SRF_FIRSTCALL_INIT();
321 newcontext = funcctx->multi_call_memory_ctx;
322 oldcontext = MemoryContextSwitchTo(newcontext);
324 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
330 MemoryContextSwitchTo(oldcontext);
331 funcctx = SRF_PERCALL_SETUP();
332 SRF_RETURN_DONE(funcctx);
336 state =
lwalloc(
sizeof *state);
337 state->
root = lwgeom;
343 funcctx->user_fctx = state;
355 if (get_call_result_type(fcinfo, 0, &funcctx->tuple_desc) != TYPEFUNC_COMPOSITE)
358 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
359 errmsg(
"set-valued function called in context that cannot accept a set")));
362 BlessTupleDesc(funcctx->tuple_desc);
365 get_typlenbyvalalign(INT4OID, &state->
typlen, &state->
byval, &state->
align);
367 MemoryContextSwitchTo(oldcontext);
371 funcctx = SRF_PERCALL_SETUP();
372 newcontext = funcctx->multi_call_memory_ctx;
375 state = funcctx->user_fctx;
464 pathpt[0] = PointerGetDatum(construct_array(state->
path,
470 pathpt[1] = PointerGetDatum(geometry_serialize((
LWGEOM *)segment));
472 tuple = heap_form_tuple(funcctx->tuple_desc, pathpt, isnull);
473 result = HeapTupleGetDatum(tuple);
474 SRF_RETURN_NEXT(funcctx,
result);
479 SRF_RETURN_DONE(funcctx);
494 elog(ERROR,
"Unable to dump overly nested collection");
497 lwgeom = lwcoll->
geoms[node->
idx++];
514 SRF_RETURN_DONE(funcctx);
char result[OUT_DOUBLE_BUFFER_SIZE]
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
void * lwalloc(size_t size)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
struct dumpnode stack[MAXDEPTH]