47 size_t *result_count) {
55 PGR_DBG(
"total edges %ld", edgesSize);
58 for (
size_t i = 0; i < edgesSize; ++i) {
59 PGR_DBG(
"x1=%f y1=%f", edgesArr[i].x1, edgesArr[i].y1);
60 PGR_DBG(
"x2=%f y2=%f", edgesArr[i].x2, edgesArr[i].y2);
65 if (edgesArr) pfree(edgesArr);
66 elog(ERROR,
"Less than 3 vertices."
67 " pgr_alphaShape needs at least 3 vertices.");
72 PGR_DBG(
"Calling alpha-shape driver\n");
76 char* notice_msg = NULL;
88 if (err_msg && (*res)) {
96 if (log_msg) pfree(log_msg);
97 if (notice_msg) pfree(notice_msg);
98 if (err_msg) pfree(err_msg);
99 if (edgesArr) pfree(edgesArr);
107 FuncCallContext *funcctx;
108 TupleDesc tuple_desc;
112 size_t result_count = 0;
115 if (SRF_IS_FIRSTCALL()) {
116 MemoryContext oldcontext;
117 funcctx = SRF_FIRSTCALL_INIT();
118 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
123 text_to_cstring(PG_GETARG_TEXT_P(0)),
130 #if PGSQL_VERSION > 95
131 funcctx->max_calls = result_count;
133 funcctx->max_calls = (uint32_t)result_count;
136 funcctx->user_fctx = result_tuples;
137 if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
139 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
140 errmsg(
"function returning record called in context "
141 "that cannot accept type record")));
143 funcctx->tuple_desc = tuple_desc;
144 MemoryContextSwitchTo(oldcontext);
147 funcctx = SRF_PERCALL_SETUP();
148 tuple_desc = funcctx->tuple_desc;
149 result_tuples = (
GeomText_t*) funcctx->user_fctx;
151 if (funcctx->call_cntr < funcctx->max_calls) {
156 size_t call_cntr = funcctx->call_cntr;
160 values = palloc(numb *
sizeof(Datum));
161 nulls = palloc(numb *
sizeof(
bool));
164 for (i = 0; i < numb; ++i) {
168 values[0] = Int64GetDatum(call_cntr + 1);
169 values[1] = CStringGetTextDatum(result_tuples[call_cntr].geom);
171 tuple = heap_form_tuple(tuple_desc, values, nulls);
172 result = HeapTupleGetDatum(tuple);
173 SRF_RETURN_NEXT(funcctx, result);
175 SRF_RETURN_DONE(funcctx);