PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ encode_mpoly()

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

Definition at line 348 of file geobuf.c.

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