PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lwpoly_make_geos_friendly()

LWGEOM * lwpoly_make_geos_friendly ( LWPOLY poly)

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

252 {
253  LWGEOM* ret;
254  POINTARRAY** new_rings;
255  uint32_t i;
256 
257  /* If the polygon has no rings there's nothing to do */
258  if (!poly->nrings) return (LWGEOM*)poly;
259 
260  /* Allocate enough pointers for all rings */
261  new_rings = lwalloc(sizeof(POINTARRAY*) * poly->nrings);
262 
263  /* All rings must be closed and have > 3 points */
264  for (i = 0; i < poly->nrings; i++)
265  {
266  POINTARRAY* ring_in = poly->rings[i];
267  POINTARRAY* ring_out = ring_make_geos_friendly(ring_in);
268 
269  if (ring_in != ring_out)
270  {
271  LWDEBUGF(
272  3, "lwpoly_make_geos_friendly: ring %d cleaned, now has %d points", i, ring_out->npoints);
273  ptarray_free(ring_in);
274  }
275  else
276  LWDEBUGF(3, "lwpoly_make_geos_friendly: ring %d untouched", i);
277 
278  assert(ring_out);
279  new_rings[i] = ring_out;
280  }
281 
282  lwfree(poly->rings);
283  poly->rings = new_rings;
284  ret = (LWGEOM*)poly;
285 
286  return ret;
287 }
POINTARRAY * ring_make_geos_friendly(POINTARRAY *ring)
void lwfree(void *mem)
Definition: lwutil.c:242
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:319
void * lwalloc(size_t size)
Definition: lwutil.c:227
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
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: