349{
350 int i, j, c, len, offset, n_lengths, ngeoms, nrings;
352 Data__Geometry *geometry;
353 uint32_t *lengths;
354 int64_t *coords = NULL;
355
356 geometry =
galloc(DATA__GEOMETRY__TYPE__MULTIPOLYGON);
357
359
360 if (ngeoms == 0) return geometry;
361
362 n_lengths = 1;
363 for (i = 0; i < ngeoms; i++) {
365 n_lengths++;
366 for (j = 0; j < nrings; j++)
367 n_lengths++;
368 }
369
370 lengths = palloc (sizeof (uint32_t) * n_lengths);
371
372 c = 0;
373 offset = 0;
374 lengths[c++] = ngeoms;
375 for (i = 0; i < ngeoms; i++) {
377 lengths[c++] = nrings;
378 for (j = 0; j < nrings; j++) {
383 lengths[c++] = len;
384 }
385 }
386
387 if (c > 1) {
388 geometry->n_lengths = n_lengths;
389 geometry->lengths = lengths;
390 }
391
392 geometry->n_coords = offset;
393 geometry->coords = coords;
394
395 return geometry;
396}
static int64_t * encode_coords(struct geobuf_agg_context *ctx, POINTARRAY *pa, int64_t *coords, int len, int offset)
static Data__Geometry * galloc(Data__Geometry__Type type)