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

◆ encode_ptarray()

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

Definition at line 149 of file mvt.c.

150{
151 uint32_t offset = 0;
152 uint32_t i, c = 0;
153 int32_t dx, dy, x, y;
154 const POINT2D *p;
155
156 /* loop points and add to buffer */
157 for (i = 0; i < pa->npoints; i++)
158 {
159 /* move offset for command */
160 if (i == 0 || (i == 1 && type > MVT_POINT))
161 offset++;
162 /* skip closing point for rings */
163 if (type == MVT_RING && i == pa->npoints - 1)
164 break;
165 p = getPoint2d_cp(pa, i);
166 x = p->x;
167 y = p->y;
168 dx = x - *px;
169 dy = y - *py;
170 buffer[offset++] = p_int(dx);
171 buffer[offset++] = p_int(dy);
172 *px = x;
173 *py = y;
174 c++;
175 }
176
177 /* determine initial move and eventual line command */
178 if (type == MVT_POINT)
179 {
180 /* point or multipoint, use actual number of point count */
181 buffer[0] = c_int(CMD_MOVE_TO, c);
182 }
183 else
184 {
185 /* line or polygon, assume count 1 */
186 buffer[0] = c_int(CMD_MOVE_TO, 1);
187 /* line command with move point subtracted from count */
188 buffer[3] = c_int(CMD_LINE_TO, c - 1);
189 }
190
191 /* add close command if ring */
192 if (type == MVT_RING)
193 buffer[offset++] = c_int(CMD_CLOSE_PATH, 1);
194
195 return offset;
196}
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:97
@ CMD_MOVE_TO
Definition mvt.c:50
@ CMD_CLOSE_PATH
Definition mvt.c:52
@ CMD_LINE_TO
Definition mvt.c:51
static uint32_t c_int(enum mvt_cmd_id id, uint32_t count)
Definition mvt.c:139
@ MVT_POINT
Definition mvt.c:57
@ MVT_RING
Definition mvt.c:59
static uint32_t p_int(int32_t value)
Definition mvt.c:144
Datum buffer(PG_FUNCTION_ARGS)
double y
Definition liblwgeom.h:390
double x
Definition liblwgeom.h:390
uint32_t npoints
Definition liblwgeom.h:427

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: