PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcircstring_from_lwmpoint()

LWCIRCSTRING * lwcircstring_from_lwmpoint ( int  srid,
LWMPOINT mpoint 
)

Definition at line 199 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().

200 {
201  uint32_t i;
202  POINTARRAY *pa;
203  char zmflag = FLAGS_GET_ZM(mpoint->flags);
204  size_t ptsize, size;
205  uint8_t *newpoints, *ptr;
206 
207  if (zmflag == 0) ptsize = 2 * sizeof(double);
208  else if (zmflag == 3) ptsize = 4 * sizeof(double);
209  else ptsize = 3 * sizeof(double);
210 
211  /* Allocate space for output points */
212  size = ptsize * mpoint->ngeoms;
213  newpoints = lwalloc(size);
214  memset(newpoints, 0, size);
215 
216  ptr = newpoints;
217  for (i = 0; i < mpoint->ngeoms; i++)
218  {
219  memcpy(ptr,
220  getPoint_internal(mpoint->geoms[i]->point, 0),
221  ptsize);
222  ptr += ptsize;
223  }
224 
225  pa = ptarray_construct_reference_data(zmflag&2, zmflag&1, mpoint->ngeoms, newpoints);
226 
227  LWDEBUGF(3, "lwcurve_from_lwmpoint: constructed pointarray for %d points, %d zmflag", mpoint->ngeoms, zmflag);
228 
229  return lwcircstring_construct(srid, NULL, pa);
230 }
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
uint8_t flags
Definition: liblwgeom.h:465
POINTARRAY * point
Definition: liblwgeom.h:411
unsigned int uint32_t
Definition: uthash.h:78
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
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:295
LWPOINT ** geoms
Definition: liblwgeom.h:470
void * lwalloc(size_t size)
Definition: lwutil.c:229
int ngeoms
Definition: liblwgeom.h:468
#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:51
Here is the call graph for this function: