PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ geobuf_agg_finalfn()

uint8_t* geobuf_agg_finalfn ( struct geobuf_agg_context ctx)

Finalize aggregation.

Encode into Data message and return it packed as a bytea.

Definition at line 623 of file geobuf.c.

624 {
625  size_t i, len;
626  Data *data;
627  Data__FeatureCollection *fc;
628  uint8_t *buf;
629 
630  data = ctx->data;
631  fc = data->feature_collection;
632 
633  /* check and set dimensions if not default */
634  if (ctx->dimensions != 2) {
635  data->has_dimensions = ctx->has_dimensions;
636  data->dimensions = ctx->dimensions;
637  }
638 
639  /* check and set precision if not default */
640  if (ctx->e > MAX_PRECISION)
641  ctx->e = MAX_PRECISION;
642  ctx->precision = ceil(log(ctx->e) / log(10));
643  if (ctx->precision != 6) {
644  data->has_precision = 1;
645  data->precision = ctx->precision;
646  }
647 
648  for (i = 0; i < fc->n_features; i++)
649  fc->features[i]->geometry = encode_geometry(ctx, ctx->lwgeoms[i]);
650 
651  len = data__get_packed_size(data);
652  buf = palloc(sizeof(*buf) * (len + VARHDRSZ));
653  data__pack(data, buf + VARHDRSZ);
654 
655  SET_VARSIZE(buf, VARHDRSZ + len);
656 
657  return buf;
658 }
#define MAX_PRECISION
Definition: geobuf.c:31
static Data__Geometry * encode_geometry(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
Definition: geobuf.c:424
data
Definition: ovdump.py:104
uint32_t precision
Definition: geobuf.h:59
uint32_t e
Definition: geobuf.h:57
protobuf_c_boolean has_dimensions
Definition: geobuf.h:60
LWGEOM ** lwgeoms
Definition: geobuf.h:53
uint32_t dimensions
Definition: geobuf.h:61

References geobuf_agg_context::data, ovdump::data, geobuf_agg_context::dimensions, geobuf_agg_context::e, encode_geometry(), geobuf_agg_context::has_dimensions, geobuf_agg_context::lwgeoms, MAX_PRECISION, and geobuf_agg_context::precision.

Referenced by pgis_asgeobuf_finalfn().

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