PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ encode_ptarray()

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

Definition at line 106 of file mvt.c.

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

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

109 {
110  uint32_t offset = 0;
111  uint32_t i, c = 0;
112  int32_t dx, dy, x, y;
113 
114  /* loop points and add to buffer */
115  for (i = 0; i < pa->npoints; i++) {
116  /* move offset for command */
117  if (i == 0 || (i == 1 && type > MVT_POINT))
118  offset++;
119  /* skip closing point for rings */
120  if (type == MVT_RING && i == pa->npoints - 1)
121  break;
122  const POINT2D *p = getPoint2d_cp(pa, i);
123  x = p->x;
124  y = p->y;
125  dx = x - *px;
126  dy = y - *py;
127  buffer[offset++] = p_int(dx);
128  buffer[offset++] = p_int(dy);
129  *px = x;
130  *py = y;
131  c++;
132  }
133 
134  /* determine initial move and eventual line command */
135  if (type == MVT_POINT) {
136  /* point or multipoint, use actual number of point count */
137  buffer[0] = c_int(CMD_MOVE_TO, c);
138  } else {
139  /* line or polygon, assume count 1 */
140  buffer[0] = c_int(CMD_MOVE_TO, 1);
141  /* line command with move point subtracted from count */
142  buffer[3] = c_int(CMD_LINE_TO, c - 1);
143  }
144 
145  /* add close command if ring */
146  if (type == MVT_RING)
147  buffer[offset++] = c_int(CMD_CLOSE_PATH, 1);
148 
149  return offset;
150 }
Definition: mvt.c:49
int npoints
Definition: liblwgeom.h:371
static uint32_t c_int(enum mvt_cmd_id id, uint32_t count)
Definition: mvt.c:96
static uint32_t p_int(int32_t value)
Definition: mvt.c:101
unsigned int uint32_t
Definition: uthash.h:78
double x
Definition: liblwgeom.h:328
Datum buffer(PG_FUNCTION_ARGS)
Definition: mvt.c:51
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:373
double y
Definition: liblwgeom.h:328
type
Definition: ovdump.py:41
Here is the call graph for this function:
Here is the caller graph for this function: