249{
250 uint32_t dims = 2;
251 uint32_t i;
252 int append_points = 0;
255 GEOSCoordSeq sq;
256
258
259 if (fix_ring)
260 {
262 {
263 lwerror(
"ptarray_to_GEOSCoordSeq called with fix_ring and 0 vertices in ring, cannot fix");
264 return NULL;
265 }
266 else
267 {
270 }
271 }
272
273 if (!(sq = GEOSCoordSeq_create(pa->
npoints + append_points, dims)))
274 {
275 lwerror(
"Error creating GEOS Coordinate Sequence");
276 return NULL;
277 }
278
279 for (i = 0; i < pa->
npoints; i++)
280 {
281 if (dims == 3)
282 {
285 LWDEBUGF(4,
"Point: %g,%g,%g", p3d->
x, p3d->
y, p3d->
z);
286 }
287 else
288 {
291 }
292
293#if POSTGIS_GEOS_VERSION < 38
294 GEOSCoordSeq_setX(sq, i, p2d->
x);
295 GEOSCoordSeq_setY(sq, i, p2d->
y);
296 if (dims == 3) GEOSCoordSeq_setZ(sq, i, p3d->
z);
297#else
298 if (dims == 3)
299 GEOSCoordSeq_setXYZ(sq, i, p2d->
x, p2d->
y, p3d->
z);
300 else
301 GEOSCoordSeq_setXY(sq, i, p2d->
x, p2d->
y);
302#endif
303
304 }
305
306 if (append_points)
307 {
308 if (dims == 3)
309 {
312 }
313 else
316 {
317#if POSTGIS_GEOS_VERSION < 38
318 GEOSCoordSeq_setX(sq, i, p2d->
x);
319 GEOSCoordSeq_setY(sq, i, p2d->
y);
320#else
321 GEOSCoordSeq_setXY(sq, i, p2d->
x, p2d->
y);
322#endif
323
324 if (dims == 3) GEOSCoordSeq_setZ(sq, i, p3d->
z);
325 }
326 }
327
328 return sq;
329}
#define FLAGS_GET_Z(flags)
int ptarray_is_closed_2d(const POINTARRAY *pa)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static const POINT3D * getPoint3d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.