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

◆ geobuf_agg_transfn()

void geobuf_agg_transfn ( struct geobuf_agg_context ctx)

Aggregation step.

Expands features array if needed by a factor of 2. Allocates a new feature, increment feature counter and encode properties into it.  

Definition at line 578 of file geobuf.c.

579{
580 LWGEOM *lwgeom;
581 bool isnull = false;
582 Datum datum;
583 Data__FeatureCollection *fc = ctx->data->feature_collection;
584/* Data__Feature **features = fc->features; */
585 Data__Feature *feature;
586 GSERIALIZED *gs;
587 if (fc->n_features >= ctx->features_capacity) {
588 size_t new_capacity = ctx->features_capacity * 2;
589 fc->features = repalloc(fc->features, new_capacity *
590 sizeof(*fc->features));
591 ctx->lwgeoms = repalloc(ctx->lwgeoms, new_capacity *
592 sizeof(*ctx->lwgeoms));
593 ctx->features_capacity = new_capacity;
594 }
595
596 /* inspect row and encode keys assuming static schema */
597 if (fc->n_features == 0)
598 encode_keys(ctx);
599
600 datum = GetAttributeByNum(ctx->row, ctx->geom_index + 1, &isnull);
601 if (isnull)
602 return;
603
604 gs = (GSERIALIZED *) PG_DETOAST_DATUM_COPY(datum);
605 lwgeom = lwgeom_from_gserialized(gs);
606
607 feature = encode_feature(ctx);
608
609 /* inspect geometry flags assuming static schema */
610 if (fc->n_features == 0)
611 analyze_geometry_flags(ctx, lwgeom);
612
613 analyze_geometry(ctx, lwgeom);
614
615 ctx->lwgeoms[fc->n_features] = lwgeom;
616 fc->features[fc->n_features++] = feature;
617}
static void analyze_geometry_flags(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
Definition geobuf.c:512
static void analyze_geometry(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
Definition geobuf.c:477
static void encode_keys(struct geobuf_agg_context *ctx)
Definition geobuf.c:53
static Data__Feature * encode_feature(struct geobuf_agg_context *ctx)
Definition geobuf.c:527
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
HeapTupleHeader row
Definition geobuf.h:52
uint32_t geom_index
Definition geobuf.h:51
size_t features_capacity
Definition geobuf.h:56
LWGEOM ** lwgeoms
Definition geobuf.h:53

References analyze_geometry(), analyze_geometry_flags(), geobuf_agg_context::data, encode_feature(), encode_keys(), geobuf_agg_context::features_capacity, geobuf_agg_context::geom_index, lwgeom_from_gserialized(), geobuf_agg_context::lwgeoms, and geobuf_agg_context::row.

Referenced by pgis_asgeobuf_transfn().

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