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

◆ lwpoly_make_geos_friendly()

LWGEOM * lwpoly_make_geos_friendly ( LWPOLY poly)

Definition at line 171 of file liblwgeom/lwgeom_geos_clean.c.

172{
173 LWGEOM* ret;
174 POINTARRAY** new_rings;
175 uint32_t i;
176
177 /* If the polygon has no rings there's nothing to do */
178 if (!poly->nrings) return (LWGEOM*)poly;
179
180 /* Allocate enough pointers for all rings */
181 new_rings = lwalloc(sizeof(POINTARRAY*) * poly->nrings);
182
183 /* All rings must be closed and have > 3 points */
184 for (i = 0; i < poly->nrings; i++)
185 {
186 POINTARRAY* ring_in = poly->rings[i];
187 POINTARRAY* ring_out = ring_make_geos_friendly(ring_in);
188
189 if (ring_in != ring_out)
190 {
191 LWDEBUGF(
192 3, "lwpoly_make_geos_friendly: ring %d cleaned, now has %d points", i, ring_out->npoints);
193 ptarray_free(ring_in);
194 }
195 else
196 LWDEBUGF(3, "lwpoly_make_geos_friendly: ring %d untouched", i);
197
198 assert(ring_out);
199 new_rings[i] = ring_out;
200 }
201
202 lwfree(poly->rings);
203 poly->rings = new_rings;
204 ret = (LWGEOM*)poly;
205
206 return ret;
207}
POINTARRAY * ring_make_geos_friendly(POINTARRAY *ring)
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
void ptarray_free(POINTARRAY *pa)
Definition ptarray.c:327
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524
uint32_t npoints
Definition liblwgeom.h:427

References lwalloc(), LWDEBUGF, lwfree(), POINTARRAY::npoints, LWPOLY::nrings, ptarray_free(), ring_make_geos_friendly(), and LWPOLY::rings.

Referenced by lwgeom_make_geos_friendly().

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