76 FuncCallContext *funcctx;
77 MemoryContext oldcontext, newcontext;
87 bool isnull[2] = {0,0};
90 if (SRF_IS_FIRSTCALL()) {
91 funcctx = SRF_FIRSTCALL_INIT();
93 newcontext = funcctx->multi_call_memory_ctx;
94 oldcontext = MemoryContextSwitchTo(newcontext);
97 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
102 MemoryContextSwitchTo(oldcontext);
103 funcctx = SRF_PERCALL_SETUP();
104 SRF_RETURN_DONE(funcctx);
108 state =
lwalloc(
sizeof *state);
109 state->
root = lwgeom;
115 funcctx->user_fctx = state;
128 if (get_call_result_type(fcinfo, 0, &funcctx->tuple_desc) != TYPEFUNC_COMPOSITE) {
129 ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
130 errmsg(
"set-valued function called in context that cannot accept a set")));
133 BlessTupleDesc(funcctx->tuple_desc);
136 get_typlenbyvalalign(INT4OID, &state->
typlen, &state->
byval, &state->
align);
138 MemoryContextSwitchTo(oldcontext);
142 funcctx = SRF_PERCALL_SETUP();
143 newcontext = funcctx->multi_call_memory_ctx;
146 state = funcctx->user_fctx;
171 switch(lwgeom->
type) {
174 if (state->
pt == 0) {
177 if (state->
pt <= 3) {
235 ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
236 errmsg(
"Invalid Geometry type %d passed to ST_DumpPoints()", lwgeom->
type)));
251 if (--state->
stacklen == 0) SRF_RETURN_DONE(funcctx);
259 pathpt[0] = PointerGetDatum(construct_array(state->
path, state->
pathlen+1,
264 tuple = heap_form_tuple(funcctx->tuple_desc, pathpt, isnull);
265 result = HeapTupleGetDatum(tuple);
266 SRF_RETURN_NEXT(funcctx, result);
275 lwgeom = lwcoll->
geoms[node->
idx++];
290 if (--state->
stacklen == 0) SRF_RETURN_DONE(funcctx);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWPOINT * lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, uint32_t where)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
#define FLAGS_GET_M(flags)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
void * lwalloc(size_t size)
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
LWPOINT * lwpoint_make(int srid, int hasz, int hasm, const POINT4D *p)
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
struct dumpnode stack[MAXDEPTH]