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

◆ lwcircstring_from_lwpointarray()

LWCIRCSTRING * lwcircstring_from_lwpointarray ( int32_t  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}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
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
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:116
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:179
void * lwalloc(size_t size)
Definition lwutil.c:227
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:180
LWCIRCSTRING * lwcircstring_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition lwinline.h:67
static size_t ptarray_point_size(const POINTARRAY *pa)
Definition lwinline.h:48

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

Here is the call graph for this function: