PostGIS  2.5.7dev-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 607 of file geobuf.c.

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

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: