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

◆ lwcircstring_from_lwmpoint()

LWCIRCSTRING * lwcircstring_from_lwmpoint ( int32_t  srid,
LWMPOINT mpoint 
)

Definition at line 186 of file lwcircstring.c.

187{
188 uint32_t i;
189 POINTARRAY *pa;
190 char zmflag = FLAGS_GET_ZM(mpoint->flags);
191 size_t ptsize, size;
192 uint8_t *newpoints, *ptr;
193
194 if (zmflag == 0) ptsize = 2 * sizeof(double);
195 else if (zmflag == 3) ptsize = 4 * sizeof(double);
196 else ptsize = 3 * sizeof(double);
197
198 /* Allocate space for output points */
199 size = ptsize * mpoint->ngeoms;
200 newpoints = lwalloc(size);
201 memset(newpoints, 0, size);
202
203 ptr = newpoints;
204 for (i = 0; i < mpoint->ngeoms; i++)
205 {
206 memcpy(ptr,
207 getPoint_internal(mpoint->geoms[i]->point, 0),
208 ptsize);
209 ptr += ptsize;
210 }
211
212 pa = ptarray_construct_reference_data(zmflag&2, zmflag&1, mpoint->ngeoms, newpoints);
213
214 LWDEBUGF(3, "lwcurve_from_lwmpoint: constructed pointarray for %d points, %d zmflag", mpoint->ngeoms, zmflag);
215
216 return lwcircstring_construct(srid, NULL, pa);
217}
POINTARRAY * ptarray_construct_reference_data(char hasz, char hasm, uint32_t npoints, uint8_t *ptlist)
Construct a new POINTARRAY, referencing to the data from ptlist.
Definition ptarray.c:291
void * lwalloc(size_t size)
Definition lwutil.c:227
#define FLAGS_GET_ZM(flags)
Definition liblwgeom.h:180
LWCIRCSTRING * lwcircstring_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition lwinline.h:75
lwflags_t flags
Definition liblwgeom.h:535
uint32_t ngeoms
Definition liblwgeom.h:538
LWPOINT ** geoms
Definition liblwgeom.h:533
POINTARRAY * point
Definition liblwgeom.h:471

References LWMPOINT::flags, FLAGS_GET_ZM, LWMPOINT::geoms, getPoint_internal(), lwalloc(), lwcircstring_construct(), LWDEBUGF, LWMPOINT::ngeoms, LWPOINT::point, and ptarray_construct_reference_data().

Here is the call graph for this function: