PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ encode_poly()

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

Definition at line 299 of file geobuf.c.

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

Referenced by encode_geometry().

301 {
302  int i, len, nrings, offset;
303  POINTARRAY *pa;
304  Data__Geometry *geometry;
305  uint32_t *lengths;
306  int64_t *coords = NULL;
307 
308  geometry = galloc(DATA__GEOMETRY__TYPE__POLYGON);
309 
310  nrings = lwpoly->nrings;
311 
312  if (nrings == 0)
313  return geometry;
314 
315  lengths = palloc (sizeof (uint32_t) * nrings);
316 
317  offset = 0;
318  for (i = 0; i < nrings; i++) {
319  pa = lwpoly->rings[i];
320  len = pa->npoints - 1;
321  coords = encode_coords(ctx, pa, coords, len, offset);
322  offset += len * ctx->dimensions;
323  lengths[i] = len;
324  }
325 
326  if (nrings > 1) {
327  geometry->n_lengths = nrings;
328  geometry->lengths = lengths;
329  }
330 
331  geometry->n_coords = offset;
332  geometry->coords = coords;
333 
334  return geometry;
335 }
int npoints
Definition: liblwgeom.h:371
static Data__Geometry * galloc(Data__Geometry__Type type)
Definition: geobuf.c:36
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:168
POINTARRAY ** rings
Definition: liblwgeom.h:457
int nrings
Definition: liblwgeom.h:455
Here is the call graph for this function:
Here is the caller graph for this function: