PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ pgis_asmvt_transfn()

Datum pgis_asmvt_transfn ( PG_FUNCTION_ARGS  )

Definition at line 126 of file lwgeom_out_mvt.c.

127{
128#ifndef HAVE_LIBPROTOBUF
129 elog(ERROR, "ST_AsMVT: Compiled without protobuf-c support");
130 PG_RETURN_NULL();
131#else
132 MemoryContext aggcontext, old_context;
133 mvt_agg_context *ctx;
134
135 /* We need to initialize the internal cache to access it later via postgis_oid() */
136 postgis_initialize_cache();
137
138 if (!AggCheckCallContext(fcinfo, &aggcontext))
139 elog(ERROR, "%s called in non-aggregate context", __func__);
140
141 if (PG_ARGISNULL(0)) {
142 old_context = MemoryContextSwitchTo(aggcontext);
143 ctx = palloc(sizeof(*ctx));
144 ctx->name = "default";
145 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
146 ctx->name = text_to_cstring(PG_GETARG_TEXT_P(2));
147 ctx->extent = 4096;
148 if (PG_NARGS() > 3 && !PG_ARGISNULL(3))
149 ctx->extent = PG_GETARG_INT32(3);
150 ctx->geom_name = NULL;
151 if (PG_NARGS() > 4 && !PG_ARGISNULL(4))
152 ctx->geom_name = text_to_cstring(PG_GETARG_TEXT_P(4));
153 if (PG_NARGS() > 5 && !PG_ARGISNULL(5))
154 ctx->id_name = text_to_cstring(PG_GETARG_TEXT_P(5));
155 else
156 ctx->id_name = NULL;
157
158 ctx->trans_context = AllocSetContextCreate(aggcontext, "MVT transfn", ALLOCSET_DEFAULT_SIZES);
159
160 MemoryContextSwitchTo(ctx->trans_context);
162 MemoryContextSwitchTo(old_context);
163 } else {
164 ctx = (mvt_agg_context *) PG_GETARG_POINTER(0);
165 }
166
167 if (!type_is_rowtype(get_fn_expr_argtype(fcinfo->flinfo, 1)))
168 elog(ERROR, "%s: parameter row cannot be other than a rowtype", __func__);
169 ctx->row = PG_GETARG_HEAPTUPLEHEADER(1);
170
171 old_context = MemoryContextSwitchTo(ctx->trans_context);
172 mvt_agg_transfn(ctx);
173 MemoryContextSwitchTo(old_context);
174
175 PG_FREE_IF_COPY(ctx->row, 1);
176 PG_RETURN_POINTER(ctx);
177#endif
178}
void mvt_agg_init_context(mvt_agg_context *ctx)
Initialize aggregation context.
Definition mvt.c:988
void mvt_agg_transfn(mvt_agg_context *ctx)
Aggregation step.
Definition mvt.c:1030
char * id_name
Definition mvt.h:67
char * geom_name
Definition mvt.h:71
MemoryContext trans_context
Definition mvt.h:62
uint32_t extent
Definition mvt.h:64
HeapTupleHeader row
Definition mvt.h:74
char * name
Definition mvt.h:63

References mvt_agg_context::extent, mvt_agg_context::geom_name, mvt_agg_context::id_name, mvt_agg_init_context(), mvt_agg_transfn(), mvt_agg_context::name, mvt_agg_context::row, and mvt_agg_context::trans_context.

Here is the call graph for this function: