PostGIS  2.5.0dev-r@@SVN_REVISION@@
static int64_t* encode_coords ( struct geobuf_agg_context ctx,
POINTARRAY pa,
int64_t *  coords,
int  len,
int  offset 
)
static

Definition at line 168 of file geobuf.c.

References geobuf_agg_context::dimensions, geobuf_agg_context::e, getPoint4d_p(), POINT4D::m, POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by encode_line(), encode_mline(), encode_mpoint(), encode_mpoly(), encode_point(), and encode_poly().

170 {
171  int i, c;
172  POINT4D pt;
173  int64_t sum[] = { 0, 0, 0, 0 };
174 
175  if (offset == 0)
176  coords = palloc(sizeof (int64_t) * len * ctx->dimensions);
177  else
178  coords = repalloc(coords, sizeof (int64_t) *
179  ((len * ctx->dimensions) + offset));
180 
181  c = offset;
182  for (i = 0; i < len; i++) {
183  getPoint4d_p(pa, i, &pt);
184  sum[0] += coords[c++] = (int64_t) (ceil(pt.x * ctx->e) - sum[0]);
185  sum[1] += coords[c++] = (int64_t) (ceil(pt.y * ctx->e) - sum[1]);
186  if (ctx->dimensions == 3)
187  sum[2] += coords[c++] = (int64_t) (ceil(pt.z * ctx->e) - sum[2]);
188  else if (ctx->dimensions == 4)
189  sum[3] += coords[c++] = (int64_t) (ceil(pt.m * ctx->e) - sum[3]);
190  }
191  return coords;
192 }
double x
Definition: liblwgeom.h:351
double m
Definition: liblwgeom.h:351
uint32_t dimensions
Definition: geobuf.h:61
double z
Definition: liblwgeom.h:351
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:113
double y
Definition: liblwgeom.h:351
uint32_t e
Definition: geobuf.h:57

Here is the call graph for this function:

Here is the caller graph for this function: