PostGIS  2.5.0dev-r@@SVN_REVISION@@
LWPOLY* lwpoly_from_lwlines ( const LWLINE shell,
uint32_t  nholes,
const LWLINE **  holes 
)

Definition at line 358 of file lwpoly.c.

References lwalloc(), lwerror(), lwpoly_construct(), POINTARRAY::npoints, LWLINE::points, ptarray_clone_deep(), ptarray_is_closed_2d(), and LWLINE::srid.

Referenced by lwgeom_force_sfs(), and LWGEOM_makepoly().

360 {
361  uint32_t nrings;
362  POINTARRAY **rings = lwalloc((nholes+1)*sizeof(POINTARRAY *));
363  int srid = shell->srid;
364  LWPOLY *ret;
365 
366  if ( shell->points->npoints < 4 )
367  lwerror("lwpoly_from_lwlines: shell must have at least 4 points");
368  if ( ! ptarray_is_closed_2d(shell->points) )
369  lwerror("lwpoly_from_lwlines: shell must be closed");
370  rings[0] = ptarray_clone_deep(shell->points);
371 
372  for (nrings=1; nrings<=nholes; nrings++)
373  {
374  const LWLINE *hole = holes[nrings-1];
375 
376  if ( hole->srid != srid )
377  lwerror("lwpoly_from_lwlines: mixed SRIDs in input lines");
378 
379  if ( hole->points->npoints < 4 )
380  lwerror("lwpoly_from_lwlines: holes must have at least 4 points");
381  if ( ! ptarray_is_closed_2d(hole->points) )
382  lwerror("lwpoly_from_lwlines: holes must be closed");
383 
384  rings[nrings] = ptarray_clone_deep(hole->points);
385  }
386 
387  ret = lwpoly_construct(srid, NULL, nrings, rings);
388  return ret;
389 }
int32_t srid
Definition: liblwgeom.h:420
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:688
unsigned int uint32_t
Definition: uthash.h:78
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:628
void * lwalloc(size_t size)
Definition: lwutil.c:229
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:421
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: