PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ encode_mline()

static Data__Geometry* encode_mline ( struct geobuf_agg_context ctx,
LWMLINE lwmline 
)
static

Definition at line 262 of file geobuf.c.

References geobuf_agg_context::dimensions, encode_coords(), galloc(), LWMLINE::geoms, LWMLINE::ngeoms, POINTARRAY::npoints, and LWLINE::points.

Referenced by encode_geometry().

264 {
265  int i, offset, ngeoms;
266  POINTARRAY *pa;
267  Data__Geometry *geometry;
268  uint32_t *lengths;
269  int64_t *coords = NULL;
270 
271  geometry = galloc(DATA__GEOMETRY__TYPE__MULTILINESTRING);
272 
273  ngeoms = lwmline->ngeoms;
274 
275  if (ngeoms == 0)
276  return geometry;
277 
278  lengths = palloc (sizeof (uint32_t) * ngeoms);
279 
280  offset = 0;
281  for (i = 0; i < ngeoms; i++) {
282  pa = lwmline->geoms[i]->points;
283  coords = encode_coords(ctx, pa, coords, pa->npoints, offset);
284  offset += pa->npoints * ctx->dimensions;
285  lengths[i] = pa->npoints;
286  }
287 
288  if (ngeoms > 1) {
289  geometry->n_lengths = ngeoms;
290  geometry->lengths = lengths;
291  }
292 
293  geometry->n_coords = offset;
294  geometry->coords = coords;
295 
296  return geometry;
297 }
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
uint32_t ngeoms
Definition: liblwgeom.h:483
LWLINE ** geoms
Definition: liblwgeom.h:485
POINTARRAY * points
Definition: liblwgeom.h:424
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: