PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwcircstring_from_lwpointarray()

LWCIRCSTRING * lwcircstring_from_lwpointarray ( int  srid,
uint32_t  npoints,
LWPOINT **  points 
)

Definition at line 141 of file lwcircstring.c.

142 {
143  int zmflag=0;
144  uint32_t i;
145  POINTARRAY *pa;
146  uint8_t *newpoints, *ptr;
147  size_t ptsize, size;
148 
149  /*
150  * Find output dimensions, check integrity
151  */
152  for (i = 0; i < npoints; i++)
153  {
154  if (points[i]->type != POINTTYPE)
155  {
156  lwerror("lwcurve_from_lwpointarray: invalid input type: %s",
157  lwtype_name(points[i]->type));
158  return NULL;
159  }
160  if (FLAGS_GET_Z(points[i]->flags)) zmflag |= 2;
161  if (FLAGS_GET_M(points[i]->flags)) zmflag |= 1;
162  if (zmflag == 3) break;
163  }
164 
165  if (zmflag == 0) ptsize = 2 * sizeof(double);
166  else if (zmflag == 3) ptsize = 4 * sizeof(double);
167  else ptsize = 3 * sizeof(double);
168 
169  /*
170  * Allocate output points array
171  */
172  size = ptsize * npoints;
173  newpoints = lwalloc(size);
174  memset(newpoints, 0, size);
175 
176  ptr = newpoints;
177  for (i = 0; i < npoints; i++)
178  {
179  size = ptarray_point_size(points[i]->point);
180  memcpy(ptr, getPoint_internal(points[i]->point, 0), size);
181  ptr += ptsize;
182  }
183  pa = ptarray_construct_reference_data(zmflag&2, zmflag&1, npoints, newpoints);
184 
185  return lwcircstring_construct(srid, NULL, pa);
186 }
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
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1750
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
size_t ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
void * lwalloc(size_t size)
Definition: lwutil.c:229
LWCIRCSTRING * lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwcircstring.c:50
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
type
Definition: ovdump.py:41
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

References FLAGS_GET_M, FLAGS_GET_Z, getPoint_internal(), lwalloc(), lwcircstring_construct(), lwerror(), lwtype_name(), POINTTYPE, ptarray_construct_reference_data(), ptarray_point_size(), and ovdump::type.

Here is the call graph for this function: