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;
170 switch(lwgeom->
type) {
173 if (state->
pt == 0) {
176 if (state->
pt <= 3) {
234 ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
235 errmsg(
"Invalid Geometry type %d passed to ST_DumpPoints()", lwgeom->
type)));
249 if (--state->
stacklen == 0) SRF_RETURN_DONE(funcctx);
257 pathpt[0] = PointerGetDatum(construct_array(state->
path, state->
pathlen+1,
262 tuple = heap_form_tuple(funcctx->tuple_desc, pathpt, isnull);
263 result = HeapTupleGetDatum(tuple);
264 SRF_RETURN_NEXT(funcctx, result);
273 lwgeom = lwcoll->
geoms[node->
idx++];
288 if (--state->
stacklen == 0) SRF_RETURN_DONE(funcctx);
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
LWPOINT * lwpoint_make(int srid, int hasz, int hasm, const POINT4D *p)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_M(flags)
LWPOINT * lwline_get_lwpoint(const LWLINE *line, int where)
Returns freshly allocated LWPOINT that corresponds to the index where.
struct dumpnode stack[MAXDEPTH]
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
LWPOINT * lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, int where)
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)