PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWGEOM * lwpoly_make_geos_friendly ( LWPOLY poly)

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

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

Referenced by lwgeom_make_geos_friendly().

239 {
240  LWGEOM* ret;
241  POINTARRAY **new_rings;
242  int i;
243 
244  /* If the polygon has no rings there's nothing to do */
245  if ( ! poly->nrings ) return (LWGEOM*)poly;
246 
247  /* Allocate enough pointers for all rings */
248  new_rings = lwalloc(sizeof(POINTARRAY*)*poly->nrings);
249 
250  /* All rings must be closed and have > 3 points */
251  for (i=0; i<poly->nrings; i++)
252  {
253  POINTARRAY* ring_in = poly->rings[i];
254  POINTARRAY* ring_out = ring_make_geos_friendly(ring_in);
255 
256  if ( ring_in != ring_out )
257  {
258  LWDEBUGF(3, "lwpoly_make_geos_friendly: ring %d cleaned, now has %d points", i, ring_out->npoints);
259  /* this may come right from
260  * the binary representation lands
261  */
262  /*ptarray_free(ring_in); */
263  }
264  else
265  {
266  LWDEBUGF(3, "lwpoly_make_geos_friendly: ring %d untouched", i);
267  }
268 
269  assert ( ring_out );
270  new_rings[i] = ring_out;
271  }
272 
273  lwfree(poly->rings);
274  poly->rings = new_rings;
275  ret = (LWGEOM*)poly;
276 
277  return ret;
278 }
void lwfree(void *mem)
Definition: lwutil.c:190
int npoints
Definition: liblwgeom.h:327
POINTARRAY ** rings
Definition: liblwgeom.h:413
int nrings
Definition: liblwgeom.h:411
POINTARRAY * ring_make_geos_friendly(POINTARRAY *ring)
void * lwalloc(size_t size)
Definition: lwutil.c:175
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55

Here is the call graph for this function:

Here is the caller graph for this function: