PostGIS  2.5.0dev-r@@SVN_REVISION@@
static Data__Geometry* encode_poly ( struct geobuf_agg_context ctx,
LWPOLY lwpoly 
)
static

Definition at line 298 of file geobuf.c.

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

Referenced by encode_geometry().

300 {
301  int i, len, nrings, offset;
302  POINTARRAY *pa;
303  Data__Geometry *geometry;
304  uint32_t *lengths;
305  int64_t *coords = NULL;
306 
307  geometry = galloc(DATA__GEOMETRY__TYPE__POLYGON);
308 
309  nrings = lwpoly->nrings;
310 
311  if (nrings == 0)
312  return geometry;
313 
314  lengths = palloc (sizeof (uint32_t) * nrings);
315 
316  offset = 0;
317  for (i = 0; i < nrings; i++) {
318  pa = lwpoly->rings[i];
319  len = pa->npoints - 1;
320  coords = encode_coords(ctx, pa, coords, len, offset);
321  offset += len * ctx->dimensions;
322  lengths[i] = len;
323  }
324 
325  if (nrings > 1) {
326  geometry->n_lengths = nrings;
327  geometry->lengths = lengths;
328  }
329 
330  geometry->n_coords = offset;
331  geometry->coords = coords;
332 
333  return geometry;
334 }
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
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: