PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ encode_poly()

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

Definition at line 310 of file geobuf.c.

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