PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwpoly_make_geos_friendly()

LWGEOM * lwpoly_make_geos_friendly ( LWPOLY poly)

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

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

Referenced by LWGEOM_GEOS_getPointN(), and lwgeom_make_geos_friendly().

230 {
231  LWGEOM* ret;
232  POINTARRAY **new_rings;
233  int i;
234 
235  /* If the polygon has no rings there's nothing to do */
236  if ( ! poly->nrings ) return (LWGEOM*)poly;
237 
238  /* Allocate enough pointers for all rings */
239  new_rings = lwalloc(sizeof(POINTARRAY*)*poly->nrings);
240 
241  /* All rings must be closed and have > 3 points */
242  for (i=0; i<poly->nrings; i++)
243  {
244  POINTARRAY* ring_in = poly->rings[i];
245  POINTARRAY* ring_out = ring_make_geos_friendly(ring_in);
246 
247  if ( ring_in != ring_out )
248  {
249  LWDEBUGF(3, "lwpoly_make_geos_friendly: ring %d cleaned, now has %d points", i, ring_out->npoints);
250  ptarray_free(ring_in);
251  }
252  else
253  {
254  LWDEBUGF(3, "lwpoly_make_geos_friendly: ring %d untouched", i);
255  }
256 
257  assert ( ring_out );
258  new_rings[i] = ring_out;
259  }
260 
261  lwfree(poly->rings);
262  poly->rings = new_rings;
263  ret = (LWGEOM*)poly;
264 
265  return ret;
266 }
void lwfree(void *mem)
Definition: lwutil.c:244
int npoints
Definition: liblwgeom.h:371
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
POINTARRAY ** rings
Definition: liblwgeom.h:457
int nrings
Definition: liblwgeom.h:455
POINTARRAY * ring_make_geos_friendly(POINTARRAY *ring)
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Here is the call graph for this function:
Here is the caller graph for this function: