PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ encode_ptarray()

static uint32_t encode_ptarray ( __attribute__((__unused__)) mvt_agg_context ctx,
enum mvt_type  type,
POINTARRAY pa,
uint32_t buffer,
int32_t *  px,
int32_t *  py 
)
static

Definition at line 116 of file mvt.c.

119 {
120  uint32_t offset = 0;
121  uint32_t i, c = 0;
122  int32_t dx, dy, x, y;
123  const POINT2D *p;
124 
125  /* loop points and add to buffer */
126  for (i = 0; i < pa->npoints; i++)
127  {
128  /* move offset for command */
129  if (i == 0 || (i == 1 && type > MVT_POINT))
130  offset++;
131  /* skip closing point for rings */
132  if (type == MVT_RING && i == pa->npoints - 1)
133  break;
134  p = getPoint2d_cp(pa, i);
135  x = p->x;
136  y = p->y;
137  dx = x - *px;
138  dy = y - *py;
139  buffer[offset++] = p_int(dx);
140  buffer[offset++] = p_int(dy);
141  *px = x;
142  *py = y;
143  c++;
144  }
145 
146  /* determine initial move and eventual line command */
147  if (type == MVT_POINT)
148  {
149  /* point or multipoint, use actual number of point count */
150  buffer[0] = c_int(CMD_MOVE_TO, c);
151  }
152  else
153  {
154  /* line or polygon, assume count 1 */
155  buffer[0] = c_int(CMD_MOVE_TO, 1);
156  /* line command with move point subtracted from count */
157  buffer[3] = c_int(CMD_LINE_TO, c - 1);
158  }
159 
160  /* add close command if ring */
161  if (type == MVT_RING)
162  buffer[offset++] = c_int(CMD_CLOSE_PATH, 1);
163 
164  return offset;
165 }
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwgeom_api.c:374
@ CMD_MOVE_TO
Definition: mvt.c:45
@ CMD_CLOSE_PATH
Definition: mvt.c:47
@ CMD_LINE_TO
Definition: mvt.c:46
static uint32_t c_int(enum mvt_cmd_id id, uint32_t count)
Definition: mvt.c:106
@ MVT_POINT
Definition: mvt.c:52
@ MVT_RING
Definition: mvt.c:54
static uint32_t p_int(int32_t value)
Definition: mvt.c:111
type
Definition: ovdump.py:41
Datum buffer(PG_FUNCTION_ARGS)
double y
Definition: liblwgeom.h:331
double x
Definition: liblwgeom.h:331
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

References buffer(), c_int(), CMD_CLOSE_PATH, CMD_LINE_TO, CMD_MOVE_TO, getPoint2d_cp(), MVT_POINT, MVT_RING, POINTARRAY::npoints, p_int(), ovdump::type, POINT2D::x, pixval::x, POINT2D::y, and pixval::y.

Referenced by encode_mline(), encode_mpoly(), encode_poly(), and encode_ptarray_initial().

Here is the call graph for this function:
Here is the caller graph for this function: