PostGIS  3.1.6dev-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 89 of file mvt.c.

92 {
93  uint32_t offset = 0;
94  uint32_t i, c = 0;
95  int32_t dx, dy, x, y;
96  const POINT2D *p;
97 
98  /* loop points and add to buffer */
99  for (i = 0; i < pa->npoints; i++)
100  {
101  /* move offset for command */
102  if (i == 0 || (i == 1 && type > MVT_POINT))
103  offset++;
104  /* skip closing point for rings */
105  if (type == MVT_RING && i == pa->npoints - 1)
106  break;
107  p = getPoint2d_cp(pa, i);
108  x = p->x;
109  y = p->y;
110  dx = x - *px;
111  dy = y - *py;
112  buffer[offset++] = p_int(dx);
113  buffer[offset++] = p_int(dy);
114  *px = x;
115  *py = y;
116  c++;
117  }
118 
119  /* determine initial move and eventual line command */
120  if (type == MVT_POINT)
121  {
122  /* point or multipoint, use actual number of point count */
123  buffer[0] = c_int(CMD_MOVE_TO, c);
124  }
125  else
126  {
127  /* line or polygon, assume count 1 */
128  buffer[0] = c_int(CMD_MOVE_TO, 1);
129  /* line command with move point subtracted from count */
130  buffer[3] = c_int(CMD_LINE_TO, c - 1);
131  }
132 
133  /* add close command if ring */
134  if (type == MVT_RING)
135  buffer[offset++] = c_int(CMD_CLOSE_PATH, 1);
136 
137  return offset;
138 }
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwinline.h:101
@ CMD_MOVE_TO
Definition: mvt.c:54
@ CMD_CLOSE_PATH
Definition: mvt.c:56
@ CMD_LINE_TO
Definition: mvt.c:55
static uint32_t c_int(enum mvt_cmd_id id, uint32_t count)
Definition: mvt.c:79
@ MVT_POINT
Definition: mvt.c:61
@ MVT_RING
Definition: mvt.c:63
static uint32_t p_int(int32_t value)
Definition: mvt.c:84
type
Definition: ovdump.py:42
Datum buffer(PG_FUNCTION_ARGS)
double y
Definition: liblwgeom.h:404
double x
Definition: liblwgeom.h:404
uint32_t npoints
Definition: liblwgeom.h:441

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: