PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ encode_mpoly()

static Data__Geometry* encode_mpoly ( struct geobuf_agg_context ctx,
LWMPOLY lwmpoly 
)
static

Definition at line 347 of file geobuf.c.

349 {
350  int i, j, c, len, offset, n_lengths, ngeoms, nrings;
351  POINTARRAY *pa;
352  Data__Geometry *geometry;
353  uint32_t *lengths;
354  int64_t *coords = NULL;
355 
356  geometry = galloc(DATA__GEOMETRY__TYPE__MULTIPOLYGON);
357 
358  ngeoms = lwmpoly->ngeoms;
359 
360  if (ngeoms == 0) return geometry;
361 
362  n_lengths = 1;
363  for (i = 0; i < ngeoms; i++) {
364  nrings = lwmpoly->geoms[i]->nrings;
365  n_lengths++;
366  for (j = 0; j < nrings; j++)
367  n_lengths++;
368  }
369 
370  lengths = palloc (sizeof (uint32_t) * n_lengths);
371 
372  c = 0;
373  offset = 0;
374  lengths[c++] = ngeoms;
375  for (i = 0; i < ngeoms; i++) {
376  nrings = lwmpoly->geoms[i]->nrings;
377  lengths[c++] = nrings;
378  for (j = 0; j < nrings; j++) {
379  pa = lwmpoly->geoms[i]->rings[j];
380  len = pa->npoints - 1;
381  coords = encode_coords(ctx, pa, coords, len, offset);
382  offset += len * ctx->dimensions;
383  lengths[c++] = len;
384  }
385  }
386 
387  if (c > 1) {
388  geometry->n_lengths = n_lengths;
389  geometry->lengths = lengths;
390  }
391 
392  geometry->n_coords = offset;
393  geometry->coords = coords;
394 
395  return geometry;
396 }
static Data__Geometry * galloc(Data__Geometry__Type type)
Definition: geobuf.c:36
static int64_t * encode_coords(struct geobuf_agg_context *ctx, POINTARRAY *pa, int64_t *coords, int len, int offset)
Definition: geobuf.c:161
uint32_t ngeoms
Definition: liblwgeom.h:566
LWPOLY ** geoms
Definition: liblwgeom.h:561
POINTARRAY ** rings
Definition: liblwgeom.h:519
uint32_t nrings
Definition: liblwgeom.h:524
uint32_t npoints
Definition: liblwgeom.h:427
uint32_t dimensions
Definition: geobuf.h:61

References geobuf_agg_context::dimensions, encode_coords(), galloc(), LWMPOLY::geoms, LWMPOLY::ngeoms, POINTARRAY::npoints, LWPOLY::nrings, and LWPOLY::rings.

Referenced by encode_geometry().

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