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

◆ 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 624 of file geobuf.c.

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