PostGIS  2.4.9dev-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 606 of file geobuf.c.

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().

607 {
608  int i;
609  Data *data;
610  Data__FeatureCollection *fc;
611 
612  data = ctx->data;
613  fc = data->feature_collection;
614 
615  /* check and set dimensions if not default */
616  if (ctx->dimensions != 2) {
617  data->has_dimensions = ctx->has_dimensions;
618  data->dimensions = ctx->dimensions;
619  }
620 
621  /* check and set precision if not default */
622  if (ctx->e > MAX_PRECISION)
623  ctx->e = MAX_PRECISION;
624  ctx->precision = ceil(log(ctx->e) / log(10));
625  if (ctx->precision != 6) {
626  data->has_precision = 1;
627  data->precision = ctx->precision;
628  }
629 
630  for (i = 0; i < fc->n_features; i++)
631  fc->features[i]->geometry = encode_geometry(ctx, ctx->lwgeoms[i]);
632 
633  size_t len = data__get_packed_size(data);
634  uint8_t *buf = palloc(sizeof(*buf) * (len + VARHDRSZ));
635  data__pack(data, buf + VARHDRSZ);
636 
637  SET_VARSIZE(buf, VARHDRSZ + len);
638 
639  return buf;
640 }
static Data__Geometry * encode_geometry(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
Definition: geobuf.c:414
protobuf_c_boolean has_dimensions
Definition: geobuf.h:60
data
Definition: ovdump.py:103
#define MAX_PRECISION
Definition: geobuf.c:31
uint32_t dimensions
Definition: geobuf.h:61
uint32_t precision
Definition: geobuf.h:59
LWGEOM ** lwgeoms
Definition: geobuf.h:53
unsigned char uint8_t
Definition: uthash.h:79
uint32_t e
Definition: geobuf.h:57
Here is the call graph for this function:
Here is the caller graph for this function: