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

◆ lwcircstring_from_lwpointarray()

LWCIRCSTRING * lwcircstring_from_lwpointarray ( int32_t  srid,
uint32_t  npoints,
const LWPOINT **  points 
)

Definition at line 140 of file lwcircstring.c.

141{
142 uint32_t i;
143 POINTARRAY *pa;
144 int has_z = 0, has_m = 0;
145 POINT4D pt;
146
147 /*
148 * Find output dimensions, check integrity
149 */
150 for (i = 0; i < npoints; i++)
151 {
152 const LWGEOM *lwg = (LWGEOM*)points[i];
153 if (lwg->type != POINTTYPE)
154 {
155 lwerror("%s: invalid input type: %s", __func__, lwtype_name(lwg->type));
156 return NULL;
157 }
158 has_z |= lwgeom_has_z(lwg);
159 has_m |= lwgeom_has_m(lwg);
160 if (has_z && has_m) break;
161 }
162
163 /*
164 * Allocate output points array
165 */
166 pa = ptarray_construct(has_z, has_m, npoints);
167
168 for (i = 0; i < npoints; i++)
169 {
170 const LWPOINT *lwpt = points[i];
171 if (!getPoint4d_p(lwpt->point, 0, &pt))
172 {
173 lwerror("%s: failed getPoint4d_p", __func__);
174 return NULL;
175 }
176 ptarray_set_point4d(pa, i, &pt);
177 }
178
179 return lwcircstring_construct(srid, NULL, pa);
180}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition lwgeom.c:962
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition lwgeom.c:969
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition lwgeom_api.c:369
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition ptarray.c:51
LWCIRCSTRING * lwcircstring_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
uint8_t type
Definition liblwgeom.h:462
POINTARRAY * point
Definition liblwgeom.h:471

References getPoint4d_p(), lwcircstring_construct(), lwerror(), lwgeom_has_m(), lwgeom_has_z(), lwtype_name(), LWPOINT::point, POINTTYPE, ptarray_construct(), ptarray_set_point4d(), and LWGEOM::type.

Here is the call graph for this function: