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

◆ mvt_agg_transfn()

void mvt_agg_transfn ( mvt_agg_context ctx)

Aggregation step.

Expands features array if needed by a factor of 2. Allocates a new feature, increment feature counter and encode geometry and properties into it.  

Definition at line 1277 of file mvt.c.

1278{
1279 bool isnull = false;
1280 Datum datum;
1281 GSERIALIZED *gs;
1282 LWGEOM *lwgeom;
1283 VectorTile__Tile__Feature *feature;
1284 VectorTile__Tile__Layer *layer = ctx->layer;
1285/* VectorTile__Tile__Feature **features = layer->features; */
1286 POSTGIS_DEBUG(2, "mvt_agg_transfn called");
1287
1288 if (layer->n_features >= ctx->features_capacity)
1289 {
1290 size_t new_capacity = ctx->features_capacity * 2;
1291 layer->features = repalloc(layer->features, new_capacity *
1292 sizeof(*layer->features));
1293 ctx->features_capacity = new_capacity;
1294 POSTGIS_DEBUGF(3, "mvt_agg_transfn new_capacity: %zd", new_capacity);
1295 }
1296
1297 if (ctx->geom_index == UINT32_MAX)
1298 parse_column_keys(ctx);
1299
1300 datum = GetAttributeByNum(ctx->row, ctx->geom_index + 1, &isnull);
1301 POSTGIS_DEBUGF(3, "mvt_agg_transfn ctx->geom_index: %d", ctx->geom_index);
1302 POSTGIS_DEBUGF(3, "mvt_agg_transfn isnull: %u", isnull);
1303 POSTGIS_DEBUGF(3, "mvt_agg_transfn datum: %lu", datum);
1304 if (isnull) /* Skip rows that have null geometry */
1305 {
1306 POSTGIS_DEBUG(3, "mvt_agg_transfn got null geom");
1307 return;
1308 }
1309
1310 feature = palloc(sizeof(*feature));
1311 vector_tile__tile__feature__init(feature);
1312
1313 ctx->feature = feature;
1314
1315 gs = (GSERIALIZED *) PG_DETOAST_DATUM(datum);
1316 lwgeom = lwgeom_from_gserialized(gs);
1317
1318 POSTGIS_DEBUGF(3, "mvt_agg_transfn encoded feature count: %zd", layer->n_features);
1319 layer->features[layer->n_features++] = feature;
1320
1321 encode_geometry(ctx, lwgeom);
1322 lwgeom_free(lwgeom);
1323 // TODO: free detoasted datum?
1324 parse_values(ctx);
1325}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
#define UINT32_MAX
static void encode_geometry(mvt_agg_context *ctx, LWGEOM *lwgeom)
Definition mvt.c:274
static void parse_column_keys(mvt_agg_context *ctx)
Definition mvt.c:325
static void parse_values(mvt_agg_context *ctx)
Definition mvt.c:681
uint32_t geom_index
Definition mvt.h:64
size_t features_capacity
Definition mvt.h:69
VectorTile__Tile__Layer * layer
Definition mvt.h:67
VectorTile__Tile__Feature * feature
Definition mvt.h:66
HeapTupleHeader row
Definition mvt.h:65

References encode_geometry(), mvt_agg_context::feature, mvt_agg_context::features_capacity, mvt_agg_context::geom_index, mvt_agg_context::layer, lwgeom_free(), lwgeom_from_gserialized(), parse_column_keys(), parse_values(), mvt_agg_context::row, and UINT32_MAX.

Referenced by pgis_asmvt_transfn().

Here is the call graph for this function:
Here is the caller graph for this function: