PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwpoly_from_lwlines()

LWPOLY* lwpoly_from_lwlines ( const LWLINE shell,
uint32_t  nholes,
const LWLINE **  holes 
)

Definition at line 360 of file lwpoly.c.

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

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().

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