PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ lwpoly_make_geos_friendly()

LWGEOM * lwpoly_make_geos_friendly ( LWPOLY poly)

Definition at line 216 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().

217 {
218  LWGEOM* ret;
219  POINTARRAY** new_rings;
220  uint32_t i;
221 
222  /* If the polygon has no rings there's nothing to do */
223  if (!poly->nrings) return (LWGEOM*)poly;
224 
225  /* Allocate enough pointers for all rings */
226  new_rings = lwalloc(sizeof(POINTARRAY*) * poly->nrings);
227 
228  /* All rings must be closed and have > 3 points */
229  for (i = 0; i < poly->nrings; i++)
230  {
231  POINTARRAY* ring_in = poly->rings[i];
232  POINTARRAY* ring_out = ring_make_geos_friendly(ring_in);
233 
234  if (ring_in != ring_out)
235  {
236  LWDEBUGF(
237  3, "lwpoly_make_geos_friendly: ring %d cleaned, now has %d points", i, ring_out->npoints);
238  ptarray_free(ring_in);
239  }
240  else
241  LWDEBUGF(3, "lwpoly_make_geos_friendly: ring %d untouched", i);
242 
243  assert(ring_out);
244  new_rings[i] = ring_out;
245  }
246 
247  lwfree(poly->rings);
248  poly->rings = new_rings;
249  ret = (LWGEOM*)poly;
250 
251  return ret;
252 }
void lwfree(void *mem)
Definition: lwutil.c:244
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
uint32_t nrings
Definition: liblwgeom.h:457
unsigned int uint32_t
Definition: uthash.h:78
POINTARRAY ** rings
Definition: liblwgeom.h:459
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
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: