PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ring_make_geos_friendly()

POINTARRAY * ring_make_geos_friendly ( POINTARRAY ring)

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

196 {
197  POINTARRAY* closedring;
198  POINTARRAY* ring_in = ring;
199 
200  /* close the ring if not already closed (2d only) */
201  closedring = ptarray_close2d(ring);
202  if (closedring != ring )
203  {
204  ring = closedring;
205  }
206 
207  /* return 0 for collapsed ring (after closeup) */
208 
209  while ( ring->npoints < 4 )
210  {
211  POINTARRAY *oring = ring;
212  LWDEBUGF(4, "ring has %d points, adding another", ring->npoints);
213  /* let's add another... */
214  ring = ptarray_addPoint(ring,
215  getPoint_internal(ring, 0),
216  FLAGS_NDIMS(ring->flags),
217  ring->npoints);
218  if ( oring != ring_in ) ptarray_free(oring);
219  }
220 
221 
222  return ring;
223 }
POINTARRAY * ptarray_close2d(POINTARRAY *ring)
int npoints
Definition: liblwgeom.h:371
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
Definition: ptarray.c:504
uint8_t flags
Definition: liblwgeom.h:369
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
Here is the call graph for this function:
Here is the caller graph for this function: