PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ ring_make_geos_friendly()

POINTARRAY * ring_make_geos_friendly ( POINTARRAY ring)

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

References POINTARRAY::flags, FLAGS_NDIMS, getPoint_internal(), LWDEBUGF, POINTARRAY::npoints, ptarray_addPoint(), ptarray_close2d(), and ptarray_free().

Referenced by LWGEOM_GEOS_getPointN(), and lwpoly_make_geos_friendly().

190 {
191  POINTARRAY* closedring;
192  POINTARRAY* ring_in = ring;
193 
194  /* close the ring if not already closed (2d only) */
195  closedring = ptarray_close2d(ring);
196  if (closedring != ring) ring = closedring;
197 
198  /* return 0 for collapsed ring (after closeup) */
199 
200  while (ring->npoints < 4)
201  {
202  POINTARRAY* oring = ring;
203  LWDEBUGF(4, "ring has %d points, adding another", ring->npoints);
204  /* let's add another... */
205  ring = ptarray_addPoint(ring, getPoint_internal(ring, 0), FLAGS_NDIMS(ring->flags), ring->npoints);
206  if (oring != ring_in) ptarray_free(oring);
207  }
208 
209  return ring;
210 }
POINTARRAY * ptarray_close2d(POINTARRAY *ring)
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
Definition: ptarray.c:503
uint8_t flags
Definition: liblwgeom.h:371
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1750
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:151
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: