PostGIS  2.2.7dev-r@@SVN_REVISION@@
POINTARRAY * ring_make_geos_friendly ( POINTARRAY ring)

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

206 {
207  POINTARRAY* closedring;
208  POINTARRAY* ring_in = ring;
209 
210  /* close the ring if not already closed (2d only) */
211  closedring = ptarray_close2d(ring);
212  if (closedring != ring )
213  {
214  ring = closedring;
215  }
216 
217  /* return 0 for collapsed ring (after closeup) */
218 
219  while ( ring->npoints < 4 )
220  {
221  POINTARRAY *oring = ring;
222  LWDEBUGF(4, "ring has %d points, adding another", ring->npoints);
223  /* let's add another... */
224  ring = ptarray_addPoint(ring,
225  getPoint_internal(ring, 0),
226  FLAGS_NDIMS(ring->flags),
227  ring->npoints);
228  if ( oring != ring_in ) ptarray_free(oring);
229  }
230 
231 
232  return ring;
233 }
POINTARRAY * ptarray_close2d(POINTARRAY *ring)
int npoints
Definition: liblwgeom.h:355
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:509
uint8_t flags
Definition: liblwgeom.h:353
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136

Here is the call graph for this function:

Here is the caller graph for this function: