PostGIS  2.5.0dev-r@@SVN_REVISION@@
LWCIRCSTRING * lwcircstring_from_lwmpoint ( int  srid,
LWMPOINT mpoint 
)

Definition at line 192 of file lwcircstring.c.

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

193 {
194  uint32_t i;
195  POINTARRAY *pa;
196  char zmflag = FLAGS_GET_ZM(mpoint->flags);
197  size_t ptsize, size;
198  uint8_t *newpoints, *ptr;
199 
200  if (zmflag == 0) ptsize = 2 * sizeof(double);
201  else if (zmflag == 3) ptsize = 4 * sizeof(double);
202  else ptsize = 3 * sizeof(double);
203 
204  /* Allocate space for output points */
205  size = ptsize * mpoint->ngeoms;
206  newpoints = lwalloc(size);
207  memset(newpoints, 0, size);
208 
209  ptr = newpoints;
210  for (i = 0; i < mpoint->ngeoms; i++)
211  {
212  memcpy(ptr,
213  getPoint_internal(mpoint->geoms[i]->point, 0),
214  ptsize);
215  ptr += ptsize;
216  }
217 
218  pa = ptarray_construct_reference_data(zmflag&2, zmflag&1, mpoint->ngeoms, newpoints);
219 
220  LWDEBUGF(3, "lwcurve_from_lwmpoint: constructed pointarray for %d points, %d zmflag", mpoint->ngeoms, zmflag);
221 
222  return lwcircstring_construct(srid, NULL, pa);
223 }
uint32_t ngeoms
Definition: liblwgeom.h:467
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:152
uint8_t flags
Definition: liblwgeom.h:464
POINTARRAY * point
Definition: liblwgeom.h:410
unsigned int uint32_t
Definition: uthash.h:78
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:293
LWPOINT ** geoms
Definition: liblwgeom.h:469
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1743
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
unsigned char uint8_t
Definition: uthash.h:79
LWCIRCSTRING * lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwcircstring.c:50

Here is the call graph for this function: