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

◆ ptarray_from_GEOSCoordSeq()

POINTARRAY * ptarray_from_GEOSCoordSeq ( const GEOSCoordSequence *  cs,
uint8_t  want3d 
)

Definition at line 144 of file liblwgeom/lwgeom_geos.c.

145{
146 uint32_t dims = 2;
147 POINTARRAY* pa;
148 uint32_t size = 0;
149#if POSTGIS_GEOS_VERSION < 31000
150 uint32_t i;
151 POINT4D point = { 0.0, 0.0, 0.0, 0.0 };
152#endif
153
154 LWDEBUG(2, "ptarray_fromGEOSCoordSeq called");
155
156 if (!GEOSCoordSeq_getSize(cs, &size)) lwerror("Exception thrown");
157
158 LWDEBUGF(4, " GEOSCoordSeq size: %d", size);
159
160 if (want3d)
161 {
162 if (!GEOSCoordSeq_getDimensions(cs, &dims)) lwerror("Exception thrown");
163
164 LWDEBUGF(4, " GEOSCoordSeq dimensions: %d", dims);
165
166 /* forget higher dimensions (if any) */
167 if (dims > 3) dims = 3;
168 }
169
170 LWDEBUGF(4, " output dimensions: %d", dims);
171
172 pa = ptarray_construct((dims == 3), 0, size);
173#if POSTGIS_GEOS_VERSION >= 31000
174 GEOSCoordSeq_copyToBuffer(cs, (double*) pa->serialized_pointlist, (dims == 3), 0);
175 return pa;
176#else
177 for (i = 0; i < size; i++)
178 {
179 if (dims >= 3)
180 GEOSCoordSeq_getXYZ(cs, i, &(point.x), &(point.y), &(point.z));
181 else
182 GEOSCoordSeq_getXY(cs, i, &(point.x), &(point.y));
183
184 ptarray_set_point4d(pa, i, &point);
185 }
186
187 return pa;
188#endif
189}
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
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
double x
Definition liblwgeom.h:414
double z
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414
uint8_t * serialized_pointlist
Definition liblwgeom.h:434

References LWDEBUG, LWDEBUGF, lwerror(), ptarray_construct(), ptarray_set_point4d(), POINTARRAY::serialized_pointlist, POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by GEOS2LWGEOM(), and lwtin_from_geos().

Here is the call graph for this function:
Here is the caller graph for this function: