299 FuncCallContext *funcctx;
300 MemoryContext oldcontext, newcontext;
310 bool isnull[2] = {0, 0};
313 if (SRF_IS_FIRSTCALL())
315 funcctx = SRF_FIRSTCALL_INIT();
317 newcontext = funcctx->multi_call_memory_ctx;
318 oldcontext = MemoryContextSwitchTo(newcontext);
320 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
326 MemoryContextSwitchTo(oldcontext);
327 funcctx = SRF_PERCALL_SETUP();
328 SRF_RETURN_DONE(funcctx);
332 state =
lwalloc(
sizeof *state);
333 state->
root = lwgeom;
339 funcctx->user_fctx = state;
351 if (get_call_result_type(fcinfo, 0, &funcctx->tuple_desc) != TYPEFUNC_COMPOSITE)
354 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
355 errmsg(
"set-valued function called in context that cannot accept a set")));
358 BlessTupleDesc(funcctx->tuple_desc);
361 get_typlenbyvalalign(INT4OID, &state->
typlen, &state->
byval, &state->
align);
363 MemoryContextSwitchTo(oldcontext);
367 funcctx = SRF_PERCALL_SETUP();
368 newcontext = funcctx->multi_call_memory_ctx;
371 state = funcctx->user_fctx;
460 pathpt[0] = PointerGetDatum(construct_array(state->
path,
466 pathpt[1] = PointerGetDatum(geometry_serialize((
LWGEOM *)segment));
468 tuple = heap_form_tuple(funcctx->tuple_desc, pathpt, isnull);
469 result = HeapTupleGetDatum(tuple);
470 SRF_RETURN_NEXT(funcctx,
result);
475 SRF_RETURN_DONE(funcctx);
490 lwgeom = lwcoll->
geoms[node->
idx++];
507 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]