PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 122 of file mvt.c.

125{
126 uint32_t offset = 0;
127 uint32_t i, c = 0;
128 int32_t dx, dy, x, y;
129 const POINT2D *p;
130
131 /* loop points and add to buffer */
132 for (i = 0; i < pa->npoints; i++)
133 {
134 /* move offset for command */
135 if (i == 0 || (i == 1 && type > MVT_POINT))
136 offset++;
137 /* skip closing point for rings */
138 if (type == MVT_RING && i == pa->npoints - 1)
139 break;
140 p = getPoint2d_cp(pa, i);
141 x = p->x;
142 y = p->y;
143 dx = x - *px;
144 dy = y - *py;
145 buffer[offset++] = p_int(dx);
146 buffer[offset++] = p_int(dy);
147 *px = x;
148 *py = y;
149 c++;
150 }
151
152 /* determine initial move and eventual line command */
153 if (type == MVT_POINT)
154 {
155 /* point or multipoint, use actual number of point count */
156 buffer[0] = c_int(CMD_MOVE_TO, c);
157 }
158 else
159 {
160 /* line or polygon, assume count 1 */
161 buffer[0] = c_int(CMD_MOVE_TO, 1);
162 /* line command with move point subtracted from count */
163 buffer[3] = c_int(CMD_LINE_TO, c - 1);
164 }
165
166 /* add close command if ring */
167 if (type == MVT_RING)
168 buffer[offset++] = c_int(CMD_CLOSE_PATH, 1);
169
170 return offset;
171}
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:91
@ CMD_MOVE_TO
Definition mvt.c:51
@ CMD_CLOSE_PATH
Definition mvt.c:53
@ CMD_LINE_TO
Definition mvt.c:52
static uint32_t c_int(enum mvt_cmd_id id, uint32_t count)
Definition mvt.c:112
@ MVT_POINT
Definition mvt.c:58
@ MVT_RING
Definition mvt.c:60
static uint32_t p_int(int32_t value)
Definition mvt.c:117
Datum buffer(PG_FUNCTION_ARGS)
double y
Definition liblwgeom.h:376
double x
Definition liblwgeom.h:376
uint32_t npoints
Definition liblwgeom.h:413

References buffer(), c_int(), CMD_CLOSE_PATH, CMD_LINE_TO, CMD_MOVE_TO, getPoint2d_cp(), MVT_POINT, MVT_RING, POINTARRAY::npoints, p_int(), POINT2D::x, and POINT2D::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: