PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ encode_poly()

static Data__Geometry* encode_poly ( struct geobuf_agg_context ctx,
LWPOLY lwpoly 
)
static

Definition at line 309 of file geobuf.c.

311 {
312  int i, len, nrings, offset;
313  POINTARRAY *pa;
314  Data__Geometry *geometry;
315  uint32_t *lengths;
316  int64_t *coords = NULL;
317 
318  geometry = galloc(DATA__GEOMETRY__TYPE__POLYGON);
319 
320  nrings = lwpoly->nrings;
321 
322  if (nrings == 0)
323  return geometry;
324 
325  lengths = palloc (sizeof (uint32_t) * nrings);
326 
327  offset = 0;
328  for (i = 0; i < nrings; i++) {
329  pa = lwpoly->rings[i];
330  len = pa->npoints - 1;
331  coords = encode_coords(ctx, pa, coords, len, offset);
332  offset += len * ctx->dimensions;
333  lengths[i] = len;
334  }
335 
336  if (nrings > 1) {
337  geometry->n_lengths = nrings;
338  geometry->lengths = lengths;
339  }
340 
341  geometry->n_coords = offset;
342  geometry->coords = coords;
343 
344  return geometry;
345 }
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
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(), 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: