PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwpoly_make_geos_friendly()

LWGEOM * lwpoly_make_geos_friendly ( LWPOLY poly)

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

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

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: