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

◆ ptarray_from_twkb_state()

static POINTARRAY * ptarray_from_twkb_state ( twkb_parse_state s,
uint32_t  npoints 
)
static

POINTARRAY Read a dynamically sized point array and advance the parse state forward.

Definition at line 172 of file lwin_twkb.c.

173{
174 POINTARRAY *pa = NULL;
175 uint32_t ndims = s->ndims;
176 uint32_t i;
177 double *dlist;
178
179 LWDEBUG(2,"Entering ptarray_from_twkb_state");
180 LWDEBUGF(4,"Pointarray has %d points", npoints);
181
182 /* Empty! */
183 if( npoints == 0 )
184 return ptarray_construct_empty(s->has_z, s->has_m, 0);
185
186 pa = ptarray_construct(s->has_z, s->has_m, npoints);
187 dlist = (double*)(pa->serialized_pointlist);
188 for( i = 0; i < npoints; i++ )
189 {
190 int j = 0;
191 /* X */
192 s->coords[j] += twkb_parse_state_varint(s);
193 dlist[ndims*i + j] = s->coords[j] / s->factor;
194 j++;
195 /* Y */
196 s->coords[j] += twkb_parse_state_varint(s);
197 dlist[ndims*i + j] = s->coords[j] / s->factor;
198 j++;
199 /* Z */
200 if ( s->has_z )
201 {
202 s->coords[j] += twkb_parse_state_varint(s);
203 dlist[ndims*i + j] = s->coords[j] / s->factor_z;
204 j++;
205 }
206 /* M */
207 if ( s->has_m )
208 {
209 s->coords[j] += twkb_parse_state_varint(s);
210 dlist[ndims*i + j] = s->coords[j] / s->factor_m;
211 j++;
212 }
213 }
214
215 return pa;
216}
char * s
Definition cu_in_wkt.c:23
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition ptarray.c:59
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition ptarray.c:51
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
static int64_t twkb_parse_state_varint(twkb_parse_state *s)
Definition lwin_twkb.c:93
uint8_t * serialized_pointlist
Definition liblwgeom.h:434

References LWDEBUG, LWDEBUGF, ptarray_construct(), ptarray_construct_empty(), s, POINTARRAY::serialized_pointlist, and twkb_parse_state_varint().

Referenced by lwline_from_twkb_state(), lwpoint_from_twkb_state(), and lwpoly_from_twkb_state().

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