PostGIS  3.7.0dev-r@@SVN_REVISION@@

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

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