PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ ptarray_to_GEOSLinearRing()

static GEOSGeometry* ptarray_to_GEOSLinearRing ( const POINTARRAY pa,
int  autofix 
)
static

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

250 {
251  GEOSCoordSeq sq;
252  GEOSGeom g;
253  POINTARRAY *npa = 0;
254 
255  if ( autofix )
256  {
257  /* check ring for being closed and fix if not */
258  if ( ! ptarray_is_closed_2d(pa) )
259  {
260  npa = ptarray_addPoint(pa, getPoint_internal(pa, 0), FLAGS_NDIMS(pa->flags), pa->npoints);
261  pa = npa;
262  }
263  /* TODO: check ring for having at least 4 vertices */
264 #if 0
265  while ( pa->npoints < 4 )
266  {
267  npa = ptarray_addPoint(npa, getPoint_internal(pa, 0), FLAGS_NDIMS(pa->flags), pa->npoints);
268  }
269 #endif
270  }
271 
272  sq = ptarray_to_GEOSCoordSeq(pa);
273  if ( npa ) ptarray_free(npa);
274  g = GEOSGeom_createLinearRing(sq);
275  return g;
276 }
int npoints
Definition: liblwgeom.h:355
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:353
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136
Here is the call graph for this function:
Here is the caller graph for this function: