PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 560 of file geobuf.c.

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

561 {
562  LWGEOM *lwgeom;
563  bool isnull = false;
564  Datum datum;
565  Data__FeatureCollection *fc = ctx->data->feature_collection;
566 /* Data__Feature **features = fc->features; */
567  Data__Feature *feature;
568  GSERIALIZED *gs;
569  if (fc->n_features >= ctx->features_capacity) {
570  size_t new_capacity = ctx->features_capacity * 2;
571  fc->features = repalloc(fc->features, new_capacity *
572  sizeof(*fc->features));
573  ctx->lwgeoms = repalloc(ctx->lwgeoms, new_capacity *
574  sizeof(*ctx->lwgeoms));
575  ctx->features_capacity = new_capacity;
576  }
577 
578  /* inspect row and encode keys assuming static schema */
579  if (fc->n_features == 0)
580  encode_keys(ctx);
581 
582  datum = GetAttributeByNum(ctx->row, ctx->geom_index + 1, &isnull);
583  if (isnull)
584  return;
585 
586  gs = (GSERIALIZED *) PG_DETOAST_DATUM_COPY(datum);
587  lwgeom = lwgeom_from_gserialized(gs);
588 
589  feature = encode_feature(ctx);
590 
591  /* inspect geometry flags assuming static schema */
592  if (fc->n_features == 0)
593  analyze_geometry_flags(ctx, lwgeom);
594 
595  analyze_geometry(ctx, lwgeom);
596 
597  ctx->lwgeoms[fc->n_features] = lwgeom;
598  fc->features[fc->n_features++] = feature;
599 }
HeapTupleHeader row
Definition: geobuf.h:52
static void analyze_geometry_flags(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
Definition: geobuf.c:495
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
size_t features_capacity
Definition: geobuf.h:56
LWGEOM ** lwgeoms
Definition: geobuf.h:53
uint32_t geom_index
Definition: geobuf.h:51
static void encode_keys(struct geobuf_agg_context *ctx)
Definition: geobuf.c:52
static Data__Feature * encode_feature(struct geobuf_agg_context *ctx)
Definition: geobuf.c:509
static void analyze_geometry(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
Definition: geobuf.c:462

Here is the call graph for this function:

Here is the caller graph for this function: