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

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