350{
351 int i, j, c, len, offset, n_lengths, ngeoms, nrings;
353 Data__Geometry *geometry;
354 uint32_t *lengths;
355 int64_t *coords = NULL;
356
357 geometry =
galloc(DATA__GEOMETRY__TYPE__MULTIPOLYGON);
358
360
361 if (ngeoms == 0) return geometry;
362
363 n_lengths = 1;
364 for (i = 0; i < ngeoms; i++) {
366 n_lengths++;
367 for (j = 0; j < nrings; j++)
368 n_lengths++;
369 }
370
371 lengths = palloc (sizeof (uint32_t) * n_lengths);
372
373 c = 0;
374 offset = 0;
375 lengths[c++] = ngeoms;
376 for (i = 0; i < ngeoms; i++) {
378 lengths[c++] = nrings;
379 for (j = 0; j < nrings; j++) {
384 lengths[c++] = len;
385 }
386 }
387
388 if (c > 1) {
389 geometry->n_lengths = n_lengths;
390 geometry->lengths = lengths;
391 }
392
393 geometry->n_coords = offset;
394 geometry->coords = coords;
395
396 return geometry;
397}
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)