PostGIS  2.5.0dev-r@@SVN_REVISION@@
static Data__Geometry* encode_mpoly ( struct geobuf_agg_context ctx,
LWMPOLY lwmpoly 
)
static

Definition at line 336 of file geobuf.c.

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

Referenced by encode_geometry().

338 {
339  int i, j, c, len, offset, n_lengths, ngeoms, nrings;
340  POINTARRAY *pa;
341  Data__Geometry *geometry;
342  uint32_t *lengths;
343  int64_t *coords = NULL;
344 
345  geometry = galloc(DATA__GEOMETRY__TYPE__MULTIPOLYGON);
346 
347  ngeoms = lwmpoly->ngeoms;
348 
349  if (ngeoms == 0) return geometry;
350 
351  n_lengths = 1;
352  for (i = 0; i < ngeoms; i++) {
353  nrings = lwmpoly->geoms[i]->nrings;
354  n_lengths++;
355  for (j = 0; j < nrings; j++)
356  n_lengths++;
357  }
358 
359  lengths = palloc (sizeof (uint32_t) * n_lengths);
360 
361  c = 0;
362  offset = 0;
363  lengths[c++] = ngeoms;
364  for (i = 0; i < ngeoms; i++) {
365  nrings = lwmpoly->geoms[i]->nrings;
366  lengths[c++] = nrings;
367  for (j = 0; j < nrings; j++) {
368  pa = lwmpoly->geoms[i]->rings[j];
369  len = pa->npoints - 1;
370  coords = encode_coords(ctx, pa, coords, len, offset);
371  offset += len * ctx->dimensions;
372  lengths[c++] = len;
373  }
374  }
375 
376  if (c > 1) {
377  geometry->n_lengths = n_lengths;
378  geometry->lengths = lengths;
379  }
380 
381  geometry->n_coords = offset;
382  geometry->coords = coords;
383 
384  return geometry;
385 }
uint32_t ngeoms
Definition: liblwgeom.h:493
static Data__Geometry * galloc(Data__Geometry__Type type)
Definition: geobuf.c:36
uint32_t nrings
Definition: liblwgeom.h:454
uint32_t dimensions
Definition: geobuf.h:61
unsigned int uint32_t
Definition: uthash.h:78
LWPOLY ** geoms
Definition: liblwgeom.h:495
static int64_t * encode_coords(struct geobuf_agg_context *ctx, POINTARRAY *pa, int64_t *coords, int len, int offset)
Definition: geobuf.c:167
POINTARRAY ** rings
Definition: liblwgeom.h:456
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: