PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ lwpoly_make_geos_friendly()

LWGEOM * lwpoly_make_geos_friendly ( LWPOLY poly)

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

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

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: