PostGIS  2.3.7dev-r@@SVN_REVISION@@
static GEOSGeometry* ptarray_to_GEOSLinearRing ( const POINTARRAY pa,
int  autofix 
)
static

Definition at line 254 of file liblwgeom/lwgeom_geos.c.

References POINTARRAY::flags, FLAGS_NDIMS, getPoint_internal(), POINTARRAY::npoints, ptarray_addPoint(), ptarray_free(), ptarray_is_closed_2d(), and ptarray_to_GEOSCoordSeq().

Referenced by LWGEOM2GEOS().

255 {
256  GEOSCoordSeq sq;
257  GEOSGeom g;
258  POINTARRAY *npa = 0;
259 
260  if ( autofix )
261  {
262  /* check ring for being closed and fix if not */
263  if ( ! ptarray_is_closed_2d(pa) )
264  {
265  npa = ptarray_addPoint(pa, getPoint_internal(pa, 0), FLAGS_NDIMS(pa->flags), pa->npoints);
266  pa = npa;
267  }
268  /* TODO: check ring for having at least 4 vertices */
269 #if 0
270  while ( pa->npoints < 4 )
271  {
272  npa = ptarray_addPoint(npa, getPoint_internal(pa, 0), FLAGS_NDIMS(pa->flags), pa->npoints);
273  }
274 #endif
275  }
276 
277  sq = ptarray_to_GEOSCoordSeq(pa);
278  if ( npa ) ptarray_free(npa);
279  g = GEOSGeom_createLinearRing(sq);
280  return g;
281 }
int npoints
Definition: liblwgeom.h:370
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:694
GEOSCoordSeq ptarray_to_GEOSCoordSeq(const POINTARRAY *)
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:368
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:151

Here is the call graph for this function:

Here is the caller graph for this function: