PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ ring_make_geos_friendly()

POINTARRAY * ring_make_geos_friendly ( POINTARRAY ring)

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

143 {
144  POINTARRAY* closedring;
145  POINTARRAY* ring_in = ring;
146 
148 
149  /* close the ring if not already closed (2d only) */
150  closedring = ptarray_close2d(ring);
151  if (closedring != ring) ring = closedring;
152 
153  /* return 0 for collapsed ring (after closeup) */
154 
155  while (ring->npoints < 4)
156  {
157  POINTARRAY* oring = ring;
158  LWDEBUGF(4, "ring has %d points, adding another", ring->npoints);
159  /* let's add another... */
160  ring = ptarray_addPoint(ring, getPoint_internal(ring, 0), FLAGS_NDIMS(ring->flags), ring->npoints);
161  if (oring != ring_in) ptarray_free(oring);
162  }
163 
164  return ring;
165 }
static POINTARRAY * ptarray_close2d(POINTARRAY *ring)
static void ptarray_strip_nan_coords_in_place(POINTARRAY *pa)
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
Definition: ptarray.c:530
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:179
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:327
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:106
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: lwinline.h:75
lwflags_t flags
Definition: liblwgeom.h:431
uint32_t npoints
Definition: liblwgeom.h:427

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

Referenced by lwpoly_make_geos_friendly().

Here is the call graph for this function:
Here is the caller graph for this function: