PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ mvt_agg_finalfn()

uint8_t* mvt_agg_finalfn ( struct mvt_agg_context ctx)

Finalize aggregation.

Encode keys and values and put the aggregated Layer message into a Tile message and returns it packed as a bytea.

Definition at line 942 of file mvt.c.

References encode_keys(), encode_values(), and mvt_agg_context::layer.

Referenced by pgis_asmvt_finalfn().

943 {
944  VectorTile__Tile__Layer *layers[1];
945  VectorTile__Tile tile = VECTOR_TILE__TILE__INIT;
946  size_t len;
947  uint8_t *buf;
948 
949  POSTGIS_DEBUG(2, "mvt_agg_finalfn called");
950  POSTGIS_DEBUGF(2, "mvt_agg_finalfn n_features == %zd", ctx->layer->n_features);
951 
952  /* Zero features => empty bytea output */
953  if (ctx->layer->n_features == 0)
954  {
955  buf = palloc(VARHDRSZ);
956  SET_VARSIZE(buf, VARHDRSZ);
957  return buf;
958  }
959 
960  encode_keys(ctx);
961  encode_values(ctx);
962 
963  layers[0] = ctx->layer;
964 
965  tile.n_layers = 1;
966  tile.layers = layers;
967 
968  len = vector_tile__tile__get_packed_size(&tile);
969  buf = palloc(sizeof(*buf) * (len + VARHDRSZ));
970  vector_tile__tile__pack(&tile, buf + VARHDRSZ);
971 
972  SET_VARSIZE(buf, VARHDRSZ + len);
973 
974  return buf;
975 }
static void encode_keys(struct mvt_agg_context *ctx)
Definition: mvt.c:346
static void encode_values(struct mvt_agg_context *ctx)
Definition: mvt.c:378
VectorTile__Tile__Layer * layer
Definition: mvt.h:56
unsigned char uint8_t
Definition: uthash.h:79
Here is the call graph for this function:
Here is the caller graph for this function: